简体   繁体   English

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

[英]What is “ShowWindow Lib ”user32“ ” about?

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? 它是做什么用的,它是做什么用的?

These are PInvoke declarations. 这些是PInvoke声明。 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. 它们表示存在于C库中的函数,并且以允许从VB.Net调用它们的方式进行定义。 For instance, ShowWindow is a declaration of the Win32 ShowWindow function present in user32.dll. 例如,ShowWindow是user32.dll中存在的Win32 ShowWindow函数的声明。 Calling this stub will end up calling the C function. 调用此存根将最终调用C函数。

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

This particular style of declaration is known as Dll Declare. 这种特殊的声明样式称为Dll Declare。 The more common syntax is to use DllImport and shared methods (mainly because its' compatible with C#'s implementation). 更常见的语法是使用DllImport和共享方法(主要是因为它与C#的实现兼容)。 The DllDeclare syntax is in many ways a holdover from VB6 style interop. DllDeclare语法在许多方面都是VB6样式互操作的保留。

These are almost certainly P/Invoke calls; 这些几乎可以肯定是P / Invoke调用。 ie a declaration that allows you to call a Windows API function, that is declared in user32.dll. 即,一个声明,允许您调用Windows API函数,该声明在user32.dll中声明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM