什么是“ShowWindow Lib“user32”? ” 关于?
我正在查看另一位开发人员编写的一些代码,发现了这一点:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些是 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.
这些几乎肯定是 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.