Reputation: 1865
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?
Upvotes: 1
Views: 11666
Reputation: 755121
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.
Upvotes: 3
Reputation: 74672
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.
Upvotes: 0