windows 如何在windows编程中实现“选择文件”功能?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2167922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:51:18  来源:igfitidea点击:

how to make "choose file" function on windows programming?

c++windows

提问by Newbie

I need this us all known "choose file" feature in my program, so i can load files.

我需要在我的程序中使用这个众所周知的“选择文件”功能,以便我可以加载文件。

What is this thing called as and where is the code for it?

这个东西叫什么,它的代码在哪里?

回答by Paul Dixon

What you are referring to are the "common dialogs", and you can get a file open dialog with GetOpenFileName

您所指的是“常见对话框”,您可以使用GetOpenFileName获得文件打开对话框

BOOL GetOpenFileName(      
    LPOPENFILENAME lpofn
);

A sample is available here

示例可在此处获得

回答by Eli Bendersky

With plain Win32 API you need to use the GetOpenFileNamefunction, documented here. An example of its usage is available here.

使用普通的 Win32 API,您需要使用该GetOpenFileName函数,记录在此处此处提供了其用法示例。

回答by H?vard S

I'm assuming you want to know about the built-in Windows dialog for choosing/opening a file.

我假设您想了解用于选择/打开文件的内置 Windows 对话框。

If you're doing managed code, see OpenFileDialog.

如果您正在执行托管代码,请参阅OpenFileDialog

If you're doing MFC, see CFileDialog.

如果您正在使用 MFC,请参阅CFileDialog