How do I call the DialogBox() function in the user32.dll?

耗尽温柔 提交于 2019-12-11 23:59:21

问题


I'm trying to call the WinAPI function DialogBox(). On the Microsoft website this function is specified to be in the user32.dll. However, when tried to import this function by declaring it as function to import from a dll, the linker told me it isn't there. Then I tried to find the function with the dependency walker in C:\Windows\System32\user32.dll, but the function wasn't there. (I could see all the other fancy function literals there though.) What can be reasons for that and how can I solve the problem?

I'm using the D programming language. The windows module from the standard library does not import the complete set of functions in the WinAPI. Therefore I sometimes have to import stuff by hand.


回答1:


That's accurate, there is no such function. From the WinUser32.h SDK header file:

#define DialogBoxA(hInstance, lpTemplate, hWndParent, lpDialogFunc) \
DialogBoxParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
#define DialogBoxW(hInstance, lpTemplate, hWndParent, lpDialogFunc) \
DialogBoxParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)

In other words, the C preprocesor renames the function to DialogBoxParam. That's the only one you can pinvoke. Just pass a zero like the macro does.



来源:https://stackoverflow.com/questions/11885247/how-do-i-call-the-dialogbox-function-in-the-user32-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!