C++ 如何在 MinGW 中使用 Windows API?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1549123/
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
How to use the Windows API in MinGW?
提问by SomeUser
How to use the Windows APIin MinGW?
如何在MinGW 中使用Windows API?
回答by Greg Hewgill
Whenever I've done this, I just
每当我这样做时,我只是
#include <windows.h>
and start coding. MinGW comes with a windows.h
file so you don't need to do anything extra.
并开始编码。MinGW 附带一个windows.h
文件,因此您无需执行任何额外操作。
回答by Rob
I occasionally use the Windows API for Qt apps that I build using Qt Creator/MinGW - I just #include
the appropriate Windows SDK header (the headers come with MinGW) and it just works. However, you may need to #define
a few things in order that some API calls are exposed. For example, I recently needed to call SHGetSpecialFolderPath
(found in shlobj.h
) but needed to define _WIN32_IE
to 0x0400
first.
我偶尔会为使用 Qt Creator/MinGW 构建的 Qt 应用程序使用 Windows API - 我只是#include
使用适当的 Windows SDK 标头(标头与 MinGW 一起提供)并且它可以正常工作。但是,您可能需要做#define
一些事情才能公开某些 API 调用。例如,我最近需要调用SHGetSpecialFolderPath
(在 中找到shlobj.h
)但需要先定义_WIN32_IE
to 0x0400
。