type RECT
    left as long
    top as long
    right as long
    bottom as long
end type

type POINTAPI
    x as long
    y as long
end type

type tagMSG
    hwnd as dword
    message as dword
    wParam as long
    lParam as long
    time as dword
    pt as POINTAPI
end type

type MINMAXINFO
    ptReserved as POINTAPI
    ptMaxSize as POINTAPI
    ptMaxPosition as POINTAPI
    ptMinTrackSize as POINTAPI
    ptMaxTrackSize as POINTAPI
end type

type MONITORINFO
    cbSize as dword
    rcMonitor as RECT
    rcWork as RECT
    dwFlags as dword
end type

type STARTUPINFO
    cb as dword
    lpReserved as asciiz PTR
    lpDesktop as asciiz PTR
    lpTitle as asciiz PTR
    dwX as dword
    dwY as dword
    dwXSize as dword
    dwYSize as dword
    dwXCountChars as dword
    dwYCountChars as dword
    dwFillAttribute as dword
    dwFlags as dword
    wShowWindow as WORD
    cbReserved2 as WORD
    lpReserved2 as BYTE PTR
    hStdInput as dword
    hStdOutput as dword
    hStdError as dword
end type

type PROCESS_INFORMATION
    hProcess as dword
    hThread as dword
    dwProcessId as dword
    dwThreadId as dword
end type

type SECURITY_ATTRIBUTES
    nLength as dword
    lpSecurityDescriptor as long
    bInheritHandle as long
end type

type WNDCLASSEX
    cbSize as dword
    STYLE as dword
    lpfnWndProc as long
    cbClsExtra as long
    cbWndExtra as long
    hInstance as dword
    hIcon as dword
    hCursor as dword
    hbrBackground as dword
    lpszMenuName as asciiz PTR
    lpszClassName as asciiz PTR
    hIconSm as dword
end type

type COPYDATASTRUCT DWORD
   dwData as dword   ' ULONG_PTR
   cbData as dword   ' DWORD
   lpData as dword   ' PVOID
end type

%WM_COPYDATA             = 74
%NULL                     = 0
%TRUE                     = 1
%FALSE                    = 0
%CS_HREDRAW               = &h0002
%CS_VREDRAW               = &h0001
%ERROR_ALREADY_EXISTS     = 183
%PM_REMOVE                = &H0001
%IDC_ARROW                = 32512&
%SM_CXSCREEN              = 0
%SM_CYSCREEN              = 1
%WM_MOVE                  = &H3
%WM_SIZE                  = &H5
%WM_WINDOWPOSCHANGED      = &H47
%WM_IME_NOTIFY            = &H0282
%WM_GETMINMAXINFO         = &H24
%WM_DROPFILES             = &H233
%WM_ERASEBKGND            = &H14
%WM_SETTEXT               = &HC
%MONITOR_DEFAULTTONEAREST = &H00000002
%GWL_STYLE                = -16
%GWL_EXSTYLE              = -20
%MAX_PATH                 = 260
%SWP_NOSIZE               = &H0001
%SWP_NOMOVE               = &H0002
%SWP_NOACTIVATE           = &H0010
%SWP_NOOWNERZORDER        = &H0200
%STARTF_USESHOWWINDOW     = &H00000001
%INFINITE                 = &HFFFFFFFF???
%NORMAL_PRIORITY_CLASS    = &H00000020
%GW_HWNDNEX               = 2
%SW_SHOWNOACTIVATE        = 4

