Original link: https://ifmet.cn/posts/ec046916/
Brief description: The respective meanings of WINUSERAPI and WINAPI frequently encountered in Window API.
[TOC]
This article was originally published on ” Xie Zang’s Small Station “, and is reproduced here simultaneously.
background
In the research to realize the cross-platform AcrylicWindow acrylic (similar to transparent frosted) effect, when calling the Windows API, I found that the definition of its function is as follows, and I found that these two macros are a bit strange, so I was a little lost, so I checked the meaning of WINUSERAPI
/ WINAPI
.
WINUSERAPI BOOL WINAPI SetWindowCompositionAttribute ( _In_ HWND hWnd , _Inout_ WINDOWCOMPOSITIONATTRIBDATA * pAttrData ) ;
WINUSERAPI
Indicates the import of a function
WINUSERAPI // 定义一# if ! defined ( _USER32_ ) # define WINUSERAPI DECLSPEC_IMPORT # else # define WINUSERAPI extern "C" # endif // 定义二# define DECLSPEC_IMPORT __declspec ( dllimport )
From the definition of the two-level meaning, WINUSERAPI
roughly regarded as the keyword __declspec(dllimport);
__declspec(dllimport) means that you tell the compiler to explicitly import functions from the dll; especially when the class has a static member, the Link will basically fail without it. See this article
WINAPI
Commonly used macros WINAPI or CALLBACK to represent the __stdcall
calling convention. Indicates that when parameters are pushed onto the stack, they are sequentially pushed onto the stack from right to left. Other calling conventions by yourself Googel Keywords: function calling convention
1 #define CALLBACK __stdcall 2 #define WINAPI __stdcall
Serial address
Welcome to star
⭐ and fork
? this series of C++ / QT / DTK
learning, with a list of learning from shallow to deep.
This article is reproduced from: https://ifmet.cn/posts/ec046916/
This site is for inclusion only, and the copyright belongs to the original author.