开发者

How to use the Windows API in MinGW?

How to use the Windows API in Min开发者_Go百科GW?


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.


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.


In case if you installed MinGW as a part of MSYS on Windows then you can install Windows.h and other Win-API headers through following command inside MSYS shell:

pacman -S msys2-w32api-headers msys2-w32api-runtime

then header is located in

c:/MSYS_PATH/usr/include/w32api/windows.h

also you can search any package name (or sub-name) through e.g.

pacman -Ss w32api


If you're on Linux then Windows.h can be installed through

sudo apt install mingw-w64-common

then header is located here

/usr/share/mingw-w64/include/windows.h

you may probably need to include compiler's option

-I/usr/share/mingw-w64/include/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