我刚刚在我的应用程序中遇到问题,我需要获取CreateWindowW
函数的静态地址.像这样:
&ShowWindow;
但是,当使用相同的技巧时CreateWindowW
,我得到编译器错误 Identifier "CreateWindowW" is undefined
(它是一个宏).我实际上找不到这个函数的定义(哪个DLL),甚至pinvoke.net也没有提到这个.
在某些网站上有提及它user32.dll
,但GetProcAddress
对于我的函数,它返回null指针.我迷路了,Windows上哪个模块链接了这个功能?
如果我尝试将调试器和跟踪调用连接到此函数,Visual Studio会"跳过"它,所以我无法理解调用的位置.
我的构建是UNICODE.WinUser.h文本我可以看到:
#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y,\ nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y,\ nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y,\ nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y,\ nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #ifdef UNICODE #define CreateWindow CreateWindowW #else #define CreateWindow CreateWindowA #endif // !UNICODE
Cheers and h.. 6
CreateWindowExW
出口user32.dll
.您只需查看文档即可.或者您可以通过Microsoft的dumpbin
工具检查导出.
> dumpbin /exports c:\windows\system32\user32.dll | find /i "CreateWindow" 1618 6D 0000A230 CreateWindowExA 1619 6E 000107B8 CreateWindowExW 1620 6F 00041530 CreateWindowStationA 1621 70 000014D0 CreateWindowStationW
CreateWindowW
是一个实现为宏的瘦包装器,根据其文档:
"
CreateWindow
实现为对CreateWindowEx
函数的调用,如下所示.#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #ifdef UNICODE #define CreateWindow CreateWindowW #else #define CreateWindow CreateWindowA #endif
您还可以通过例如Visual Studio中的"转到定义"来检查.
CreateWindowExW
出口user32.dll
.您只需查看文档即可.或者您可以通过Microsoft的dumpbin
工具检查导出.
> dumpbin /exports c:\windows\system32\user32.dll | find /i "CreateWindow" 1618 6D 0000A230 CreateWindowExA 1619 6E 000107B8 CreateWindowExW 1620 6F 00041530 CreateWindowStationA 1621 70 000014D0 CreateWindowStationW
CreateWindowW
是一个实现为宏的瘦包装器,根据其文档:
"
CreateWindow
实现为对CreateWindowEx
函数的调用,如下所示.#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #ifdef UNICODE #define CreateWindow CreateWindowW #else #define CreateWindow CreateWindowA #endif
您还可以通过例如Visual Studio中的"转到定义"来检查.