什么是“ShowWindow Lib“user32”? ” 关于?

发布于 2024-07-25 04:39:33 字数 292 浏览 3 评论 0原文

我正在查看另一位开发人员编写的一些代码,发现了这一点:

Private Declare Function ShowWindow Lib "user32" (ByVal handle As IntPtr, ByVal nCmdShow As Integer) As Integer
Private Declare Function SetForegroundWindow Lib "user32" (ByVal handle As IntPtr) As Integer

它的作用是什么以及它的用途是什么?

I was looking over some code that another developer wrote and found this:

Private Declare Function ShowWindow Lib "user32" (ByVal handle As IntPtr, ByVal nCmdShow As Integer) As Integer
Private Declare Function SetForegroundWindow Lib "user32" (ByVal handle As IntPtr) As Integer

What does it do and what is it for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光病人 2024-08-01 04:39:33

这些是 PInvoke 声明。 它们代表 C 库中存在的函数,并以允许从 VB.Net 调用它们的方式定义。 例如,ShowWindow 是 user32.dll 中 Win32 ShowWindow 函数的声明。 调用此存根最终将调用 C 函数。

ShowWindow:http://msdn.microsoft.com/en-us/library/ ms633548.aspx

这种特殊的声明风格称为 Dll Declare。 更常见的语法是使用 DllImport 和共享方法(主要是因为它与 C# 的实现兼容)。 DllDeclare 语法在很多方面都是 VB6 风格互操作的延续。

These are PInvoke declarations. They represent functions that exist in C libraries and are defined in such a way as to allow them to be called from VB.Net. For instance, ShowWindow is a declaration of the Win32 ShowWindow function present in user32.dll. Calling this stub will end up calling the C function.

ShowWindow: http://msdn.microsoft.com/en-us/library/ms633548.aspx

This particular style of declaration is known as Dll Declare. The more common syntax is to use DllImport and shared methods (mainly because its' compatible with C#'s implementation). The DllDeclare syntax is in many ways a holdover from VB6 style interop.

罪歌 2024-08-01 04:39:33

这些几乎肯定是 P/Invoke 调用; 即允许您调用 Windows API 函数的声明,该函数在 user32.dll 中声明。

These are almost certainly P/Invoke calls; i.e. a declaration that allows you to call a Windows API function, that is declared in user32.dll.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文