Imports System.Reflection
Imports System.Text
Imports System.Runtime.InteropServices


    Public Class Win32Functions
        ' Flags of SetWindowPos
        Public Const SWP_FRAMECHANGED As Integer = &H20
        Public Const SWP_NOACTIVATE As Integer = &H10
        Public Const SWP_NOMOVE As Integer = &H2
        Public Const SWP_NOSIZE As Integer = &H1
        Public Const SWP_NOZORDER As Integer = &H4
        Public Const SWP_SHOWWINDOW As Integer = &H40
    Public Const SWP_NOSENDCHANGING As Integer = &H400
    Public Const VK_RETURN As Long = &HD
    Public Const WM_GETTEXTLENGTH As Long = &HE
    Public Const WM_SETTEXT As Long = &HC
    Public Const WM_GETTEXT As Long = &HD
    Public Const WM_CHAR As Long = &H102
    Public Const WM_KEYDOWN As Long = &H100
    Public Const WM_KEYUP As Long = &H101
    Public Const WM_PASTE As Long = &H302
    Public Const WM_COPYDATA As Long = &H4A
    Public Const WM_RBUTTONDOWN As Long = &H204
    Public Const WM_LBUTTONDOWN As Long = &H201
    Public Const WM_LBUTTONUP As Long = &H202
    Public Const SMTO_BLOCK As Long = &H1
    Public Const WM_CLOSE = &H10
    Public Const WM_SETFOCUS = &H7
    Public Const GWL_WNDPROC = (-4)
    Public Const WM_MENUSELECT = &H11F
    Public Const WM_RBUTTONUP As Long = &H205
    Public Const GW_HWNDFIRST = 0
    Public Const GW_HWNDNEXT = 2
    Public Const GW_CHILD = 5
    Public Const MF_BYCOMMAND& = &H0&
    Public Const MF_BYPOSITION& = &H400&

    Declare Function GetWindow Lib "user32" (ByVal hWnd As IntPtr, ByVal wCmd As Long) As IntPtr
    Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Integer
    Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Integer) As Integer
    Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
    Declare Ansi Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As IntPtr, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Int32) As Int32
    Delegate Function EnumChildProc(ByVal hWnd As IntPtr, ByRef lParam As IntPtr) As Int32
    Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As IntPtr, ByVal lpEnumFunc As EnumChildProc, ByRef lParam As IntPtr) As Int32
        Declare Ansi Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Int32
    Declare Ansi Function SendMessageTimeout Lib "user32" Alias "SendMessageTimeoutA" (ByVal hWnd As IntPtr, ByVal msg As Int32, ByVal wParam As Int32, ByVal lParam As Int32, ByVal fuFlags As Int32, ByVal uTimeout As Int32, ByRef lpdwResult As Int32) As Int32
    Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Integer) As Boolean
        Public Const SMTO_ABORTIFHUNG As Int32 = &H2
    Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
             ByVal lpClassName As String, _
             ByVal lpWindowName As String) As IntPtr

    Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" ( _
      ByVal hWnd1 As IntPtr, _
      ByVal hWnd2 As Int32, _
      ByVal lpsz1 As String, _
      ByVal lpsz2 As String) As IntPtr

    Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
        (ByVal hWnd As IntPtr, _
        ByVal wMsg As Int32, _
        ByVal wParam As Int32, _
        ByVal lParam As Int32) As Boolean

    Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
      ByVal hwnd As IntPtr, _
      ByVal wMsg As Int32, _
      ByVal wParam As Int32, _
      ByVal lParam As String) As Int32

    Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
    Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" ( _
        ByVal hMenu As Long, ByVal ByValwIDItem As Long, ByVal lpString As String, _
        ByVal nMaxCount As Long, ByVal wFlag As Long) As Long
    Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Int32) As Int32
    Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Int32) As Int32

    Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" ( _
        ByVal hwnd As IntPtr, _
        ByVal lpClassName As String, _
        ByVal nMaxCount As Int32) As Int32

End Class


