MSDN打开对话框示例代码 [英] MSDN open dialog box sample code
问题描述
所以我试图从 MSDN 运行和编译这段示例代码(打开一个对话框):http://msdn.microsoft.com/en-us/library/ff485843(v=vs.85).aspx
So I'm trying to run and compile this piece of sample code from MSDN (opening a dialig box): http://msdn.microsoft.com/en-us/library/ff485843(v=vs.85).aspx
我的编译器报错:main.cpp:在函数int wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)"中:main.cpp:19:9: 错误:'IFileOpenDialog' 未在此范围内声明
My compiler gives an error: main.cpp: In function 'int wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)': main.cpp:19:9: error: 'IFileOpenDialog' was not declared in this scope
我从文档中得到的是 CoInitializeEx 函数应该链接到必要的 COM 库并导入所需的函数.虽然我对 C++ 和 Windows 完全陌生,但我肯定会出错.
What I get from the documentation is that CoInitializeEx function should link against the necessary COM libraries and import the needed functions. Though I am totally new to C++ and Windows and for sure I'm getting something wrong.
我使用 Netbeans、MinGW 和 MSYS.
I use Netbeans, MinGW and MSYS.
有人能帮我看看这里发生了什么以及如何解决吗?
Can somebody help me out what is happening here and how to solve?
推荐答案
MinGW g++ 自 4.8.2 版(我拥有的那个)起尚不支持在 Windows Vista 或更高版本中引入的 Windows API 函数或接口.
MinGW g++ as of version 4.8.2 (the one I have) does not yet support Windows API functions or interfaces that were introduced in Windows Vista or later.
作为一种解决方法,您可以使用旧的 GetOpenFileName
或 GetSaveFileName
对话框.
As a workaround you can use the old GetOpenFileName
or GetSaveFileName
dialog.
或者下载并安装适用于 Windows 桌面的 Visual Studio Express,并使用 Visual C++.
Alternatively download and install Visual Studio Express for Windows Desktop, and use Visual C++.
这篇关于MSDN打开对话框示例代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!