declare function CreateMutex lib "KERNEL32.DLL" alias "CreateMutexA" (lpMutexAttributes as SECURITY_ATTRIBUTES, byval bInitialOwner as long, lpName as asciiz) as long
declare function GetLastError lib "KERNEL32.DLL" alias "GetLastError" () as long
declare function FindWindow lib "USER32.DLL" alias "FindWindowA" (lpClassName as asciiz, lpWindowName as asciiz) as long
declare function PeekMessage lib "USER32.DLL" alias "PeekMessageA" (lpMsg as tagMSG, byval hWnd as dword, byval dwMsgFilterMin as dword, byval dwMsgFilterMax as dword, byval dwRemoveMsg as dword) as long
declare function IsIconic lib "USER32.DLL" alias "IsIconic" (byval hWnd as dword) as long
declare function SetForegroundWindow lib "USER32.DLL" alias "SetForegroundWindow" (byval hWnd as dword) as long
declare function GetClassInfoEx lib "USER32.DLL" alias "GetClassInfoExA" (byval hInst as dword, lpszClass as asciiz, lpWndClass as WNDCLASSEX) as long
declare function LoadIcon lib "USER32.DLL" alias "LoadIconA" (byval hInstance as dword, lpIconName as asciiz) as dword
declare function LoadCursor lib "USER32.DLL" alias "LoadCursorA" (byval hInstance as dword, lpCursorName as asciiz) as dword
declare function RegisterClassEx lib "USER32.DLL" alias "RegisterClassExA" (byref lpwcx as WNDCLASSEX) as WORD
declare function SetRect lib "USER32.DLL" alias "SetRect" (lpRect as RECT, byval X1 as long, byval Y1 as long, byval X2 as long, byval Y2 as long) as long
declare function AdjustWindowRectEx lib "USER32.DLL" alias "AdjustWindowRectEx" (lpRect as RECT, byval dsStyle as long, byval bMenu as long, byval dwEsStyle as dword) as long
declare function CreateWindowEx lib "USER32.DLL" alias "CreateWindowExA" (byval dwExStyle as dword, byref lpClassName as asciiz, byref lpWindowName as asciiz, byval dwStyle as dword, byval X as long, byval Y as long, _
                                                                          byval nWidth as long, byval nHeight as long, OPTIONAL byval hwndParent as dword, OPTIONAL byval hMenu as dword, OPTIONAL byval hInstance as dword, _
                                                                          OPTIONAL byref lpParam as any) as dword
