如何在user32.dll中调用DialogBox()函数? [英] How do I call the DialogBox() function in the user32.dll?

查看:118
本文介绍了如何在user32.dll中调用DialogBox()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调用WinAPI函数 DialogBox()。在 Microsoft网站此函数指定为在user32.dll中。但是,当尝试通过将其声明为要从dll导入的函数来导入该函数时,链接器告诉我它不存在。然后,我尝试在C:\Windows\System32\user32.dll中找到带有依赖项遍历器的函数,但该函数不存在。 (我在那里可以看到所有其他奇特的函数文字。)这可能是什么原因,我该如何解决这个问题?

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?

我正在使用D编程语言。标准库中的Windows模块未将WinAPI中的完整功能集导入。因此,有时我不得不手工进口东西。

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.

推荐答案

没错,没有这样的功能。从WinUser32.h SDK头文件中:

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)

换句话说,C预处理程序将函数重命名为DialogBoxParam。那是您唯一可以选择的一个。只需像宏一样传递零即可。

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.

这篇关于如何在user32.dll中调用DialogBox()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