declare function RegisterWindowMessage lib "USER32.DLL" alias "RegisterWindowMessageA" (lpString as asciiz) as long
declare function EnableWindow lib "USER32.DLL" alias "EnableWindow" (byval hWnd as dword, byval fEnable as long) as long
declare sub      DragAcceptFiles lib "SHELL32.DLL" alias "DragAcceptFiles" (byval hwnd as dword, byval fAccept as long)
declare function SetTimer lib "USER32.DLL" alias "SetTimer" (byval hWnd as dword, byval nIDEvent as long, byval uElapse as dword, byval lpTimerFunc as long) as long
declare function GetMessage lib "USER32.DLL" alias "GetMessageA" (lpMsg as tagMSG, byval hWnd as dword, byval uMsgFilterMin as dword, byval uMsgFilterMax as dword) as long
declare function TranslateMessage lib "USER32.DLL" alias "TranslateMessage" (lpMsg as tagMSG) as long
declare function DispatchMessage lib "USER32.DLL" alias "DispatchMessageA" (lpMsg as tagMSG) as long
declare function KillTimer lib "USER32.DLL" alias "KillTimer" (byval hWnd as dword, byval nIDEvent as long) as long
declare function CloseHandle lib "KERNEL32.DLL" alias "CloseHandle" (byval hObject as dword) as long
declare function GetTickCount lib "KERNEL32.DLL" alias "GetTickCount" () as dword
declare function GetDlgItem lib "USER32.DLL" alias "GetDlgItem" (byval hDlg as dword, byval nIDDlgItem as long) as dword
declare function GetWindowRect lib "USER32.DLL" alias "GetWindowRect" (byval hWnd as dword, lpRect as RECT) as long
declare function MoveWindow lib "USER32.DLL" alias "MoveWindow" (byval hWnd as dword, byval x as long, byval y as long, byval nWidth as long, byval nHeight as long, byval bRepaint as long) as long
declare function SendMessage lib "USER32.DLL" alias "SendMessageA" (byval hWnd as dword, byval dwMsg as dword, byval wParam as dword, byval lParam as long) as long
declare function MonitorFromWindow lib "USER32.DLL" alias "MonitorFromWindow" (byval hwnd as dword, byval dwFlags as dword) as dword
declare function GetMonitorInfo lib "USER32.DLL" alias "GetMonitorInfoA" (byval hMonitor as dword, lpmi as MONITORINFO) as long
declare function DragQueryFile lib "SHELL32.DLL" alias "DragQueryFileA" (byval hDrop as dword, byval uiFile as dword, lpStr as asciiz, byval cch as dword) as dword
declare sub      DragFinish lib "SHELL32.DLL" alias "DragFinish" (byval hDrop as dword)
declare sub      PostQuitMessage lib "USER32.DLL" alias "PostQuitMessage" (byval nExitCode as long)
declare function WaitForSingleObject lib "KERNEL32.DLL" alias "WaitForSingleObject" (byval hHandle as dword, byval dwMilliseconds as dword) as dword
declare function WaitForInputIdle lib "USER32.DLL" alias "WaitForInputIdle" (byval hProcess as dword, byval dwMilliseconds as dword) as dword
declare function ShowWindow lib "USER32.DLL" alias "ShowWindow" (byval hWnd as dword, byval nCmdShow as long) as long
declare function GetSystemMetrics lib "USER32.DLL" alias "GetSystemMetrics" (byval nIndex as long) as long
declare function ScreenToClient lib "USER32.DLL" alias "ScreenToClient" (byval hWnd as dword, lpPoint as POINTAPI) as long
declare function GetParent lib "USER32.DLL" alias "GetParent" (byval hWnd as dword) as long
declare function GetClientRect lib "USER32.DLL" alias "GetClientRect" (byval hwnd as dword, lpRect as RECT) as long
declare function GetWindowLong lib "USER32.DLL" alias "GetWindowLongA" (byval hWnd as dword, byval nIndex as long) as long
declare function DefWindowProc lib "USER32.DLL" alias "DefWindowProcA" (byval hWnd as dword, byval uMsg as dword, byval wParam as dword, byval lParam as long) as long
declare function GetWindow lib "USER32.DLL" alias "GetWindow" (byval hWnd as dword, byval wCmd as dword) as long
declare function SetWindowPos lib "USER32.DLL" alias "SetWindowPos" (byval hWnd as dword, byval hWndInsertAfter as dword, byval x as long, byval y as long, byval cx as long, byval cy as long, byval wFlags as dword) as long
declare function CreateProcess lib "KERNEL32.DLL" alias "CreateProcessA" (lpApplicationName as asciiz, lpCommandLine as asciiz, lpProcessAttributes as SECURITY_ATTRIBUTES, lpThreadAttributes as SECURITY_ATTRIBUTES, _
                 byval bInheritHandles as long, byval dwCreationFlags as dword, lpEnvironment as any, lpCurrentDirectory as asciiz, lpStartupInfo as STARTUPINFO, lpProcessInformation as PROCESS_INFORMATION) as long
declare function GetModuleFileName lib "KERNEL32.DLL" alias "GetModuleFileNameA" (byval hModule as dword, lpFileName as asciiz, byval nSize as dword) as dword
declare function PathCombine lib "SHLWAPI.DLL" alias "PathCombineA" (byref lpszDest as asciiz, byref lpszDir as asciiz, byref lpszFile as asciiz) as long
declare function ShellExecute lib "SHELL32.DLL" alias "ShellExecuteA" (byval hWnd as dword, byref lpOperation as asciiz, byref lpFile as asciiz, byref lpParameters as asciiz, byref lpDirectory as asciiz, byval nShowCmd as long) as dword
declare sub      apiSleep lib "KERNEL32.DLL" alias "Sleep" (byval dwMilliseconds as dword)
