Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - programatrix

#1041

' Keyboard Layout API
Public Const HKL_PREV = 0
Public Const HKL_NEXT = 1

Public Const KLF_ACTIVATE = &H1
Public Const KLF_SUBSTITUTE_OK = &H2
Public Const KLF_UNLOADPREVIOUS = &H4
Public Const KLF_REORDER = &H8

' Size of KeyboardLayoutName (number of characters), including nul terminator
Public Const KL_NAMELENGTH = 9

Declare Function LoadKeyboardLayout Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal flags As Long) As Long
Declare Function ActivateKeyboardLayout Lib "user32" Alias "ActivateKeyboardLayout" (ByVal HKL As Long, ByVal flags As Long) As Long
Declare Function UnloadKeyboardLayout Lib "user32" Alias "UnloadKeyboardLayout" (ByVal HKL As Long) As Long
Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long

' Desktop-specific access flags
Public Const DESKTOP_READOBJECTS = &H1&
Public Const DESKTOP_CREATEWINDOW = &H2&
Public Const DESKTOP_CREATEMENU = &H4&
Public Const DESKTOP_HOOKCONTROL = &H8&
Public Const DESKTOP_JOURNALRECORD = &H10&
Public Const DESKTOP_JOURNALPLAYBACK = &H20&
Public Const DESKTOP_ENUMERATE = &H40&
Public Const DESKTOP_WRITEOBJECTS = &H80&

Declare Function GetThreadDesktop Lib "user32" Alias "GetThreadDesktop" (ByVal dwThread As Long) As Long

' Windowstation-specific access flags
Public Const WINSTA_ENUMDESKTOPS = &H1&
Public Const WINSTA_READATTRIBUTES = &H2&
Public Const WINSTA_ACCESSCLIPBOARD = &H4&
Public Const WINSTA_CREATEDESKTOP = &H8&
Public Const WINSTA_WRITEATTRIBUTES = &H10&
Public Const WINSTA_ACCESSPUBLICATOMS = &H20&
Public Const WINSTA_EXITWINDOWS = &H40&
Public Const WINSTA_ENUMERATE = &H100&
Public Const WINSTA_READSCREEN = &H200&

Declare Function GetProcessWindowStation Lib "user32" Alias "GetProcessWindowStation" () As Long
Declare Function SetUserObjectSecurity Lib "user32" Alias "SetUserObjectSecurity" (ByVal hObj As Long, pSIRequested As Long, pSd As SECURITY_DESCRIPTOR) As Long
Declare Function GetUserObjectSecurity Lib "user32" Alias "GetUserObjectSecurity" (ByVal hObj As Long, pSIRequested As Long, pSd As SECURITY_DESCRIPTOR, ByVal nLength As Long, lpnLengthNeeded As Long) As Long

' Message structure

' Window field offsets for GetWindowLong() and GetWindowWord()
Public Const GWL_WNDPROC = (-4)
Public Const GWL_HINSTANCE = (-6)
Public Const GWL_HWNDPARENT = (-8)
Public Const GWL_STYLE = (-16)
Public Const GWL_EXSTYLE = (-20)
Public Const GWL_USERDATA = (-21)
Public Const GWL_ID = (-12)

' Class field offsets for GetClassLong() and GetClassWord()
Public Const GCL_MENUNAME = (-8)
Public Const GCL_HBRBACKGROUND = (-10)
Public Const GCL_HCURSOR = (-12)
Public Const GCL_HICON = (-14)
Public Const GCL_HMODULE = (-16)
Public Const GCL_CBWNDEXTRA = (-18)
Public Const GCL_CBCLSEXTRA = (-20)
Public Const GCL_WNDPROC = (-24)
Public Const GCL_STYLE = (-26)
Public Const GCW_ATOM = (-32)

' Window Messages
Public Const WM_NULL = &H0
Public Const WM_CREATE = &H1
Public Const WM_DESTROY = &H2
Public Const WM_MOVE = &H3
Public Const WM_SIZE = &H5

Public Const WM_ACTIVATE = &H6
'
'  WM_ACTIVATE state values

Public Const WA_INACTIVE = 0
Public Const WA_ACTIVE = 1
Public Const WA_CLICKACTIVE = 2

Public Const WM_SETFOCUS = &H7
Public Const WM_KILLFOCUS = &H8
Public Const WM_ENABLE = &HA
Public Const WM_SETREDRAW = &HB
Public Const WM_SETTEXT = &HC
Public Const WM_GETTEXT = &HD
Public Const WM_GETTEXTLENGTH = &HE
Public Const WM_PAINT = &HF
Public Const WM_CLOSE = &H10
Public Const WM_QUERYENDSESSION = &H11
Public Const WM_QUIT = &H12
Public Const WM_QUERYOPEN = &H13
Public Const WM_ERASEBKGND = &H14
Public Const WM_SYSCOLORCHANGE = &H15
Public Const WM_ENDSESSION = &H16
Public Const WM_SHOWWINDOW = &H18
Public Const WM_WININICHANGE = &H1A
Public Const WM_DEVMODECHANGE = &H1B
Public Const WM_ACTIVATEAPP = &H1C
Public Const WM_FONTCHANGE = &H1D
Public Const WM_TIMECHANGE = &H1E
Public Const WM_CANCELMODE = &H1F
Public Const WM_SETCURSOR = &H20
Public Const WM_MOUSEACTIVATE = &H21
Public Const WM_CHILDACTIVATE = &H22
Public Const WM_QUEUESYNC = &H23

Public Const WM_GETMINMAXINFO = &H24

Type MINMAXINFO
        ptReserved As POINTAPI
        ptMaxSize As POINTAPI
        ptMaxPosition As POINTAPI
        ptMinTrackSize As POINTAPI
        ptMaxTrackSize As POINTAPI
End Type

Public Const WM_PAINTICON = &H26
Public Const WM_ICONERASEBKGND = &H27
Public Const WM_NEXTDLGCTL = &H28
Public Const WM_SPOOLERSTATUS = &H2A
Public Const WM_DRAWITEM = &H2B
Public Const WM_MEASUREITEM = &H2C
Public Const WM_DELETEITEM = &H2D
Public Const WM_VKEYTOITEM = &H2E
Public Const WM_CHARTOITEM = &H2F
Public Const WM_SETFONT = &H30
Public Const WM_GETFONT = &H31
Public Const WM_SETHOTKEY = &H32
Public Const WM_GETHOTKEY = &H33
Public Const WM_QUERYDRAGICON = &H37
Public Const WM_COMPAREITEM = &H39
Public Const WM_COMPACTING = &H41
Public Const WM_OTHERWINDOWCREATED = &H42               '  no longer suported
Public Const WM_OTHERWINDOWDESTROYED = &H43             '  no longer suported
Public Const WM_COMMNOTIFY = &H44                       '  no longer suported

' notifications passed in low word of lParam on WM_COMMNOTIFY messages
Public Const CN_RECEIVE = &H1
Public Const CN_TRANSMIT = &H2
Public Const CN_EVENT = &H4

Public Const WM_WINDOWPOSCHANGING = &H46
Public Const WM_WINDOWPOSCHANGED = &H47

Public Const WM_POWER = &H48
'
'  wParam for WM_POWER window message and DRV_POWER driver notification

Public Const PWR_OK = 1
Public Const PWR_FAIL = (-1)
Public Const PWR_SUSPENDREQUEST = 1
Public Const PWR_SUSPENDRESUME = 2
Public Const PWR_CRITICALRESUME = 3

Public Const WM_COPYDATA = &H4A
Public Const WM_CANCELJOURNAL = &H4B

Type COPYDATASTRUCT
        dwData As Long
        cbData As Long
        lpData As Long
End Type

Public Const WM_NCCREATE = &H81
Public Const WM_NCDESTROY = &H82
Public Const WM_NCCALCSIZE = &H83
Public Const WM_NCHITTEST = &H84
Public Const WM_NCPAINT = &H85
Public Const WM_NCACTIVATE = &H86
Public Const WM_GETDLGCODE = &H87
Public Const WM_NCMOUSEMOVE = &HA0
Public Const WM_NCLBUTTONDOWN = &HA1
Public Const WM_NCLBUTTONUP = &HA2
Public Const WM_NCLBUTTONDBLCLK = &HA3
Public Const WM_NCRBUTTONDOWN = &HA4
Public Const WM_NCRBUTTONUP = &HA5
Public Const WM_NCRBUTTONDBLCLK = &HA6
Public Const WM_NCMBUTTONDOWN = &HA7
Public Const WM_NCMBUTTONUP = &HA8
Public Const WM_NCMBUTTONDBLCLK = &HA9

Public Const WM_KEYFIRST = &H100
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_CHAR = &H102
Public Const WM_DEADCHAR = &H103
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105
Public Const WM_SYSCHAR = &H106
Public Const WM_SYSDEADCHAR = &H107
Public Const WM_KEYLAST = &H108
Public Const WM_INITDIALOG = &H110
Public Const WM_COMMAND = &H111
Public Const WM_SYSCOMMAND = &H112
Public Const WM_TIMER = &H113
Public Const WM_HSCROLL = &H114
Public Const WM_VSCROLL = &H115
Public Const WM_INITMENU = &H116
Public Const WM_INITMENUPOPUP = &H117
Public Const WM_MENUSELECT = &H11F
Public Const WM_MENUCHAR = &H120
Public Const WM_ENTERIDLE = &H121

Public Const WM_CTLCOLORMSGBOX = &H132
Public Const WM_CTLCOLOREDIT = &H133
Public Const WM_CTLCOLORLISTBOX = &H134
Public Const WM_CTLCOLORBTN = &H135
Public Const WM_CTLCOLORDLG = &H136
Public Const WM_CTLCOLORSCROLLBAR = &H137
Public Const WM_CTLCOLORSTATIC = &H138

Public Const WM_MOUSEFIRST = &H200
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Const WM_MBUTTONDOWN = &H207
Public Const WM_MBUTTONUP = &H208
Public Const WM_MBUTTONDBLCLK = &H209
Public Const WM_MOUSELAST = &H209

Public Const WM_PARENTNOTIFY = &H210
Public Const WM_ENTERMENULOOP = &H211
Public Const WM_EXITMENULOOP = &H212
Public Const WM_MDICREATE = &H220
Public Const WM_MDIDESTROY = &H221
Public Const WM_MDIACTIVATE = &H222
Public Const WM_MDIRESTORE = &H223
Public Const WM_MDINEXT = &H224
Public Const WM_MDIMAXIMIZE = &H225
Public Const WM_MDITILE = &H226
Public Const WM_MDICASCADE = &H227
Public Const WM_MDIICONARRANGE = &H228
Public Const WM_MDIGETACTIVE = &H229
Public Const WM_MDISETMENU = &H230
Public Const WM_DROPFILES = &H233
Public Const WM_MDIREFRESHMENU = &H234


Public Const WM_CUT = &H300
Public Const WM_COPY = &H301
Public Const WM_PASTE = &H302
Public Const WM_CLEAR = &H303
Public Const WM_UNDO = &H304
Public Const WM_RENDERFORMAT = &H305
Public Const WM_RENDERALLFORMATS = &H306
Public Const WM_DESTROYCLIPBOARD = &H307
Public Const WM_DRAWCLIPBOARD = &H308
Public Const WM_PAINTCLIPBOARD = &H309
Public Const WM_VSCROLLCLIPBOARD = &H30A
Public Const WM_SIZECLIPBOARD = &H30B
Public Const WM_ASKCBFORMATNAME = &H30C
Public Const WM_CHANGECBCHAIN = &H30D
Public Const WM_HSCROLLCLIPBOARD = &H30E
Public Const WM_QUERYNEWPALETTE = &H30F
Public Const WM_PALETTEISCHANGING = &H310
Public Const WM_PALETTECHANGED = &H311
Public Const WM_HOTKEY = &H312

Public Const WM_PENWINFIRST = &H380
Public Const WM_PENWINLAST = &H38F

' NOTE: All Message Numbers below 0x0400 are RESERVED.

' Private Window Messages Start Here:
Public Const WM_USER = &H400

' WM_SYNCTASK Commands
Public Const ST_BEGINSWP = 0
Public Const ST_ENDSWP = 1

' WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes
Public Const HTERROR = (-2)
Public Const HTTRANSPARENT = (-1)
Public Const HTNOWHERE = 0
Public Const HTCLIENT = 1
Public Const HTCAPTION = 2
Public Const HTSYSMENU = 3
Public Const HTGROWBOX = 4
Public Const HTSIZE = HTGROWBOX
Public Const HTMENU = 5
Public Const HTHSCROLL = 6
Public Const HTVSCROLL = 7
Public Const HTMINBUTTON = 8
Public Const HTMAXBUTTON = 9
Public Const HTLEFT = 10
Public Const HTRIGHT = 11
Public Const HTTOP = 12
Public Const HTTOPLEFT = 13
Public Const HTTOPRIGHT = 14
Public Const HTBOTTOM = 15
Public Const HTBOTTOMLEFT = 16
Public Const HTBOTTOMRIGHT = 17
Public Const HTBORDER = 18
Public Const HTREDUCE = HTMINBUTTON
Public Const HTZOOM = HTMAXBUTTON
Public Const HTSIZEFIRST = HTLEFT
Public Const HTSIZELAST = HTBOTTOMRIGHT

'  SendMessageTimeout values
Public Const SMTO_NORMAL = &H0
Public Const SMTO_BLOCK = &H1
Public Const SMTO_ABORTIFHUNG = &H2

' WM_MOUSEACTIVATE Return Codes
Public Const MA_ACTIVATE = 1
Public Const MA_ACTIVATEANDEAT = 2
Public Const MA_NOACTIVATE = 3
Public Const MA_NOACTIVATEANDEAT = 4

Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long

' WM_SIZE message wParam values
Public Const SIZE_RESTORED = 0
Public Const SIZE_MINIMIZED = 1
Public Const SIZE_MAXIMIZED = 2
Public Const SIZE_MAXSHOW = 3
Public Const SIZE_MAXHIDE = 4

' Obsolete constant names
Public Const SIZENORMAL = SIZE_RESTORED
Public Const SIZEICONIC = SIZE_MINIMIZED
Public Const SIZEFULLSCREEN = SIZE_MAXIMIZED
Public Const SIZEZOOMSHOW = SIZE_MAXSHOW
Public Const SIZEZOOMHIDE = SIZE_MAXHIDE

' WM_WINDOWPOSCHANGING/CHANGED struct pointed to by lParam
Type WINDOWPOS
        hwnd As Long
        hWndInsertAfter As Long
        x As Long
        y As Long
        cx As Long
        cy As Long
        flags As Long
End Type

' WM_NCCALCSIZE return flags
Public Const WVR_ALIGNTOP = &H10
Public Const WVR_ALIGNLEFT = &H20
Public Const WVR_ALIGNBOTTOM = &H40
Public Const WVR_ALIGNRIGHT = &H80
Public Const WVR_HREDRAW = &H100
Public Const WVR_VREDRAW = &H200
Public Const WVR_REDRAW = (WVR_HREDRAW Or WVR_VREDRAW)
Public Const WVR_VALIDRECTS = &H400

' Key State Masks for Mouse Messages
Public Const MK_LBUTTON = &H1
Public Const MK_RBUTTON = &H2
Public Const MK_SHIFT = &H4
Public Const MK_CONTROL = &H8
Public Const MK_MBUTTON = &H10

' Window Styles
Public Const WS_OVERLAPPED = &H0&
Public Const WS_POPUP = &H80000000
Public Const WS_CHILD = &H40000000
Public Const WS_MINIMIZE = &H20000000
Public Const WS_VISIBLE = &H10000000
Public Const WS_DISABLED = &H8000000
Public Const WS_CLIPSIBLINGS = &H4000000
Public Const WS_CLIPCHILDREN = &H2000000
Public Const WS_MAXIMIZE = &H1000000
Public Const WS_CAPTION = &HC00000                  '  WS_BORDER Or WS_DLGFRAME
Public Const WS_BORDER = &H800000
Public Const WS_DLGFRAME = &H400000
Public Const WS_VSCROLL = &H200000
Public Const WS_HSCROLL = &H100000
Public Const WS_SYSMENU = &H80000
Public Const WS_THICKFRAME = &H40000
Public Const WS_GROUP = &H20000
Public Const WS_TABSTOP = &H10000

Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000

Public Const WS_TILED = WS_OVERLAPPED
Public Const WS_ICONIC = WS_MINIMIZE
Public Const WS_SIZEBOX = WS_THICKFRAME
Public Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
Public Const WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW

'
'   Common Window Styles
'  /


Public Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)

Public Const WS_CHILDWINDOW = (WS_CHILD)

' Extended Window Styles
Public Const WS_EX_DLGMODALFRAME = &H1&
Public Const WS_EX_NOPARENTNOTIFY = &H4&
Public Const WS_EX_TOPMOST = &H8&
Public Const WS_EX_ACCEPTFILES = &H10&
Public Const WS_EX_TRANSPARENT = &H20&

' Class styles
Public Const CS_VREDRAW = &H1
Public Const CS_HREDRAW = &H2
Public Const CS_KEYCVTWINDOW = &H4
Public Const CS_DBLCLKS = &H8
Public Const CS_OWNDC = &H20
Public Const CS_CLASSDC = &H40
Public Const CS_PARENTDC = &H80
Public Const CS_NOKEYCVT = &H100
Public Const CS_NOCLOSE = &H200
Public Const CS_SAVEBITS = &H800
Public Const CS_BYTEALIGNCLIENT = &H1000
Public Const CS_BYTEALIGNWINDOW = &H2000
Public Const CS_PUBLICCLASS = &H4000

' Predefined Clipboard Formats
Public Const CF_TEXT = 1
Public Const CF_BITMAP = 2
Public Const CF_METAFILEPICT = 3
Public Const CF_SYLK = 4
Public Const CF_DIF = 5
Public Const CF_TIFF = 6
Public Const CF_OEMTEXT = 7
Public Const CF_DIB = 8
Public Const CF_PALETTE = 9
Public Const CF_PENDATA = 10
Public Const CF_RIFF = 11
Public Const CF_WAVE = 12
Public Const CF_UNICODETEXT = 13
Public Const CF_ENHMETAFILE = 14

Public Const CF_OWNERDISPLAY = &H80
Public Const CF_DSPTEXT = &H81
Public Const CF_DSPBITMAP = &H82
Public Const CF_DSPMETAFILEPICT = &H83
Public Const CF_DSPENHMETAFILE = &H8E

' "Private" formats don't get GlobalFree()'d
Public Const CF_PRIVATEFIRST = &H200
Public Const CF_PRIVATELAST = &H2FF

' "GDIOBJ" formats do get DeleteObject()'d
Public Const CF_GDIOBJFIRST = &H300
Public Const CF_GDIOBJLAST = &H3FF

'  Defines for the fVirt field of the Accelerator table structure.
Public Const FVIRTKEY = True          '  Assumed to be == TRUE
Public Const FNOINVERT = &H2
Public Const FSHIFT = &H4
Public Const FCONTROL = &H8
Public Const FALT = &H10

Type ACCEL
        fVirt As Byte
        key As Integer
        cmd As Integer
End Type

Type PAINTSTRUCT
        hdc As Long
        fErase As Long
        rcPaint As Rect
        fRestore As Long
        fIncUpdate As Long
        rgbReserved As Byte
End Type

Type CREATESTRUCT
        lpCreateParams As Long
        hInstance As Long
        hMenu As Long
        hWndParent As Long
        cy As Long
        cx As Long
        y As Long
        x As Long
        style As Long
        lpszName As String
        lpszClass As String
        ExStyle As Long
End Type

' HCBT_CREATEWND parameters pointed to by lParam
Type CBT_CREATEWND
        lpcs As CREATESTRUCT
        hWndInsertAfter As Long
End Type

Type WINDOWPLACEMENT
        Length As Long
        flags As Long
        showCmd As Long
        ptMinPosition As POINTAPI
        ptMaxPosition As POINTAPI
        rcNormalPosition As Rect
End Type

Public Const WPF_SETMINPOSITION = &H1
Public Const WPF_RESTORETOMAXIMIZED = &H2

' Owner draw control types
Public Const ODT_MENU = 1
Public Const ODT_LISTBOX = 2
Public Const ODT_COMBOBOX = 3
Public Const ODT_BUTTON = 4

' Owner draw actions
Public Const ODA_DRAWENTIRE = &H1
Public Const ODA_SELECT = &H2
Public Const ODA_FOCUS = &H4

' Owner draw state
Public Const ODS_SELECTED = &H1
Public Const ODS_GRAYED = &H2
Public Const ODS_DISABLED = &H4
Public Const ODS_CHECKED = &H8
Public Const ODS_FOCUS = &H10

' MEASUREITEMSTRUCT for ownerdraw
Type MEASUREITEMSTRUCT
        CtlType As Long
        CtlID As Long
        itemID As Long
        itemWidth As Long
        itemHeight As Long
        itemData As Long
End Type

' DRAWITEMSTRUCT for ownerdraw
Type DRAWITEMSTRUCT
        CtlType As Long
        CtlID As Long
        itemID As Long
        itemAction As Long
        itemState As Long
        hwndItem As Long
        hdc As Long
        rcItem As Rect
        itemData As Long
End Type

' DELETEITEMSTRUCT for ownerdraw
Type DELETEITEMSTRUCT
        CtlType As Long
        CtlID As Long
        itemID As Long
        hwndItem As Long
        itemData As Long
End Type

' COMPAREITEMSTRUCT for ownerdraw sorting
Type COMPAREITEMSTRUCT
        CtlType As Long
        CtlID As Long
        hwndItem As Long
        itemID1 As Long
        itemData1 As Long
        itemID2 As Long
        itemData2 As Long
End Type

' Message Function Templates
Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function TranslateMessage Lib "user32" Alias "TranslateMessage" (lpMsg As MSG) As Long
Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As MSG) As Long
Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long

' PeekMessage() Options
Public Const PM_NOREMOVE = &H0
Public Const PM_REMOVE = &H1
Public Const PM_NOYIELD = &H2

Declare Function RegisterHotKey Lib "user32" Alias "RegisterHotKey" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Declare Function UnregisterHotKey Lib "user32" Alias "UnregisterHotKey" (ByVal hwnd As Long, ByVal id As Long) As Long

Public Const MOD_ALT = &H1
Public Const MOD_CONTROL = &H2
Public Const MOD_SHIFT = &H4

Public Const IDHOT_SNAPWINDOW = (-1)    '  SHIFT-PRINTSCRN
Public Const IDHOT_SNAPDESKTOP = (-2)    '  PRINTSCRN

Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_REBOOT = 2
Public Const EWX_FORCE = 4

Public Const READAPI = 0        '  Flags for _lopen
Public Const WRITEAPI = 1
Public Const READ_WRITE = 2
#1042
Type EMRSTRETCHBLT
        pEmr As emr
        rclBounds As RECTL
        xDest As Long
        yDest As Long
        cxDest As Long
        cyDest As Long
        dwRop As Long
        xSrc As Long
        ySrc As Long
        xformSrc As xform
        crBkColorSrc As Long
        iUsageSrc As Long
        offBmiSrc As Long
        cbBmiSrc As Long
        offBitsSrc As Long
        cbBitsSrc As Long
        cxSrc As Long
        cySrc As Long
End Type

Type EMRMASKBLT
        pEmr As emr
        rclBounds As RECTL
        xDest As Long
        yDest As Long
        cxDest As Long
        cyDest As Long
        dwRop As Long
        xSrc2 As Long
        cyDest2 As Long
        dwRop2 As Long
        xSrc As Long
        ySrc As Long
        xformSrc As XFORM
        crBkColorSrc As Long
        iUsageSrc As Long
        offBmiSrc As Long
        cbBmiSrc As Long
        offBitsSrc As Long
        cbBitsSrc As Long
        xMask As Long
        yMask As Long
        iUsageMask As Long
        offBmiMask As Long
        cbBmiMask As Long
        offBitsMask As Long
        cbBitsMask As Long
End Type

Type EMRPLGBLT
        pEmr As emr
        rclBounds As RECTL
        aptlDest(3) As POINTL
        xSrc As Long
        ySrc As Long
        cxSrc As Long
        cySrc As Long
        xformSrc As XFORM
        crBkColorSrc As Long
        iUsageSrc As Long
        offBmiSrc As Long
        cbBmiSrc As Long
        offBitsSrc As Long
        cbBitsSrc As Long
        xMask As Long
        yMask As Long
        iUsageMask As Long
        offBmiMask As Long
        cbBmiMask As Long
        offBitsMask As Long
        cbBitsMask As Long
End Type

Type EMRSETDIBITSTODEVICE
        pEmr As emr
        rclBounds As RECTL
        xDest As Long
        yDest As Long
        xSrc As Long
        ySrc As Long
        cxSrc As Long
        cySrc As Long
        offBmiSrc As Long
        cbBmiSrc As Long
        offBitsSrc As Long
        cbBitsSrc As Long
        iUsageSrc As Long
        iStartScan As Long
        cScans As Long
End Type

Type EMRSTRETCHDIBITS
        pEmr As emr
        rclBounds As RECTL
        xDest As Long
        yDest As Long
        xSrc As Long
        ySrc As Long
        cxSrc As Long
        cySrc As Long
        offBmiSrc As Long
        cbBmiSrc As Long
        offBitsSrc As Long
        cbBitsSrc As Long
        iUsageSrc As Long
        dwRop As Long
        cxDest As Long
        cyDest As Long
End Type

Type EMREXTCREATEFONTINDIRECT
        pEmr As emr
        ihFont As Long
        elfw As EXTLOGFONT
End Type

Type EMRCREATEPALETTE
        pEmr As emr
        ihPal As Long
        lgpl As LOGPALETTE
End Type

Type EMRCREATEPEN
        pEmr As emr
        ihPen As Long
        lopn As LOGPEN
End Type

Type EMREXTCREATEPEN
        pEmr As emr
        ihPen As Long
        offBmi As Long
        cbBmi As Long
        offBits As Long
        cbBits As Long
        elp As EXTLOGPEN
End Type

Type EMRCREATEBRUSHINDIRECT
        pEmr As emr
        ihBrush As Long
        lb As LOGBRUSH
End Type

Type EMRCREATEMONOBRUSH
        pEmr As emr
        ihBrush As Long
        iUsage As Long
        offBmi As Long
        cbBmi As Long
        offBits As Long
        cbBits As Long
End Type

Type EMRCREATEDIBPATTERNBRUSHPT
        pEmr As emr
        ihBursh As Long
        iUsage As Long
        offBmi As Long
        cbBmi As Long
        offBits As Long
        cbBits As Long
End Type

' new wingdi
' *************************************************************************
' *                                                                         *
' * wingdi.h -- GDI procedure declarations, constant definitions and macros *
' *                                                                         *
' * Copyright (c) 1985-1995, Microsoft Corp. All rights reserved.           *
' *                                                                         *
' **************************************************************************/

'  StretchBlt() Modes
Public Const STRETCH_ANDSCANS = 1
Public Const STRETCH_ORSCANS = 2
Public Const STRETCH_DELETESCANS = 3
Public Const STRETCH_HALFTONE = 4

Type BITMAPV4HEADER
        bV4Size As Long
        bV4Width As Long
        bV4Height As Long
        bV4Planes As Integer
        bV4BitCount As Integer
        bV4V4Compression As Long
        bV4SizeImage As Long
        bV4XPelsPerMeter As Long
        bV4YPelsPerMeter As Long
        bV4ClrUsed As Long
        bV4ClrImportant As Long
        bV4RedMask As Long
        bV4GreenMask As Long
        bV4BlueMask As Long
        bV4AlphaMask As Long
        bV4CSType As Long
        bV4Endpoints As Long
        bV4GammaRed As Long
        bV4GammaGreen As Long
        bV4GammaBlue As Long
End Type

Type FONTSIGNATURE
        fsUsb(4) As Long
        fsCsb(2) As Long
End Type

Type CHARSETINFO
        ciCharset As Long
        ciACP As Long
        fs As FONTSIGNATURE
End Type

Public Const TCI_SRCCHARSET = 1
Public Const TCI_SRCCODEPAGE = 2
Public Const TCI_SRCFONTSIG = 3

Type LOCALESIGNATURE
        lsUsb(4) As Long
        lsCsbDefault(2) As Long
        lsCsbSupported(2) As Long
End Type

Type NEWTEXTMETRICEX
        ntmTm As NEWTEXTMETRIC
        ntmFontSig As FONTSIGNATURE
End Type

Type ENUMLOGFONTEX
        elfLogFont As LOGFONT
        elfFullName(LF_FULLFACESIZE) As Byte
        elfStyle(LF_FACESIZE) As Byte
        elfScript(LF_FACESIZE) As Byte
End Type

Public Const MONO_FONT = 8
Public Const JOHAB_CHARSET = 130
Public Const HEBREW_CHARSET = 177
Public Const ARABIC_CHARSET = 178
Public Const GREEK_CHARSET = 161
Public Const TURKISH_CHARSET = 162
Public Const THAI_CHARSET = 222
Public Const EASTEUROPE_CHARSET = 238
Public Const RUSSIAN_CHARSET = 204

Public Const MAC_CHARSET = 77
Public Const BALTIC_CHARSET = 186

Public Const FS_LATIN1 = &H1&
Public Const FS_LATIN2 = &H2&
Public Const FS_CYRILLIC = &H4&
Public Const FS_GREEK = &H8&
Public Const FS_TURKISH = &H10&
Public Const FS_HEBREW = &H20&
Public Const FS_ARABIC = &H40&
Public Const FS_BALTIC = &H80&
Public Const FS_THAI = &H10000
Public Const FS_JISJAPAN = &H20000
Public Const FS_CHINESESIMP = &H40000
Public Const FS_WANSUNG = &H80000
Public Const FS_CHINESETRAD = &H100000
Public Const FS_JOHAB = &H200000
Public Const FS_SYMBOL = &H80000000
Public Const DEFAULT_GUI_FONT = 17
'  current version of specification
Public Const DM_RESERVED1 = &H800000
Public Const DM_RESERVED2 = &H1000000
Public Const DM_ICMMETHOD = &H2000000
Public Const DM_ICMINTENT = &H4000000
Public Const DM_MEDIATYPE = &H8000000
Public Const DM_DITHERTYPE = &H10000000
Public Const DMPAPER_ISO_B4 = 42                '  B4 (ISO) 250 x 353 mm
Public Const DMPAPER_JAPANESE_POSTCARD = 43     '  Japanese Postcard 100 x 148 mm
Public Const DMPAPER_9X11 = 44                  '  9 x 11 in
Public Const DMPAPER_10X11 = 45                 '  10 x 11 in
Public Const DMPAPER_15X11 = 46                 '  15 x 11 in
Public Const DMPAPER_ENV_INVITE = 47            '  Envelope Invite 220 x 220 mm
Public Const DMPAPER_RESERVED_48 = 48           '  RESERVED--DO NOT USE
Public Const DMPAPER_RESERVED_49 = 49           '  RESERVED--DO NOT USE
Public Const DMPAPER_LETTER_EXTRA = 50              '  Letter Extra 9 \275 x 12 in
Public Const DMPAPER_LEGAL_EXTRA = 51               '  Legal Extra 9 \275 x 15 in
Public Const DMPAPER_TABLOID_EXTRA = 52              '  Tabloid Extra 11.69 x 18 in
Public Const DMPAPER_A4_EXTRA = 53                   '  A4 Extra 9.27 x 12.69 in
Public Const DMPAPER_LETTER_TRANSVERSE = 54     '  Letter Transverse 8 \275 x 11 in
Public Const DMPAPER_A4_TRANSVERSE = 55         '  A4 Transverse 210 x 297 mm
Public Const DMPAPER_LETTER_EXTRA_TRANSVERSE = 56 '  Letter Extra Transverse 9\275 x 12 in
Public Const DMPAPER_A_PLUS = 57                '  SuperA/SuperA/A4 227 x 356 mm
Public Const DMPAPER_B_PLUS = 58                '  SuperB/SuperB/A3 305 x 487 mm
Public Const DMPAPER_LETTER_PLUS = 59           '  Letter Plus 8.5 x 12.69 in
Public Const DMPAPER_A4_PLUS = 60               '  A4 Plus 210 x 330 mm
Public Const DMPAPER_A5_TRANSVERSE = 61         '  A5 Transverse 148 x 210 mm
Public Const DMPAPER_B5_TRANSVERSE = 62         '  B5 (JIS) Transverse 182 x 257 mm
Public Const DMPAPER_A3_EXTRA = 63              '  A3 Extra 322 x 445 mm
Public Const DMPAPER_A5_EXTRA = 64              '  A5 Extra 174 x 235 mm
Public Const DMPAPER_B5_EXTRA = 65              '  B5 (ISO) Extra 201 x 276 mm
Public Const DMPAPER_A2 = 66                    '  A2 420 x 594 mm
Public Const DMPAPER_A3_TRANSVERSE = 67         '  A3 Transverse 297 x 420 mm
Public Const DMPAPER_A3_EXTRA_TRANSVERSE = 68   '  A3 Extra Transverse 322 x 445 mm
Public Const DMTT_DOWNLOAD_OUTLINE = 4 '  download TT fonts as outline soft fonts

'  ICM methods
Public Const DMICMMETHOD_NONE = 1       '  ICM disabled
Public Const DMICMMETHOD_SYSTEM = 2     '  ICM handled by system
Public Const DMICMMETHOD_DRIVER = 3     '  ICM handled by driver
Public Const DMICMMETHOD_DEVICE = 4     '  ICM handled by device
Public Const DMICMMETHOD_USER = 256     '  Device-specific methods start here

'  ICM Intents
Public Const DMICM_SATURATE = 1         '  Maximize color saturation
Public Const DMICM_CONTRAST = 2         '  Maximize color contrast
Public Const DMICM_COLORMETRIC = 3      '  Use specific color metric
Public Const DMICM_USER = 256           '  Device-specific intents start here

'  Media types
Public Const DMMEDIA_STANDARD = 1         '  Standard paper
Public Const DMMEDIA_GLOSSY = 2           '  Glossy paper
Public Const DMMEDIA_TRANSPARENCY = 3     '  Transparency

Public Const DMMEDIA_USER = 256           '  Device-specific media start here

'  Dither types
Public Const DMDITHER_NONE = 1          '  No dithering
Public Const DMDITHER_COARSE = 2        '  Dither with a coarse brush
Public Const DMDITHER_FINE = 3          '  Dither with a fine brush
Public Const DMDITHER_LINEART = 4       '  LineArt dithering
Public Const DMDITHER_GRAYSCALE = 5     '  Device does grayscaling
Public Const DMDITHER_USER = 256        '  Device-specific dithers start here
Public Const GGO_GRAY2_BITMAP = 4
Public Const GGO_GRAY4_BITMAP = 5
Public Const GGO_GRAY8_BITMAP = 6
Public Const GGO_GLYPH_INDEX = &H80
Public Const GCP_DBCS = &H1
Public Const GCP_REORDER = &H2
Public Const GCP_USEKERNING = &H8
Public Const GCP_GLYPHSHAPE = &H10
Public Const GCP_LIGATE = &H20
Public Const GCP_DIACRITIC = &H100
Public Const GCP_KASHIDA = &H400
Public Const GCP_ERROR = &H8000
Public Const FLI_MASK = &H103B
Public Const GCP_JUSTIFY = &H10000
Public Const GCP_NODIACRITICS = &H20000
Public Const FLI_GLYPHS = &H40000
Public Const GCP_CLASSIN = &H80000
Public Const GCP_MAXEXTENT = &H100000
Public Const GCP_JUSTIFYIN = &H200000
Public Const GCP_DISPLAYZWG = &H400000
Public Const GCP_SYMSWAPOFF = &H800000
Public Const GCP_NUMERICOVERRIDE = &H1000000
Public Const GCP_NEUTRALOVERRIDE = &H2000000
Public Const GCP_NUMERICSLATIN = &H4000000
Public Const GCP_NUMERICSLOCAL = &H8000000
Public Const GCPCLASS_LATIN = 1
Public Const GCPCLASS_HEBREW = 2
Public Const GCPCLASS_ARABIC = 2
Public Const GCPCLASS_NEUTRAL = 3
Public Const GCPCLASS_LOCALNUMBER = 4
Public Const GCPCLASS_LATINNUMBER = 5
Public Const GCPCLASS_LATINNUMERICTERMINATOR = 6
Public Const GCPCLASS_LATINNUMERICSEPARATOR = 7
Public Const GCPCLASS_NUMERICSEPARATOR = 8
Public Const GCPCLASS_PREBOUNDRTL = &H80
Public Const GCPCLASS_PREBOUNDLTR = &H40



Type GCP_RESULTS
        lStructSize As Long
        lpOutString As String
        lpOrder As Long
        lpDX As Long
        lpCaretPos As Long
        lpClass As String
        lpGlyphs As String
        nGlyphs As Long
        nMaxFit As Long
End Type

Public Const DC_BINADJUST = 19
Public Const DC_EMF_COMPLIANT = 20
Public Const DC_DATATYPE_PRODUCED = 21
Public Const DC_COLLATE = 22

Public Const DCTT_DOWNLOAD_OUTLINE = &H8&

'  return values for DC_BINADJUST
Public Const DCBA_FACEUPNONE = &H0
Public Const DCBA_FACEUPCENTER = &H1
Public Const DCBA_FACEUPLEFT = &H2
Public Const DCBA_FACEUPRIGHT = &H3
Public Const DCBA_FACEDOWNNONE = &H100
Public Const DCBA_FACEDOWNCENTER = &H101
Public Const DCBA_FACEDOWNLEFT = &H102
Public Const DCBA_FACEDOWNRIGHT = &H103

Declare Function EnumFontFamilies Lib "gdi32" Alias "EnumFontFamiliesA" (ByVal hdc As Long, ByVal lpszFamily As String, ByVal lpEnumFontFamProc As Long, ByVal lParam As Long) As Long
Declare Function EnumFontFamiliesEx Lib "gdi32" Alias "EnumFontFamiliesExA" (ByVal hdc As Long, lpLogFont As LOGFONT, ByVal lpEnumFontProc As Long, ByVal lParam As Long, ByVal dw As Long) As Long
Declare Function GetTextCharset Lib "gdi32" Alias "GetTextCharset" (ByVal hdc As Long) As Long
Declare Function GetTextCharsetInfo Lib "gdi32" Alias "GetTextCharsetInfo" (ByVal hdc As Long, lpSig As FONTSIGNATURE, ByVal dwFlags As Long) As Long

Declare Function TranslateCharsetInfo Lib "gdi32" Alias "TranslateCharsetInfo" (lpSrc As Long, lpcs As CHARSETINFO, ByVal dwFlags As Long) As Long
Declare Function GetFontLanguageInfo Lib "gdi32" Alias "GetFontLanguageInfo" (ByVal hdc As Long) As Long
Declare Function GetCharacterPlacement Lib "gdi32" Alias " GetCharacterPlacementA" (ByVal hdc As Long, ByVal lpsz As String, ByVal n1 As Long, ByVal n2 As Long, lpGcpResults As GCP_RESULTS, ByVal dw As Long) As Long

Public Const ICM_OFF = 1
Public Const ICM_ON = 2
Public Const ICM_QUERY = 3

Type CIEXYZ
ciexyzX As Long
ciexyzY As Long
ciexyzZ As Long
End Type

Type CIEXYZTRIPLE
    ciexyzRed As CIEXYZ
    ciexyzGreen As CIEXYZ
    ciexyBlue As CIEXYZ
End Type

Type LOGCOLORSPACE
    lcsSignature As Long
    lcsVersion As Long
    lcsSize As Long
    lcsCSType As Long
    lcsIntent As Long
    lcsEndPoints As CIEXYZTRIPLE
    lcsGammaRed As Long
    lcsGammaGreen As Long
    lcsGammaBlue As Long
    lcsFileName As String * MAX_PATH
End Type

Declare Function SetICMMode Lib "gdi32" Alias "SetICMMode" (ByVal hdc As Long, ByVal n As Long) As Long
Declare Function CheckColorsInGamut Lib "gdi32" Alias "CheckColorsInGamut" (ByVal hdc As Long, lpv As Any, lpv2 As Any, ByVal dw As Long) As Long
Declare Function GetLogColorSpace Lib "gdi32" Alias "GetLogColorSpaceA" (ByVal hcolorspace As Long, ByVal lplogcolorspace As LOGCOLORSPACE, ByVal dw As Long) As Long
Declare Function GetColorSpace Lib "gdi32" Alias "GetColorSpace" (ByVal hdc As Long) As Long

Declare Function CreateColorSpace Lib "gdi32" Alias "CreateColorSpaceA" (lplogcolorspace As LOGCOLORSPACE) As Long

Declare Function SetColorSpace Lib "gdi32" Alias "SetColorSpace" (ByVal hdc As Long, ByVal hcolorspace As Long) As Long
Declare Function DeleteColorSpace Lib "gdi32" Alias "DeleteColorSpace" (ByVal hcolorspace As Long) As Long
Declare Function GetICMProfile Lib "gdi32" Alias "GetICMProfileA" (ByVal hdc As Long, ByVal dw As Long, ByVal lpStr As String) As Long
Declare Function SetICMProfile Lib "gdi32" Alias "SetICMProfileA" (ByVal hdc As Long, ByVal lpStr As String) As Long
Declare Function GetDeviceGammaRamp Lib "gdi32" Alias "GetDeviceGammaRamp" (ByVal hdc As Long, lpv As Any) As Long
Declare Function SetDeviceGammaRamp Lib "gdi32" Alias "SetDeviceGammaRamp" (ByVal hdc As Long, lpv As Any) As Long
Declare Function ColorMatchToTarget Lib "gdi32" Alias "ColorMatchToTarget" (ByVal hdc As Long, ByVal hdc2 As Long, ByVal dw As Long) As Long

Declare Function EnumICMProfiles Lib "gdi32" Alias "EnumICMProfilesA" (ByVal hdc As Long, ByVal icmEnumProc As Long, ByVal lParam As Long) As Long

Public Const EMR_SETICMMODE = 98
Public Const EMR_CREATECOLORSPACE = 99
Public Const EMR_SETCOLORSPACE = 100
Public Const EMR_DELETECOLORSPACE = 101

Type EMRSELECTCOLORSPACE
        pEmr As emr
        ihCS As Long               '  ColorSpace handle index
End Type

Type EMRCREATECOLORSPACE
        pEmr As emr
        ihCS As Long        '  ColorSpace handle index
        lcs As LOGCOLORSPACE
End Type


' --------------
'  USER Section
' --------------

' Scroll Bar Constants
Public Const SB_HORZ = 0
Public Const SB_VERT = 1
Public Const SB_CTL = 2
Public Const SB_BOTH = 3

' Scroll Bar Commands
Public Const SB_LINEUP = 0
Public Const SB_LINELEFT = 0
Public Const SB_LINEDOWN = 1
Public Const SB_LINERIGHT = 1
Public Const SB_PAGEUP = 2
Public Const SB_PAGELEFT = 2
Public Const SB_PAGEDOWN = 3
Public Const SB_PAGERIGHT = 3
Public Const SB_THUMBPOSITION = 4
Public Const SB_THUMBTRACK = 5
Public Const SB_TOP = 6
Public Const SB_LEFT = 6
Public Const SB_BOTTOM = 7
Public Const SB_RIGHT = 7
Public Const SB_ENDSCROLL = 8

' ShowWindow() Commands
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_NORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Const SW_SHOWDEFAULT = 10
Public Const SW_MAX = 10

' Old ShowWindow() Commands
Public Const HIDE_WINDOW = 0
Public Const SHOW_OPENWINDOW = 1
Public Const SHOW_ICONWINDOW = 2
Public Const SHOW_FULLSCREEN = 3
Public Const SHOW_OPENNOACTIVATE = 4

' Identifiers for the WM_SHOWWINDOW message
Public Const SW_PARENTCLOSING = 1
Public Const SW_OTHERZOOM = 2
Public Const SW_PARENTOPENING = 3
Public Const SW_OTHERUNZOOM = 4

' WM_KEYUP/DOWN/CHAR HIWORD(lParam) flags
Public Const KF_EXTENDED = &H100
Public Const KF_DLGMODE = &H800
Public Const KF_MENUMODE = &H1000
Public Const KF_ALTDOWN = &H2000
Public Const KF_REPEAT = &H4000
Public Const KF_UP = &H8000

' Virtual Keys, Standard Set
Public Const VK_LBUTTON = &H1
Public Const VK_RBUTTON = &H2
Public Const VK_CANCEL = &H3
Public Const VK_MBUTTON = &H4             '  NOT contiguous with L RBUTTON

Public Const VK_BACK = &H8
Public Const VK_TAB = &H9

Public Const VK_CLEAR = &HC
Public Const VK_RETURN = &HD

Public Const VK_SHIFT = &H10
Public Const VK_CONTROL = &H11
Public Const VK_MENU = &H12
Public Const VK_PAUSE = &H13
Public Const VK_CAPITAL = &H14

Public Const VK_ESCAPE = &H1B

Public Const VK_SPACE = &H20
Public Const VK_PRIOR = &H21
Public Const VK_NEXT = &H22
Public Const VK_END = &H23
Public Const VK_HOME = &H24
Public Const VK_LEFT = &H25
Public Const VK_UP = &H26
Public Const VK_RIGHT = &H27
Public Const VK_DOWN = &H28
Public Const VK_SELECT = &H29
Public Const VK_PRINT = &H2A
Public Const VK_EXECUTE = &H2B
Public Const VK_SNAPSHOT = &H2C
Public Const VK_INSERT = &H2D
Public Const VK_DELETE = &H2E
Public Const VK_HELP = &H2F

' VK_A thru VK_Z are the same as their ASCII equivalents: 'A' thru 'Z'
' VK_0 thru VK_9 are the same as their ASCII equivalents: '0' thru '9'

Public Const VK_NUMPAD0 = &H60
Public Const VK_NUMPAD1 = &H61
Public Const VK_NUMPAD2 = &H62
Public Const VK_NUMPAD3 = &H63
Public Const VK_NUMPAD4 = &H64
Public Const VK_NUMPAD5 = &H65
Public Const VK_NUMPAD6 = &H66
Public Const VK_NUMPAD7 = &H67
Public Const VK_NUMPAD8 = &H68
Public Const VK_NUMPAD9 = &H69
Public Const VK_MULTIPLY = &H6A
Public Const VK_ADD = &H6B
Public Const VK_SEPARATOR = &H6C
Public Const VK_SUBTRACT = &H6D
Public Const VK_DECIMAL = &H6E
Public Const VK_DIVIDE = &H6F
Public Const VK_F1 = &H70
Public Const VK_F2 = &H71
Public Const VK_F3 = &H72
Public Const VK_F4 = &H73
Public Const VK_F5 = &H74
Public Const VK_F6 = &H75
Public Const VK_F7 = &H76
Public Const VK_F8 = &H77
Public Const VK_F9 = &H78
Public Const VK_F10 = &H79
Public Const VK_F11 = &H7A
Public Const VK_F12 = &H7B
Public Const VK_F13 = &H7C
Public Const VK_F14 = &H7D
Public Const VK_F15 = &H7E
Public Const VK_F16 = &H7F
Public Const VK_F17 = &H80
Public Const VK_F18 = &H81
Public Const VK_F19 = &H82
Public Const VK_F20 = &H83
Public Const VK_F21 = &H84
Public Const VK_F22 = &H85
Public Const VK_F23 = &H86
Public Const VK_F24 = &H87

Public Const VK_NUMLOCK = &H90
Public Const VK_SCROLL = &H91

'
'   VK_L VK_R - left and right Alt, Ctrl and Shift virtual keys.
'   Used only as parameters to GetAsyncKeyState() and GetKeyState().
'   No other API or message will distinguish left and right keys in this way.
'  /
Public Const VK_LSHIFT = &HA0
Public Const VK_RSHIFT = &HA1
Public Const VK_LCONTROL = &HA2
Public Const VK_RCONTROL = &HA3
Public Const VK_LMENU = &HA4
Public Const VK_RMENU = &HA5

Public Const VK_ATTN = &HF6
Public Const VK_CRSEL = &HF7
Public Const VK_EXSEL = &HF8
Public Const VK_EREOF = &HF9
Public Const VK_PLAY = &HFA
Public Const VK_ZOOM = &HFB
Public Const VK_NONAME = &HFC
Public Const VK_PA1 = &HFD
Public Const VK_OEM_CLEAR = &HFE

' SetWindowsHook() codes
Public Const WH_MIN = (-1)
Public Const WH_MSGFILTER = (-1)
Public Const WH_JOURNALRECORD = 0
Public Const WH_JOURNALPLAYBACK = 1
Public Const WH_KEYBOARD = 2
Public Const WH_GETMESSAGE = 3
Public Const WH_CALLWNDPROC = 4
Public Const WH_CBT = 5
Public Const WH_SYSMSGFILTER = 6
Public Const WH_MOUSE = 7
Public Const WH_HARDWARE = 8
Public Const WH_DEBUG = 9
Public Const WH_SHELL = 10
Public Const WH_FOREGROUNDIDLE = 11
Public Const WH_MAX = 11

' Hook Codes
Public Const HC_ACTION = 0
Public Const HC_GETNEXT = 1
Public Const HC_SKIP = 2
Public Const HC_NOREMOVE = 3
Public Const HC_NOREM = HC_NOREMOVE
Public Const HC_SYSMODALON = 4
Public Const HC_SYSMODALOFF = 5

' CBT Hook Codes
Public Const HCBT_MOVESIZE = 0
Public Const HCBT_MINMAX = 1
Public Const HCBT_QS = 2
Public Const HCBT_CREATEWND = 3
Public Const HCBT_DESTROYWND = 4
Public Const HCBT_ACTIVATE = 5
Public Const HCBT_CLICKSKIPPED = 6
Public Const HCBT_KEYSKIPPED = 7
Public Const HCBT_SYSCOMMAND = 8
Public Const HCBT_SETFOCUS = 9

' HCBT_ACTIVATE structure pointed to by lParam
Type CBTACTIVATESTRUCT
        fMouse As Long
        hWndActive As Long
End Type

' WH_MSGFILTER Filter Proc Codes
Public Const MSGF_DIALOGBOX = 0
Public Const MSGF_MESSAGEBOX = 1
Public Const MSGF_MENU = 2
Public Const MSGF_MOVE = 3
Public Const MSGF_SIZE = 4
Public Const MSGF_SCROLLBAR = 5
Public Const MSGF_NEXTWINDOW = 6
Public Const MSGF_MAINLOOP = 8
Public Const MSGF_MAX = 8
Public Const MSGF_USER = 4096

Public Const HSHELL_WINDOWCREATED = 1
Public Const HSHELL_WINDOWDESTROYED = 2
Public Const HSHELL_ACTIVATESHELLWINDOW = 3

' Message Structure used in Journaling
Type EVENTMSG
        message As Long
        paramL As Long
        paramH As Long
        time As Long
        hwnd As Long
End Type

Type CWPSTRUCT
        lParam As Long
        wParam As Long
        message As Long
        hwnd As Long
End Type

Type DEBUGHOOKINFO
        hModuleHook As Long
        Reserved As Long
        lParam As Long
        wParam As Long
        code As Long
End Type


Type MOUSEHOOKSTRUCT
        pt As POINTAPI
        hwnd As Long
        wHitTestCode As Long
        dwExtraInfo As Long
End Type
#1043
'  Flags value for COLORADJUSTMENT
Public Const CA_NEGATIVE = &H1
Public Const CA_LOG_FILTER = &H2

'  IlluminantIndex values
Public Const ILLUMINANT_DEVICE_DEFAULT = 0
Public Const ILLUMINANT_A = 1
Public Const ILLUMINANT_B = 2
Public Const ILLUMINANT_C = 3
Public Const ILLUMINANT_D50 = 4
Public Const ILLUMINANT_D55 = 5
Public Const ILLUMINANT_D65 = 6
Public Const ILLUMINANT_D75 = 7
Public Const ILLUMINANT_F2 = 8
Public Const ILLUMINANT_MAX_INDEX = ILLUMINANT_F2

Public Const ILLUMINANT_TUNGSTEN = ILLUMINANT_A
Public Const ILLUMINANT_DAYLIGHT = ILLUMINANT_C
Public Const ILLUMINANT_FLUORESCENT = ILLUMINANT_F2
Public Const ILLUMINANT_NTSC = ILLUMINANT_C

'  Min and max for RedGamma, GreenGamma, BlueGamma
Public Const RGB_GAMMA_MIN = 2500 'words
Public Const RGB_GAMMA_MAX = 65000

'  Min and max for ReferenceBlack and ReferenceWhite
Public Const REFERENCE_WHITE_MIN = 6000 'words
Public Const REFERENCE_WHITE_MAX = 10000
Public Const REFERENCE_BLACK_MIN = 0
Public Const REFERENCE_BLACK_MAX = 4000

'  Min and max for Contrast, Brightness, Colorfulness, RedGreenTint
Public Const COLOR_ADJ_MIN = -100 'shorts
Public Const COLOR_ADJ_MAX = 100

Type COLORADJUSTMENT
        caSize As Integer
        caFlags As Integer
        caIlluminantIndex As Integer
        caRedGamma As Integer
        caGreenGamma As Integer
        caBlueGamma As Integer
        caReferenceBlack As Integer
        caReferenceWhite As Integer
        caContrast As Integer
        caBrightness As Integer
        caColorfulness As Integer
        caRedGreenTint As Integer
End Type

Declare Function SetColorAdjustment Lib "gdi32" Alias "SetColorAdjustment" (ByVal hdc As Long, lpca As COLORADJUSTMENT) As Long
Declare Function GetColorAdjustment Lib "gdi32" Alias "GetColorAdjustment" (ByVal hdc As Long, lpca As COLORADJUSTMENT) As Long
Declare Function CreateHalftonePalette Lib "gdi32" Alias "CreateHalftonePalette" (ByVal hdc As Long) As Long

Type DOCINFO
        cbSize As Long
        lpszDocName As String
        lpszOutput As String
End Type

Declare Function StartDoc Lib "gdi32" Alias "StartDocA" (ByVal hdc As Long, lpdi As DOCINFO) As Long
Declare Function StartPage Lib "gdi32" Alias "StartPage" (ByVal hdc As Long) As Long
Declare Function EndPage Lib "gdi32" Alias "EndPage" (ByVal hdc As Long) As Long
Declare Function EndDoc Lib "gdi32" Alias "EndDoc" (ByVal hdc As Long) As Long
Declare Function AbortDoc Lib "gdi32" Alias "AbortDoc" (ByVal hdc As Long) As Long

Declare Function AbortPath Lib "gdi32" Alias "AbortPath" (ByVal hdc As Long) As Long
Declare Function ArcTo Lib "gdi32" Alias "ArcTo" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
Declare Function BeginPath Lib "gdi32" Alias "BeginPath" (ByVal hdc As Long) As Long
Declare Function CloseFigure Lib "gdi32" Alias "CloseFigure" (ByVal hdc As Long) As Long
Declare Function EndPath Lib "gdi32" Alias "EndPath" (ByVal hdc As Long) As Long
Declare Function FillPath Lib "gdi32" Alias "FillPath" (ByVal hdc As Long) As Long
Declare Function FlattenPath Lib "gdi32" Alias "FlattenPath" (ByVal hdc As Long) As Long
Declare Function GetPath Lib "gdi32" Alias "GetPath" (ByVal hdc As Long, lpPoint As POINTAPI, lpTypes As Byte, ByVal nSize As Long) As Long
Declare Function PathToRegion Lib "gdi32" Alias "PathToRegion" (ByVal hdc As Long) As Long
Declare Function PolyDraw Lib "gdi32" Alias "PolyDraw" (ByVal hdc As Long, lppt As POINTAPI, lpbTypes As Byte, ByVal cCount As Long) As Long
Declare Function SelectClipPath Lib "gdi32" Alias "SelectClipPath" (ByVal hdc As Long, ByVal iMode As Long) As Long
Declare Function SetArcDirection Lib "gdi32" Alias "SetArcDirection" (ByVal hdc As Long, ByVal ArcDirection As Long) As Long
Declare Function SetMiterLimit Lib "gdi32" Alias "SetMiterLimit" (ByVal hdc As Long, ByVal eNewLimit As Double, peOldLimit As Double) As Long
Declare Function StrokeAndFillPath Lib "gdi32" Alias "StrokeAndFillPath" (ByVal hdc As Long) As Long
Declare Function StrokePath Lib "gdi32" Alias "StrokePath" (ByVal hdc As Long) As Long
Declare Function WidenPath Lib "gdi32" Alias "WidenPath" (ByVal hdc As Long) As Long
Declare Function ExtCreatePen Lib "gdi32" Alias "ExtCreatePen" (ByVal dwPenStyle As Long, ByVal dwWidth As Long, lplb As LOGBRUSH, ByVal dwStyleCount As Long, lpStyle As Long) As Long
Declare Function GetMiterLimit Lib "gdi32" Alias "GetMiterLimit" (ByVal hdc As Long, peLimit As Double) As Long
Declare Function GetArcDirection Lib "gdi32" Alias "GetArcDirection" (ByVal hdc As Long) As Long

Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Declare Function MoveToEx Lib "gdi32" Alias "MoveToEx" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal wOptions As Long, lpRect As Rect, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long
Declare Function PolyTextOut Lib "gdi32" Alias "PolyTextOutA" (ByVal hdc As Long, pptxt As POLYTEXT, cStrings As Long) As Long

Declare Function CreatePolygonRgn Lib "gdi32" Alias "CreatePolygonRgn" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Declare Function DPtoLP Lib "gdi32" Alias "DPtoLP" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Declare Function LPtoDP Lib "gdi32" Alias "LPtoDP" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Declare Function Polyline Lib "gdi32" Alias "Polyline" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Declare Function Polygon Lib "gdi32" Alias "Polygon" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long

Declare Function PolyBezier Lib "gdi32" Alias "PolyBezier" (ByVal hdc As Long, lppt As POINTAPI, ByVal cPoints As Long) As Long
Declare Function PolyBezierTo Lib "gdi32" Alias "PolyBezierTo" (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long
Declare Function PolylineTo Lib "gdi32" Alias "PolylineTo" (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long

Declare Function SetViewportExtEx Lib "gdi32" Alias "SetViewportExtEx" (ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, lpSize As SIZE) As Long
Declare Function SetViewportOrgEx Lib "gdi32" Alias "SetViewportOrgEx" (ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, lpPoint As POINTAPI) As Long
Declare Function SetWindowOrgEx Lib "gdi32" Alias "SetWindowOrgEx" (ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, lpPoint As POINTAPI) As Long
Declare Function SetWindowExtEx Lib "gdi32" Alias "SetWindowExtEx" (ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, lpSize As SIZE) As Long

Declare Function OffsetViewportOrgEx Lib "gdi32" Alias "OffsetViewportOrgEx" (ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, lpPoint As POINTAPI) As Long
Declare Function OffsetWindowOrgEx Lib "gdi32" Alias "OffsetWindowOrgEx" (ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, lpPoint As POINTAPI) As Long
Declare Function ScaleWindowExtEx Lib "gdi32" Alias "ScaleWindowExtEx" (ByVal hdc As Long, ByVal nXnum As Long, ByVal nXdenom As Long, ByVal nYnum As Long, ByVal nYdenom As Long, lpSize As SIZE) As Long
Declare Function ScaleViewportExtEx Lib "gdi32" Alias "ScaleViewportExtEx" (ByVal hdc As Long, ByVal nXnum As Long, ByVal nXdenom As Long, ByVal nYnum As Long, ByVal nYdenom As Long, lpSize As SIZE) As Long
Declare Function SetBitmapDimensionEx Lib "gdi32" Alias "SetBitmapDimensionEx" (ByVal hbm As Long, ByVal nX As Long, ByVal nY As Long, lpSize As SIZE) As Long
Declare Function SetBrushOrgEx Lib "gdi32" Alias "SetBrushOrgEx" (ByVal hdc As Long, ByVal nXOrg As Long, ByVal nYOrg As Long, lppt As POINTAPI) As Long

Declare Function GetTextFace Lib "gdi32" Alias "GetTextFaceA" (ByVal hdc As Long, ByVal nCount As Long, ByVal lpFacename As String) As Long

Public Const FONTMAPPER_MAX = 10

Type KERNINGPAIR
        wFirst As Integer
        wSecond As Integer
        iKernAmount As Long
End Type

Declare Function GetKerningPairs Lib "gdi32" Alias "GetKerningPairsA" (ByVal hdc As Long, ByVal cPairs As Long, lpkrnpair As KERNINGPAIR) As Long

Declare Function GetDCOrgEx Lib "gdi32" Alias "GetDCOrgEx" (ByVal hdc As Long, lpPoint As POINTAPI) As Long
Declare Function UnrealizeObject Lib "gdi32" Alias "UnrealizeObject" (ByVal hObject As Long) As Long

Declare Function GdiFlush Lib "gdi32" Alias "GdiFlush" () As Long
Declare Function GdiSetBatchLimit Lib "gdi32" Alias "GdiSetBatchLimit" (ByVal dwLimit As Long) As Long
Declare Function GdiGetBatchLimit Lib "gdi32" Alias "GdiGetBatchLimit" () As Long

' Enhanced metafile constants

Public Const ENHMETA_SIGNATURE = &H464D4520

'  Stock object flag used in the object handle
' index in the enhanced metafile records.
'  E.g. The object handle index (META_STOCK_OBJECT Or BLACK_BRUSH)
'  represents the stock object BLACK_BRUSH.

Public Const ENHMETA_STOCK_OBJECT = &H80000000

'  Enhanced metafile record types.

Public Const EMR_HEADER = 1
Public Const EMR_POLYBEZIER = 2
Public Const EMR_POLYGON = 3
Public Const EMR_POLYLINE = 4
Public Const EMR_POLYBEZIERTO = 5
Public Const EMR_POLYLINETO = 6
Public Const EMR_POLYPOLYLINE = 7
Public Const EMR_POLYPOLYGON = 8
Public Const EMR_SETWINDOWEXTEX = 9
Public Const EMR_SETWINDOWORGEX = 10
Public Const EMR_SETVIEWPORTEXTEX = 11
Public Const EMR_SETVIEWPORTORGEX = 12
Public Const EMR_SETBRUSHORGEX = 13
Public Const EMR_EOF = 14
Public Const EMR_SETPIXELV = 15
Public Const EMR_SETMAPPERFLAGS = 16
Public Const EMR_SETMAPMODE = 17
Public Const EMR_SETBKMODE = 18
Public Const EMR_SETPOLYFILLMODE = 19
Public Const EMR_SETROP2 = 20
Public Const EMR_SETSTRETCHBLTMODE = 21
Public Const EMR_SETTEXTALIGN = 22
Public Const EMR_SETCOLORADJUSTMENT = 23
Public Const EMR_SETTEXTCOLOR = 24
Public Const EMR_SETBKCOLOR = 25
Public Const EMR_OFFSETCLIPRGN = 26
Public Const EMR_MOVETOEX = 27
Public Const EMR_SETMETARGN = 28
Public Const EMR_EXCLUDECLIPRECT = 29
Public Const EMR_INTERSECTCLIPRECT = 30
Public Const EMR_SCALEVIEWPORTEXTEX = 31
Public Const EMR_SCALEWINDOWEXTEX = 32
Public Const EMR_SAVEDC = 33
Public Const EMR_RESTOREDC = 34
Public Const EMR_SETWORLDTRANSFORM = 35
Public Const EMR_MODIFYWORLDTRANSFORM = 36
Public Const EMR_SELECTOBJECT = 37
Public Const EMR_CREATEPEN = 38
Public Const EMR_CREATEBRUSHINDIRECT = 39
Public Const EMR_DELETEOBJECT = 40
Public Const EMR_ANGLEARC = 41
Public Const EMR_ELLIPSE = 42
Public Const EMR_RECTANGLE = 43
Public Const EMR_ROUNDRECT = 44
Public Const EMR_ARC = 45
Public Const EMR_CHORD = 46
Public Const EMR_PIE = 47
Public Const EMR_SELECTPALETTE = 48
Public Const EMR_CREATEPALETTE = 49
Public Const EMR_SETPALETTEENTRIES = 50
Public Const EMR_RESIZEPALETTE = 51
Public Const EMR_REALIZEPALETTE = 52
Public Const EMR_EXTFLOODFILL = 53
Public Const EMR_LINETO = 54
Public Const EMR_ARCTO = 55
Public Const EMR_POLYDRAW = 56
Public Const EMR_SETARCDIRECTION = 57
Public Const EMR_SETMITERLIMIT = 58
Public Const EMR_BEGINPATH = 59
Public Const EMR_ENDPATH = 60
Public Const EMR_CLOSEFIGURE = 61
Public Const EMR_FILLPATH = 62
Public Const EMR_STROKEANDFILLPATH = 63
Public Const EMR_STROKEPATH = 64
Public Const EMR_FLATTENPATH = 65
Public Const EMR_WIDENPATH = 66
Public Const EMR_SELECTCLIPPATH = 67
Public Const EMR_ABORTPATH = 68

Public Const EMR_GDICOMMENT = 70
Public Const EMR_FILLRGN = 71
Public Const EMR_FRAMERGN = 72
Public Const EMR_INVERTRGN = 73
Public Const EMR_PAINTRGN = 74
Public Const EMR_EXTSELECTCLIPRGN = 75
Public Const EMR_BITBLT = 76
Public Const EMR_STRETCHBLT = 77
Public Const EMR_MASKBLT = 78
Public Const EMR_PLGBLT = 79
Public Const EMR_SETDIBITSTODEVICE = 80
Public Const EMR_STRETCHDIBITS = 81
Public Const EMR_EXTCREATEFONTINDIRECTW = 82
Public Const EMR_EXTTEXTOUTA = 83
Public Const EMR_EXTTEXTOUTW = 84
Public Const EMR_POLYBEZIER16 = 85
Public Const EMR_POLYGON16 = 86
Public Const EMR_POLYLINE16 = 87
Public Const EMR_POLYBEZIERTO16 = 88
Public Const EMR_POLYLINETO16 = 89
Public Const EMR_POLYPOLYLINE16 = 90
Public Const EMR_POLYPOLYGON16 = 91
Public Const EMR_POLYDRAW16 = 92
Public Const EMR_CREATEMONOBRUSH = 93
Public Const EMR_CREATEDIBPATTERNBRUSHPT = 94
Public Const EMR_EXTCREATEPEN = 95
Public Const EMR_POLYTEXTOUTA = 96
Public Const EMR_POLYTEXTOUTW = 97

Public Const EMR_MIN = 1
Public Const EMR_MAX = 97

Type emr
        iType As Long
        nSize As Long
End Type

Type emrtext
        ptlReference As POINTL
        nchars As Long
        offString As Long
        fOptions As Long
        rcl As RECTL
        offDx As Long
End Type

Type EMRABORTPATH
        pEmr As emr
End Type

Type EMRBEGINPATH
        pEmr As emr
End Type

Type EMRENDPATH
        pEmr As emr
End Type

Type EMRCLOSEFIGURE
        pEmr As emr
End Type

Type EMRFLATTENPATH
        pEmr As emr
End Type

Type EMRWIDENPATH
        pEmr As emr
End Type

Type EMRSETMETARGN
        pEmr As emr
End Type

Type EMREMRSAVEDC
        pEmr As emr
End Type

Type EMRREALIZEPALETTE
        pEmr As emr
End Type

Type EMRSELECTCLIPPATH
        pEmr As emr
        iMode As Long
End Type

Type EMRSETBKMODE
        pEmr As emr
        iMode As Long
End Type

Type EMRSETMAPMODE
        pEmr As emr
        iMode As Long
End Type

Type EMRSETPOLYFILLMODE
        pEmr As emr
        iMode As Long
End Type

Type EMRSETROP2
        pEmr As emr
        iMode As Long
End Type

Type EMRSETSTRETCHBLTMODE
        pEmr As emr
        iMode As Long
End Type

Type EMRSETTEXTALIGN
        pEmr As emr
        iMode As Long
End Type

Type EMRSETMITERLIMIT
        pEmr As emr
        eMiterLimit As Double
End Type

Type EMRRESTOREDC
        pEmr As emr
        iRelative As Long
End Type

Type EMRSETARCDIRECTION
        pEmr As emr
        iArcDirection As Long
End Type

Type EMRSETMAPPERFLAGS
        pEmr As emr
        dwFlags As Long
End Type

Type EMRSETTEXTCOLOR
        pEmr As emr
        crColor As Long
End Type

Type EMRSETBKCOLOR
        pEmr As emr
        crColor As Long
End Type

Type EMRSELECTOBJECT
        pEmr As emr
        ihObject As Long
End Type

Type EMRDELETEOBJECT
        pEmr As emr
        ihObject As Long
End Type

Type EMRSELECTPALETTE
        pEmr As emr
        ihPal As Long
End Type

Type EMRRESIZEPALETTE
        pEmr As emr
        ihPal As Long
        cEntries As Long
End Type

Type EMRSETPALETTEENTRIES
        pEmr As emr
        ihPal As Long
        iStart As Long
        cEntries As Long
        aPalEntries(1) As PALETTEENTRY
End Type

Type EMRSETCOLORADJUSTMENT
        pEmr As emr
        ColorAdjustment As ColorAdjustment
End Type

Type EMRGDICOMMENT
        pEmr As emr
        cbData As Long
        Data(1) As Integer
End Type

Type EMREOF
        pEmr As emr
        nPalEntries As Long
        offPalEntries As Long
        nSizeLast As Long
End Type

Type EMRLINETO
        pEmr As emr
        ptl As POINTL
End Type

Type EMRMOVETOEX
        pEmr As emr
        ptl As POINTL
End Type

Type EMROFFSETCLIPRGN
        pEmr As emr
        ptlOffset As POINTL
End Type

Type EMRFILLPATH
        pEmr As emr
        rclBounds As RECTL
End Type

Type EMRSTROKEANDFILLPATH
        pEmr As emr
        rclBounds As RECTL
End Type

Type EMRSTROKEPATH
        pEmr As emr
        rclBounds As RECTL
End Type

Type EMREXCLUDECLIPRECT
        pEmr As emr
        rclClip As RECTL
End Type

Type EMRINTERSECTCLIPRECT
        pEmr As emr
        rclClip As RECTL
End Type

Type EMRSETVIEWPORTORGEX
        pEmr As emr
        ptlOrigin As POINTL
End Type

Type EMRSETWINDOWORGEX
        pEmr As emr
        ptlOrigin As POINTL
End Type

Type EMRSETBRUSHORGEX
        pEmr As emr
        ptlOrigin As POINTL
End Type

Type EMRSETVIEWPORTEXTEX
        pEmr As emr
        szlExtent As SIZEL
End Type

Type EMRSETWINDOWEXTEX
        pEmr As emr
        szlExtent As SIZEL
End Type

Type EMRSCALEVIEWPORTEXTEX
        pEmr As emr
        xNum As Long
        xDenom As Long
        yNum As Long
        yDemon As Long
End Type

Type EMRSCALEWINDOWEXTEX
        pEmr As emr
        xNum As Long
        xDenom As Long
        yNum As Long
        yDemon As Long
End Type

Type EMRSETWORLDTRANSFORM
        pEmr As emr
        xform As XFORM
End Type

Type EMRMODIFYWORLDTRANSFORM
        pEmr As emr
        xform As XFORM
        iMode As Long
End Type

Type EMRSETPIXELV
        pEmr As emr
        ptlPixel As POINTL
        crColor As Long
End Type

Type EMREXTFLOODFILL
        pEmr As emr
        ptlStart As POINTL
        crColor As Long
        iMode As Long
End Type

Type EMRELLIPSE
        pEmr As emr
        rclBox As RECTL
End Type

Type EMRRECTANGLE
        pEmr As emr
        rclBox As RECTL
End Type

Type EMRROUNDRECT
        pEmr As emr
        rclBox As RECTL
        szlCorner As SIZEL
End Type

Type EMRARC
        pEmr As emr
        rclBox As RECTL
        ptlStart As POINTL
        ptlEnd As POINTL
End Type

Type EMRARCTO
        pEmr As emr
        rclBox As RECTL
        ptlStart As POINTL
        ptlEnd As POINTL
End Type

Type EMRCHORD
        pEmr As emr
        rclBox As RECTL
        ptlStart As POINTL
        ptlEnd As POINTL
End Type

Type EMRPIE
        pEmr As emr
        rclBox As RECTL
        ptlStart As POINTL
        ptlEnd As POINTL
End Type

Type EMRANGLEARC
        pEmr As emr
        ptlCenter As POINTL
        nRadius As Long
        eStartAngle As Double
        eSweepAngle As Double
End Type

Type EMRPOLYLINE
        pEmr As emr
        rclBounds As RECTL
        cptl As Long
        aptl(1) As POINTL
End Type

Type EMRPOLYBEZIER
        pEmr As emr
        rclBounds As RECTL
        cptl As Long
        aptl(1) As POINTL
End Type

Type EMRPOLYGON
        pEmr As emr
        rclBounds As RECTL
        cptl As Long
        aptl(1) As POINTL
End Type

Type EMRPOLYBEZIERTO
        pEmr As emr
        rclBounds As RECTL
        cptl As Long
        aptl(1) As POINTL
End Type

Type EMRPOLYLINE16
        pEmr As emr
        rclBounds As RECTL
        cpts As Long
        apts(1) As POINTS
End Type

Type EMRPOLYBEZIER16
        pEmr As emr
        rclBounds As RECTL
        cpts As Long
        apts(1) As POINTS
End Type

Type EMRPOLYGON16
        pEmr As emr
        rclBounds As RECTL
        cpts As Long
        apts(1) As POINTS
End Type

Type EMRPLOYBEZIERTO16
        pEmr As emr
        rclBounds As RECTL
        cpts As Long
        apts(1) As POINTS
End Type

Type EMRPOLYLINETO16
        pEmr As emr
        rclBounds As RECTL
        cpts As Long
        apts(1) As POINTS
End Type

Type EMRPOLYDRAW
        pEmr As emr
        rclBounds As RECTL
        cptl As Long
        aptl(1) As POINTL
        abTypes(1) As Integer
End Type

Type EMRPOLYDRAW16
        pEmr As emr
        rclBounds As RECTL
        cpts As Long
        apts(1) As POINTS
        abTypes(1) As Integer
End Type

Type EMRPOLYPOLYLINE
        pEmr As emr
        rclBounds As RECTL
        nPolys As Long
        cptl As Long
        aPolyCounts(1) As Long
        aptl(1) As POINTL
End Type

Type EMRPOLYPOLYGON
        pEmr As emr
        rclBounds As RECTL
        nPolys As Long
        cptl As Long
        aPolyCounts(1) As Long
        aptl(1) As POINTL
End Type

Type EMRPOLYPOLYLINE16
        pEmr As emr
        rclBounds As RECTL
        nPolys As Long
        cpts As Long
        aPolyCounts(1) As Long
        apts(1) As POINTS
End Type

Type EMRPOLYPOLYGON16
        pEmr As emr
        rclBounds As RECTL
        nPolys As Long
        cpts As Long
        aPolyCounts(1) As Long
        apts(1) As POINTS
End Type

Type EMRINVERTRGN
        pEmr As emr
        rclBounds As RECTL
        cbRgnData As Long
        RgnData(1) As Integer
End Type

Type EMRPAINTRGN
        pEmr As emr
        rclBounds As RECTL
        cbRgnData As Long
        RgnData(1) As Integer
End Type

Type EMRFILLRGN
        pEmr As emr
        rclBounds As RECTL
        cbRgnData As Long
        ihBrush As Long
        RgnData(1) As Integer
End Type

Type EMRFRAMERGN
        pEmr As emr
        rclBounds As RECTL
        cbRgnData As Long
        ihBrush As Long
        szlStroke As SIZEL
        RgnData(1) As Integer
End Type

Type EMREXTSELECTCLIPRGN
        pEmr As emr
        cbRgnData As Long
        iMode As Long
        RgnData(1) As Integer
End Type

Type EMREXTTEXTOUT
        pEmr As emr
        rclBounds As RECTL
        iGraphicsMode As Long
        exScale As Double
        eyScale As Double
        emrtext As emrtext
End Type

Type EMRBITBLT
        pEmr As emr
        rclBounds As RECTL
        xDest As Long
        yDest As Long
        cxDest As Long
        cyDest As Long
        dwRop As Long
        xSrc As Long
        ySrc As Long
        xformSrc As xform
        crBkColorSrc As Long
        iUsageSrc As Long
        offBmiSrc As Long
        cbBmiSrc As Long
        offBitsSrc As Long
        cbBitsSrc As Long
End Type
#1044

' current version of specification
Public Const DM_SPECVERSION = &H320

' field selection bits
Public Const DM_ORIENTATION = &H1&
Public Const DM_PAPERSIZE = &H2&
Public Const DM_PAPERLENGTH = &H4&
Public Const DM_PAPERWIDTH = &H8&
Public Const DM_SCALE = &H10&
Public Const DM_COPIES = &H100&
Public Const DM_DEFAULTSOURCE = &H200&
Public Const DM_PRINTQUALITY = &H400&
Public Const DM_COLOR = &H800&
Public Const DM_DUPLEX = &H1000&
Public Const DM_YRESOLUTION = &H2000&
Public Const DM_TTOPTION = &H4000&
Public Const DM_COLLATE As Long = &H8000
Public Const DM_FORMNAME As Long = &H10000

'  orientation selections
Public Const DMORIENT_PORTRAIT = 1
Public Const DMORIENT_LANDSCAPE = 2

'  paper selections
Public Const DMPAPER_LETTER = 1
Public Const DMPAPER_FIRST = DMPAPER_LETTER
               '  Letter 8 1/2 x 11 in
Public Const DMPAPER_LETTERSMALL = 2            '  Letter Small 8 1/2 x 11 in
Public Const DMPAPER_TABLOID = 3                '  Tabloid 11 x 17 in
Public Const DMPAPER_LEDGER = 4                 '  Ledger 17 x 11 in
Public Const DMPAPER_LEGAL = 5                  '  Legal 8 1/2 x 14 in
Public Const DMPAPER_STATEMENT = 6              '  Statement 5 1/2 x 8 1/2 in
Public Const DMPAPER_EXECUTIVE = 7              '  Executive 7 1/4 x 10 1/2 in
Public Const DMPAPER_A3 = 8                     '  A3 297 x 420 mm
Public Const DMPAPER_A4 = 9                     '  A4 210 x 297 mm
Public Const DMPAPER_A4SMALL = 10               '  A4 Small 210 x 297 mm
Public Const DMPAPER_A5 = 11                    '  A5 148 x 210 mm
Public Const DMPAPER_B4 = 12                    '  B4 250 x 354
Public Const DMPAPER_B5 = 13                    '  B5 182 x 257 mm
Public Const DMPAPER_FOLIO = 14                 '  Folio 8 1/2 x 13 in
Public Const DMPAPER_QUARTO = 15                '  Quarto 215 x 275 mm
Public Const DMPAPER_10X14 = 16                 '  10x14 in
Public Const DMPAPER_11X17 = 17                 '  11x17 in
Public Const DMPAPER_NOTE = 18                  '  Note 8 1/2 x 11 in
Public Const DMPAPER_ENV_9 = 19                 '  Envelope #9 3 7/8 x 8 7/8
Public Const DMPAPER_ENV_10 = 20                '  Envelope #10 4 1/8 x 9 1/2
Public Const DMPAPER_ENV_11 = 21                '  Envelope #11 4 1/2 x 10 3/8
Public Const DMPAPER_ENV_12 = 22                '  Envelope #12 4 \276 x 11
Public Const DMPAPER_ENV_14 = 23                '  Envelope #14 5 x 11 1/2
Public Const DMPAPER_CSHEET = 24                '  C size sheet
Public Const DMPAPER_DSHEET = 25                '  D size sheet
Public Const DMPAPER_ESHEET = 26                '  E size sheet
Public Const DMPAPER_ENV_DL = 27                '  Envelope DL 110 x 220mm
Public Const DMPAPER_ENV_C5 = 28                '  Envelope C5 162 x 229 mm
Public Const DMPAPER_ENV_C3 = 29                '  Envelope C3  324 x 458 mm
Public Const DMPAPER_ENV_C4 = 30                '  Envelope C4  229 x 324 mm
Public Const DMPAPER_ENV_C6 = 31                '  Envelope C6  114 x 162 mm
Public Const DMPAPER_ENV_C65 = 32               '  Envelope C65 114 x 229 mm
Public Const DMPAPER_ENV_B4 = 33                '  Envelope B4  250 x 353 mm
Public Const DMPAPER_ENV_B5 = 34                '  Envelope B5  176 x 250 mm
Public Const DMPAPER_ENV_B6 = 35                '  Envelope B6  176 x 125 mm
Public Const DMPAPER_ENV_ITALY = 36             '  Envelope 110 x 230 mm
Public Const DMPAPER_ENV_MONARCH = 37           '  Envelope Monarch 3.875 x 7.5 in
Public Const DMPAPER_ENV_PERSONAL = 38          '  6 3/4 Envelope 3 5/8 x 6 1/2 in
Public Const DMPAPER_FANFOLD_US = 39            '  US Std Fanfold 14 7/8 x 11 in
Public Const DMPAPER_FANFOLD_STD_GERMAN = 40    '  German Std Fanfold 8 1/2 x 12 in
Public Const DMPAPER_FANFOLD_LGL_GERMAN = 41    '  German Legal Fanfold 8 1/2 x 13 in

Public Const DMPAPER_LAST = DMPAPER_FANFOLD_LGL_GERMAN

Public Const DMPAPER_USER = 256

'  bin selections
Public Const DMBIN_UPPER = 1
Public Const DMBIN_FIRST = DMBIN_UPPER

Public Const DMBIN_ONLYONE = 1
Public Const DMBIN_LOWER = 2
Public Const DMBIN_MIDDLE = 3
Public Const DMBIN_MANUAL = 4
Public Const DMBIN_ENVELOPE = 5
Public Const DMBIN_ENVMANUAL = 6
Public Const DMBIN_AUTO = 7
Public Const DMBIN_TRACTOR = 8
Public Const DMBIN_SMALLFMT = 9
Public Const DMBIN_LARGEFMT = 10
Public Const DMBIN_LARGECAPACITY = 11
Public Const DMBIN_CASSETTE = 14
Public Const DMBIN_LAST = DMBIN_CASSETTE

Public Const DMBIN_USER = 256               '  device specific bins start here

'  print qualities
Public Const DMRES_DRAFT = (-1)
Public Const DMRES_LOW = (-2)
Public Const DMRES_MEDIUM = (-3)
Public Const DMRES_HIGH = (-4)

'  color enable/disable for color printers
Public Const DMCOLOR_MONOCHROME = 1
Public Const DMCOLOR_COLOR = 2

'  duplex enable
Public Const DMDUP_SIMPLEX = 1
Public Const DMDUP_VERTICAL = 2
Public Const DMDUP_HORIZONTAL = 3

'  TrueType options
Public Const DMTT_BITMAP = 1            '  print TT fonts as graphics
Public Const DMTT_DOWNLOAD = 2          '  download TT fonts as soft fonts
Public Const DMTT_SUBDEV = 3            '  substitute device fonts for TT fonts

'  Collation selections
Public Const DMCOLLATE_FALSE = 0
Public Const DMCOLLATE_TRUE = 1

'  DEVMODE dmDisplayFlags flags

Public Const DM_GRAYSCALE = &H1
Public Const DM_INTERLACED = &H2

'  GetRegionData/ExtCreateRegion

Public Const RDH_RECTANGLES = 1

Type RGNDATAHEADER
        dwSize As Long
        iType As Long
        nCount As Long
        nRgnSize As Long
        rcBound As Rect
End Type

Type RGNDATA
        rdh As RGNDATAHEADER
        Buffer As Byte
End Type

Type ABC
        abcA As Long
        abcB As Long
        abcC As Long
End Type

Type ABCFLOAT
        abcfA As Double
        abcfB As Double
        abcfC As Double
End Type

Type OUTLINETEXTMETRIC
        otmSize As Long
        otmTextMetrics As TEXTMETRIC
        otmFiller As Byte
        otmPanoseNumber As PANOSE
        otmfsSelection As Long
        otmfsType As Long
        otmsCharSlopeRise As Long
        otmsCharSlopeRun As Long
        otmItalicAngle As Long
        otmEMSquare As Long
        otmAscent As Long
        otmDescent As Long
        otmLineGap As Long
        otmsCapEmHeight As Long
        otmsXHeight As Long
        otmrcFontBox As Rect
        otmMacAscent As Long
        otmMacDescent As Long
        otmMacLineGap As Long
        otmusMinimumPPEM As Long
        otmptSubscriptSize As POINTAPI
        otmptSubscriptOffset As POINTAPI
        otmptSuperscriptSize As POINTAPI
        otmptSuperscriptOffset As POINTAPI
        otmsStrikeoutSize As Long
        otmsStrikeoutPosition As Long
        otmsUnderscorePosition As Long
        otmsUnderscoreSize As Long
        otmpFamilyName As String
        otmpFaceName As String
        otmpStyleName As String
        otmpFullName As String
End Type

Type POLYTEXT
        x As Long
        y As Long
        n As Long
        lpStr As String
        uiFlags As Long
        rcl As Rect
        pdx As Long
End Type

Type FIXED
        fract As Integer
        Value As Integer
End Type

Type MAT2
        eM11 As FIXED
        eM12 As FIXED
        eM21 As FIXED
        eM22 As FIXED
End Type

Type GLYPHMETRICS
        gmBlackBoxX As Long
        gmBlackBoxY As Long
        gmptGlyphOrigin As POINTAPI
        gmCellIncX As Integer
        gmCellIncY As Integer
End Type


' GetGlyphOutline constants
Public Const GGO_METRICS = 0
Public Const GGO_BITMAP = 1
Public Const GGO_NATIVE = 2

Public Const TT_POLYGON_TYPE = 24

Public Const TT_PRIM_LINE = 1
Public Const TT_PRIM_QSPLINE = 2

Type POINTFX
        x As FIXED
        y As FIXED
End Type

Type TTPOLYCURVE
        wType As Integer
        cpfx As Integer
        apfx As POINTFX
End Type

Type TTPOLYGONHEADER
        cb As Long
        dwType As Long
        pfxStart As POINTFX
End Type

Type RASTERIZER_STATUS
        nSize As Integer
        wFlags As Integer
        nLanguageID As Integer
End Type

' bits defined in wFlags of RASTERIZER_STATUS
Public Const TT_AVAILABLE = &H1
Public Const TT_ENABLED = &H2

Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long

Declare Function AnimatePalette Lib "gdi32" Alias "AnimatePaletteA" (ByVal hPalette As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteColors As PALETTEENTRY) As Long
Declare Function Arc Lib "gdi32" Alias "Arc" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Declare Function CancelDC Lib "gdi32" Alias "CancelDC" (ByVal hdc As Long) As Long
Declare Function Chord Lib "gdi32" Alias "Chord" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
Declare Function CloseMetaFile Lib "gdi32" Alias "CloseMetaFile" (ByVal hMF As Long) As Long
Declare Function CombineRgn Lib "gdi32" Alias "CombineRgn" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Declare Function CopyMetaFile Lib "gdi32" Alias "CopyMetaFileA" (ByVal hMF As Long, ByVal lpFileName As String) As Long

Declare Function CreateBitmap Lib "gdi32" Alias "CreateBitmap" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
Declare Function CreateBitmapIndirect Lib "gdi32" Alias "CreateBitmapIndirect" (lpBitmap As BITMAP) As Long
Declare Function CreateBrushIndirect Lib "gdi32" Alias "CreateBrushIndirect" (lpLogBrush As LOGBRUSH) As Long
Declare Function CreateCompatibleBitmap Lib "gdi32" Alias "CreateCompatibleBitmap" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function CreateDiscardableBitmap Lib "gdi32" Alias "CreateDiscardableBitmap" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long

Declare Function CreateCompatibleDC Lib "gdi32" Alias "CreateCompatibleDC" (ByVal hdc As Long) As Long
Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE) As Long

Declare Function CreateDIBitmap Lib "gdi32" Alias "CreateDIBitmap" (ByVal hdc As Long, lpInfoHeader As BITMAPINFOHEADER, ByVal dwUsage As Long, lpInitBits As Any, lpInitInfo As BITMAPINFO, ByVal wUsage As Long) As Long
Declare Function CreateDIBPatternBrush Lib "gdi32" Alias "CreateDIBPatternBrush" (ByVal hPackedDIB As Long, ByVal wUsage As Long) As Long
Declare Function CreateDIBPatternBrushPt Lib "gdi32" Alias "CreateDIBPatternBrushPt" (lpPackedDIB As Any, ByVal iUsage As Long) As Long
Declare Function CreateEllipticRgnIndirect Lib "gdi32" Alias "CreateEllipticRgnIndirect" (lpRect As Rect) As Long
Declare Function CreateEllipticRgn Lib "gdi32" Alias "CreateEllipticRgn" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal I As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As Long

Declare Function CreateHatchBrush Lib "gdi32" Alias "CreateHatchBrush" (ByVal nIndex As Long, ByVal crColor As Long) As Long
Declare Function CreateIC Lib "gdi32" Alias "CreateICA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE) As Long

Declare Function CreateMetaFile Lib "gdi32" Alias "CreateMetaFileA" (ByVal lpString As String) As Long

Declare Function CreatePalette Lib "gdi32" Alias "CreatePalette" (lpLogPalette As LOGPALETTE) As Long
Declare Function CreatePen Lib "gdi32" Alias "CreatePen" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Declare Function CreatePenIndirect Lib "gdi32" Alias "CreatePenIndirect" (lpLogPen As LOGPEN) As Long
Declare Function CreateRectRgn Lib "gdi32" Alias "CreateRectRgn" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function CreateRectRgnIndirect Lib "gdi32" Alias "CreateRectRgnIndirect" (lpRect As RECT) As Long
Declare Function CreatePolyPolygonRgn Lib "gdi32" Alias "CreatePolyPolygonRgn" (lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Declare Function CreatePatternBrush Lib "gdi32" Alias "CreatePatternBrush" (ByVal hBitmap As Long) As Long
Declare Function CreateRoundRectRgn Lib "gdi32" Alias "CreateRoundRectRgn" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Declare Function CreateScalableFontResource Lib "gdi32" Alias "CreateScalableFontResourceA" (ByVal fHidden As Long, ByVal lpszResourceFile As String, ByVal lpszFontFile As String, ByVal lpszCurrentPath As String) As Long
Declare Function CreateSolidBrush Lib "gdi32" Alias "CreateSolidBrush" (ByVal crColor As Long) As Long

Declare Function DeleteDC Lib "gdi32" Alias "DeleteDC" (ByVal hdc As Long) As Long
Declare Function DeleteObject Lib "gdi32" Alias "DeleteObject" (ByVal hObject As Long) As Long
Declare Function DeleteMetaFile Lib "gdi32" Alias "DeleteMetaFile" (ByVal hMF As Long) As Long

'  mode selections for the device mode function
Public Const DM_UPDATE = 1
Public Const DM_COPY = 2
Public Const DM_PROMPT = 4
Public Const DM_MODIFY = 8

Public Const DM_IN_BUFFER = DM_MODIFY
Public Const DM_IN_PROMPT = DM_PROMPT
Public Const DM_OUT_BUFFER = DM_COPY
Public Const DM_OUT_DEFAULT = DM_UPDATE

'  device capabilities indices
Public Const DC_FIELDS = 1
Public Const DC_PAPERS = 2
Public Const DC_PAPERSIZE = 3
Public Const DC_MINEXTENT = 4
Public Const DC_MAXEXTENT = 5
Public Const DC_BINS = 6
Public Const DC_DUPLEX = 7
Public Const DC_SIZE = 8
Public Const DC_EXTRA = 9
Public Const DC_VERSION = 10
Public Const DC_DRIVER = 11
Public Const DC_BINNAMES = 12
Public Const DC_ENUMRESOLUTIONS = 13
Public Const DC_FILEDEPENDENCIES = 14
Public Const DC_TRUETYPE = 15
Public Const DC_PAPERNAMES = 16
Public Const DC_ORIENTATION = 17
Public Const DC_COPIES = 18

'  bit fields of the return value (DWORD) for DC_TRUETYPE
Public Const DCTT_BITMAP = &H1&
Public Const DCTT_DOWNLOAD = &H2&
Public Const DCTT_SUBDEV = &H4&

Declare Function DeviceCapabilities Lib "winspool.drv" Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, ByVal lpPort As String, ByVal iIndex As Long, ByVal lpOutput As String, lpDevMode As DEVMODE) As Long

Declare Function Ellipse Lib "gdi32" Alias "Ellipse" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Declare Function EqualRgn Lib "gdi32" Alias "EqualRgn" (ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long) As Long
Declare Function Escape Lib "gdi32" Alias "Escape" (ByVal hdc As Long, ByVal nEscape As Long, ByVal nCount As Long, ByVal lpInData As String, lpOutData As Any) As Long
Declare Function ExtEscape Lib "gdi32" Alias "ExtEscape" (ByVal hdc As Long, ByVal nEscape As Long, ByVal cbInput As Long, ByVal lpszInData As String, ByVal cbOutput As Long, ByVal lpszOutData As String) As Long
Declare Function DrawEscape Lib "gdi32" Alias "DrawEscape" (ByVal hdc As Long, ByVal nEscape As Long, ByVal cbInput As Long, ByVal lpszInData As String) As Long
Declare Function ExcludeClipRect Lib "gdi32" Alias "ExcludeClipRect" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function ExtCreateRegion Lib "gdi32" Alias "ExtCreateRegion" (lpXform As xform, ByVal nCount As Long, lpRgnData As RGNDATA) As Long
Declare Function ExtFloodFill Lib "gdi32" Alias "ExtFloodFill" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
Declare Function FillRgn Lib "gdi32" Alias "FillRgn" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
Declare Function FrameRgn Lib "gdi32" Alias "FrameRgn" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function FloodFill Lib "gdi32" Alias "FloodFill" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function GetROP2 Lib "gdi32" Alias "GetROP2" (ByVal hdc As Long) As Long
Declare Function GetAspectRatioFilterEx Lib "gdi32" Alias "GetAspectRatioFilterEx" (ByVal hdc As Long, lpAspectRatio As SIZE) As Long
Declare Function GetBkColor Lib "gdi32" Alias "GetBkColor" (ByVal hdc As Long) As Long
Declare Function GetBkMode Lib "gdi32" Alias "GetBkMode" (ByVal hdc As Long) As Long
Declare Function GetBitmapBits Lib "gdi32" Alias "GetBitmapBits" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Declare Function GetBitmapDimensionEx Lib "gdi32" Alias "GetBitmapDimensionEx" (ByVal hBitmap As Long, lpDimension As SIZE) As Long
Declare Function GetBoundsRect Lib "gdi32" Alias "GetBoundsRect" (ByVal hdc As Long, lprcBounds As RECT, ByVal flags As Long) As Long

Declare Function GetCharWidth Lib "gdi32" Alias "GetCharWidthA" (ByVal hdc As Long, ByVal wFirstChar As Long, ByVal wLastChar As Long, lpBuffer As Long) As Long
Declare Function GetCharWidth32 Lib "gdi32" Alias "GetCharWidth32A" (ByVal hdc As Long, ByVal iFirstChar As Long, ByVal iLastChar As Long, lpBuffer As Long) As Long
Declare Function GetCharWidthFloat Lib "gdi32" Alias "GetCharWidthFloatA" (ByVal hdc As Long, ByVal iFirstChar As Long, ByVal iLastChar As Long, pxBuffer As Double) As Long

Declare Function GetCharABCWidths Lib "gdi32" Alias "GetCharABCWidthsA" (ByVal hdc As Long, ByVal uFirstChar As Long, ByVal uLastChar As Long, lpabc As ABC) As Long
Declare Function GetCharABCWidthsFloat Lib "gdi32" Alias "GetCharABCWidthsFloatA" (ByVal hdc As Long, ByVal iFirstChar As Long, ByVal iLastChar As Long, lpABCF As ABCFLOAT) As Long

Declare Function GetClipBox Lib "gdi32" Alias "GetClipBox" (ByVal hdc As Long, lpRect As RECT) As Long
Declare Function GetClipRgn Lib "gdi32" Alias "GetClipRgn" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Declare Function GetMetaRgn Lib "gdi32" Alias "GetMetaRgn" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Declare Function GetCurrentObject Lib "gdi32" Alias "GetCurrentObject" (ByVal hdc As Long, ByVal uObjectType As Long) As Long
Declare Function GetCurrentPositionEx Lib "gdi32" Alias "GetCurrentPositionEx" (ByVal hdc As Long, lpPoint As POINTAPI) As Long
Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Declare Function GetDIBits Lib "gdi32" Alias "GetDIBits" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Declare Function GetFontData Lib "gdi32" Alias "GetFontDataA" (ByVal hdc As Long, ByVal dwTable As Long, ByVal dwOffset As Long, lpvBuffer As Any, ByVal cbData As Long) As Long
Declare Function GetGlyphOutline Lib "gdi32" Alias "GetGlyphOutlineA" (ByVal hdc As Long, ByVal uChar As Long, ByVal fuFormat As Long, lpgm As GLYPHMETRICS, ByVal cbBuffer As Long, lpBuffer As Any, lpmat2 As MAT2) As Long
Declare Function GetGraphicsMode Lib "gdi32" Alias "GetGraphicsMode" (ByVal hdc As Long) As Long
Declare Function GetMapMode Lib "gdi32" Alias "GetMapMode" (ByVal hdc As Long) As Long
Declare Function GetMetaFileBitsEx Lib "gdi32" Alias "GetMetaFileBitsEx" (ByVal hMF As Long, ByVal nSize As Long, lpvData As Any) As Long
Declare Function GetMetaFile Lib "gdi32" Alias "GetMetaFileA" (ByVal lpFileName As String) As Long
Declare Function GetNearestColor Lib "gdi32" Alias "GetNearestColor" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function GetNearestPaletteIndex Lib "gdi32" Alias "GetNearestPaletteIndex" (ByVal hPalette As Long, ByVal crColor As Long) As Long
Declare Function GetObjectType Lib "gdi32" Alias "GetObjectType" (ByVal hgdiobj As Long) As Long

Declare Function GetOutlineTextMetrics Lib "gdi32" Alias "GetOutlineTextMetricsA" (ByVal hdc As Long, ByVal cbData As Long, lpotm As OUTLINETEXTMETRIC) As Long

Declare Function GetPaletteEntries Lib "gdi32" Alias "GetPaletteEntries" (ByVal hPalette As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function GetPolyFillMode Lib "gdi32" Alias "GetPolyFillMode" (ByVal hdc As Long) As Long
Declare Function GetRasterizerCaps Lib "gdi32" Alias "GetRasterizerCaps" (lpraststat As RASTERIZER_STATUS, ByVal cb As Long) As Long
Declare Function GetRegionData Lib "gdi32" Alias "GetRegionDataA" (ByVal hRgn As Long, ByVal dwCount As Long, lpRgnData As RgnData) As Long
Declare Function GetRgnBox Lib "gdi32" Alias "GetRgnBox" (ByVal hRgn As Long, lpRect As RECT) As Long
Declare Function GetStockObject Lib "gdi32" Alias "GetStockObject" (ByVal nIndex As Long) As Long
Declare Function GetStretchBltMode Lib "gdi32" Alias "GetStretchBltMode" (ByVal hdc As Long) As Long
Declare Function GetSystemPaletteEntries Lib "gdi32" Alias "GetSystemPaletteEntries" (ByVal hdc As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
Declare Function GetSystemPaletteUse Lib "gdi32" Alias "GetSystemPaletteUse" (ByVal hdc As Long) As Long
Declare Function GetTextCharacterExtra Lib "gdi32" Alias "GetTextCharacterExtraA" (ByVal hdc As Long) As Long
Declare Function GetTextAlign Lib "gdi32" Alias "GetTextAlign" (ByVal hdc As Long) As Long
Declare Function GetTextColor Lib "gdi32" Alias "GetTextColor" (ByVal hdc As Long) As Long

Declare Function GetTextExtentPoint Lib "gdi32" Alias "GetTextExtentPointA" (ByVal hdc As Long, ByVal lpszString As String, ByVal cbString As Long, lpSize As SIZE) As Long
Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As SIZE) As Long
Declare Function GetTextExtentExPoint Lib "gdi32" Alias "GetTextExtentExPointA" (ByVal hdc As Long, ByVal lpszStr As String, ByVal cchString As Long, ByVal nMaxExtent As Long, lpnFit As Long, alpDx As Long, lpSize As SIZE) As Long

Declare Function GetViewportExtEx Lib "gdi32" Alias "GetViewportExtEx" (ByVal hdc As Long, lpSize As SIZE) As Long
Declare Function GetViewportOrgEx Lib "gdi32" Alias "GetViewportOrgEx" (ByVal hdc As Long, lpPoint As POINTAPI) As Long
Declare Function GetWindowExtEx Lib "gdi32" Alias "GetWindowExtEx" (ByVal hdc As Long, lpSize As SIZE) As Long
Declare Function GetWindowOrgEx Lib "gdi32" Alias "GetWindowOrgEx" (ByVal hdc As Long, lpPoint As POINTAPI) As Long

Declare Function IntersectClipRect Lib "gdi32" Alias "IntersectClipRect" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function InvertRgn Lib "gdi32" Alias "InvertRgn" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function MaskBlt Lib "gdi32" Alias "MaskBlt" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long, ByVal dwRop As Long) As Long
Declare Function PlgBlt Lib "gdi32" Alias "PlgBlt" (ByVal hdcDest As Long, lpPoint As POINTAPI, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long) As Long

Declare Function OffsetClipRgn Lib "gdi32" Alias "OffsetClipRgn" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function OffsetRgn Lib "gdi32" Alias "OffsetRgn" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function PatBlt Lib "gdi32" Alias "PatBlt" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
Declare Function Pie Lib "gdi32" Alias "Pie" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
Declare Function PlayMetaFile Lib "gdi32" Alias "PlayMetaFile" (ByVal hdc As Long, ByVal hMF As Long) As Long
Declare Function PaintRgn Lib "gdi32" Alias "PaintRgn" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Declare Function PolyPolygon Lib "gdi32" Alias "PolyPolygon" (ByVal hdc As Long, lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long) As Long
Declare Function PtInRegion Lib "gdi32" Alias "PtInRegion" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function PtVisible Lib "gdi32" Alias "PtVisible" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function RectVisible Lib "gdi32" Alias "RectVisible" (ByVal hdc As Long, lpRect As RECT) As Long
Declare Function RectInRegion Lib "gdi32" Alias "RectInRegion" (ByVal hRgn As Long, lpRect As RECT) As Long
Declare Function Rectangle Lib "gdi32" Alias "Rectangle" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function RestoreDC Lib "gdi32" Alias "RestoreDC" (ByVal hdc As Long, ByVal nSavedDC As Long) As Long
Declare Function ResetDC Lib "gdi32" Alias "ResetDCA" (ByVal hdc As Long, lpInitData As DEVMODE) As Long
Declare Function RealizePalette Lib "gdi32" Alias "RealizePalette" (ByVal hdc As Long) As Long
Declare Function RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String) As Long
Declare Function RoundRect Lib "gdi32" Alias "RoundRect" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Declare Function ResizePalette Lib "gdi32" Alias "ResizePalette" (ByVal hPalette As Long, ByVal nNumEntries As Long) As Long

Declare Function SaveDC Lib "gdi32" Alias "SaveDC" (ByVal hdc As Long) As Long
Declare Function SelectClipRgn Lib "gdi32" Alias "SelectClipRgn" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Declare Function ExtSelectClipRgn Lib "gdi32" Alias "ExtSelectClipRgn" (ByVal hdc As Long, ByVal hRgn As Long, ByVal fnMode As Long) As Long
Declare Function SetMetaRgn Lib "gdi32" Alias "SetMetaRgn" (ByVal hdc As Long) As Long
Declare Function SelectObject Lib "gdi32" Alias "SelectObject" (ByVal hdc As Long, ByVal hObject As Long) As Long
Declare Function SelectPalette Lib "gdi32" Alias "SelectPalette" (ByVal hdc As Long, ByVal hPalette As Long, ByVal bForceBackground As Long) As Long
Declare Function SetBkColor Lib "gdi32" Alias "SetBkColor" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function SetBkMode Lib "gdi32" Alias "SetBkMode" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Declare Function SetBitmapBits Lib "gdi32" Alias "SetBitmapBits" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long

Declare Function SetBoundsRect Lib "gdi32" Alias "SetBoundsRect" (ByVal hdc As Long, lprcBounds As RECT, ByVal flags As Long) As Long
Declare Function SetDIBits Lib "gdi32" Alias "SetDIBits" (ByVal hdc As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Declare Function SetDIBitsToDevice Lib "gdi32" Alias "SetDIBitsToDevice" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, Bits As Any, BitsInfo As BITMAPINFO, ByVal wUsage As Long) As Long
Declare Function SetMapperFlags Lib "gdi32" Alias "SetMapperFlags" (ByVal hdc As Long, ByVal dwFlag As Long) As Long
Declare Function SetGraphicsMode Lib "gdi32" Alias "SetGraphicsMode" (ByVal hdc As Long, ByVal iMode As Long) As Long
Declare Function SetMapMode Lib "gdi32" Alias "SetMapMode" (ByVal hdc As Long, ByVal nMapMode As Long) As Long
Declare Function SetMetaFileBitsEx Lib "gdi32" Alias "SetMetaFileBitsEx" (ByVal nSize As Long, lpData As Byte) As Long
Declare Function SetPaletteEntries Lib "gdi32" Alias "SetPaletteEntries" (ByVal hPalette As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
Declare Function SetPixel Lib "gdi32" Alias "SetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function SetPixelV Lib "gdi32" Alias "SetPixelV" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function SetPolyFillMode Lib "gdi32" Alias "SetPolyFillMode" (ByVal hdc As Long, ByVal nPolyFillMode As Long) As Long
Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Declare Function SetRectRgn Lib "gdi32" Alias "SetRectRgn" (ByVal hRgn As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function StretchDIBits Lib "gdi32" Alias "StretchDIBits" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal wSrcWidth As Long, ByVal wSrcHeight As Long, lpBits As Any, lpBitsInfo As BITMAPINFO, ByVal wUsage As Long, ByVal dwRop As Long) As Long
Declare Function SetROP2 Lib "gdi32" Alias "SetROP2" (ByVal hdc As Long, ByVal nDrawMode As Long) As Long
Declare Function SetStretchBltMode Lib "gdi32" Alias "SetStretchBltMode" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
Declare Function SetSystemPaletteUse Lib "gdi32" Alias "SetSystemPaletteUse" (ByVal hdc As Long, ByVal wUsage As Long) As Long
Declare Function SetTextCharacterExtra Lib "gdi32" Alias "SetTextCharacterExtraA" (ByVal hdc As Long, ByVal nCharExtra As Long) As Long
Declare Function SetTextColor Lib "gdi32" Alias "SetTextColor" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function SetTextAlign Lib "gdi32" Alias "SetTextAlign" (ByVal hdc As Long, ByVal wFlags As Long) As Long
Declare Function SetTextJustification Lib "gdi32" Alias "SetTextJustification" (ByVal hdc As Long, ByVal nBreakExtra As Long, ByVal nBreakCount As Long) As Long
Declare Function UpdateColors Lib "gdi32" Alias "UpdateColors" (ByVal hdc As Long) As Long

Declare Function GetProcAddress Lib "kernel32" Alias "GetProcAddress" (ByVal hModule As Long, ByVal lpProcName As String) As Long

Declare Function PlayMetaFileRecord Lib "gdi32" Alias "PlayMetaFileRecord" (ByVal hdc As Long, lpHandletable As HANDLETABLE, lpMetaRecord As METARECORD, ByVal nHandles As Long) As Long

Declare Function CloseEnhMetaFile Lib "gdi32" Alias "CloseEnhMetaFile" (ByVal hdc As Long) As Long
Declare Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long
Declare Function CreateEnhMetaFile Lib "gdi32" Alias "CreateEnhMetaFileA" (ByVal hdcRef As Long, ByVal lpFileName As String, lpRect As RECT, ByVal lpDescription As String) As Long
Declare Function DeleteEnhMetaFile Lib "gdi32" Alias "DeleteEnhMetaFile" (ByVal hemf As Long) As Long
Declare Function EnumEnhMetaFile Lib "gdi32" Alias "EnumEnhMetaFile" (ByVal hdc As Long, ByVal hemf As Long, ByVal lpEnhMetaFunc As Long, lpData As Any, lpRect As RECT) As Long
Declare Function GetEnhMetaFile Lib "gdi32" Alias "GetEnhMetaFileA" (ByVal lpszMetaFile As String) As Long
Declare Function GetEnhMetaFileBits Lib "gdi32" Alias "GetEnhMetaFileBits" (ByVal hemf As Long, ByVal cbBuffer As Long, lpbBuffer As Byte) As Long
Declare Function GetEnhMetaFileDescription Lib "gdi32" Alias "GetEnhMetaFileDescriptionA" (ByVal hemf As Long, ByVal cchBuffer As Long, ByVal lpszDescription As String) As Long
Declare Function GetEnhMetaFileHeader Lib "gdi32" Alias "GetEnhMetaFileHeader" (ByVal hemf As Long, ByVal cbBuffer As Long, lpemh As ENHMETAHEADER) As Long
Declare Function GetEnhMetaFilePaletteEntries Lib "gdi32" Alias "GetEnhMetaFilePaletteEntries" (ByVal hemf As Long, ByVal cEntries As Long, lppe As PALETTEENTRY) As Long
Declare Function GetWinMetaFileBits Lib "gdi32" Alias "GetWinMetaFileBits" (ByVal hemf As Long, ByVal cbBuffer As Long, lpbBuffer As Byte, ByVal fnMapMode As Long, ByVal hdcRef As Long) As Long
Declare Function PlayEnhMetaFile Lib "gdi32" Alias "PlayEnhMetaFile" (ByVal hdc As Long, ByVal hemf As Long, lpRect As RECT) As Long
Declare Function PlayEnhMetaFileRecord Lib "gdi32" Alias "PlayEnhMetaFileRecord" (ByVal hdc As Long, lpHandletable As HANDLETABLE, lpEnhMetaRecord As ENHMETARECORD, ByVal nHandles As Long) As Long
Declare Function SetEnhMetaFileBits Lib "gdi32" Alias "SetEnhMetaFileBits" (ByVal cbBuffer As Long, lpData As Byte) As Long
Declare Function SetWinMetaFileBits Lib "gdi32" Alias "SetWinMetaFileBits" (ByVal cbBuffer As Long, lpbBuffer As Byte, ByVal hdcRef As Long, lpmfp As METAFILEPICT) As Long
Declare Function GdiComment Lib "gdi32" Alias "GdiComment" (ByVal hdc As Long, ByVal cbSize As Long, lpData As Byte) As Long

Declare Function GetTextMetrics Lib "gdi32" Alias "GetTextMetricsA" (ByVal hdc As Long, lpMetrics As TEXTMETRIC) As Long

Declare Function AngleArc Lib "gdi32" Alias "AngleArc" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dwRadius As Long, ByVal eStartAngle As Double, ByVal eSweepAngle As Double) As Long
Declare Function PolyPolyline Lib "gdi32" Alias "PolyPolyline" (ByVal hdc As Long, lppt As POINTAPI, lpdwPolyPoints As Long, ByVal cCount As Long) As Long
Declare Function GetWorldTransform Lib "gdi32" Alias "GetWorldTransform" (ByVal hdc As Long, lpXform As xform) As Long
Declare Function SetWorldTransform Lib "gdi32" Alias "SetWorldTransform" (ByVal hdc As Long, lpXform As xform) As Long
Declare Function ModifyWorldTransform Lib "gdi32" Alias "ModifyWorldTransform" (ByVal hdc As Long, lpXform As xform, ByVal iMode As Long) As Long
Declare Function CombineTransform Lib "gdi32" Alias "CombineTransform" (lpxformResult As xform, lpxform1 As xform, lpxform2 As xform) As Long
#1045

' Font Families
'
Public Const FF_DONTCARE = 0    '  Don't care or don't know.
Public Const FF_ROMAN = 16      '  Variable stroke width, serifed.

' Times Roman, Century Schoolbook, etc.
Public Const FF_SWISS = 32      '  Variable stroke width, sans-serifed.

' Helvetica, Swiss, etc.
Public Const FF_MODERN = 48     '  Constant stroke width, serifed or sans-serifed.

' Pica, Elite, Courier, etc.
Public Const FF_SCRIPT = 64     '  Cursive, etc.
Public Const FF_DECORATIVE = 80 '  Old English, etc.

' Font Weights
Public Const FW_DONTCARE = 0
Public Const FW_THIN = 100
Public Const FW_EXTRALIGHT = 200
Public Const FW_LIGHT = 300
Public Const FW_NORMAL = 400
Public Const FW_MEDIUM = 500
Public Const FW_SEMIBOLD = 600
Public Const FW_BOLD = 700
Public Const FW_EXTRABOLD = 800
Public Const FW_HEAVY = 900

Public Const FW_ULTRALIGHT = FW_EXTRALIGHT
Public Const FW_REGULAR = FW_NORMAL
Public Const FW_DEMIBOLD = FW_SEMIBOLD
Public Const FW_ULTRABOLD = FW_EXTRABOLD
Public Const FW_BLACK = FW_HEAVY

Public Const PANOSE_COUNT = 10
Public Const PAN_FAMILYTYPE_INDEX = 0
Public Const PAN_SERIFSTYLE_INDEX = 1
Public Const PAN_WEIGHT_INDEX = 2
Public Const PAN_PROPORTION_INDEX = 3
Public Const PAN_CONTRAST_INDEX = 4
Public Const PAN_STROKEVARIATION_INDEX = 5
Public Const PAN_ARMSTYLE_INDEX = 6
Public Const PAN_LETTERFORM_INDEX = 7
Public Const PAN_MIDLINE_INDEX = 8
Public Const PAN_XHEIGHT_INDEX = 9

Public Const PAN_CULTURE_LATIN = 0

Type PANOSE
        ulculture As Long
        bFamilyType As Byte
        bSerifStyle As Byte
        bWeight As Byte
        bProportion As Byte
        bContrast As Byte
        bStrokeVariation As Byte
        bArmStyle As Byte
        bLetterform As Byte
        bMidline As Byte
        bXHeight As Byte
End Type

Public Const PAN_ANY = 0  '  Any
Public Const PAN_NO_FIT = 1  '  No Fit

Public Const PAN_FAMILY_TEXT_DISPLAY = 2  '  Text and Display
Public Const PAN_FAMILY_SCRIPT = 3  '  Script
Public Const PAN_FAMILY_DECORATIVE = 4  '  Decorative
Public Const PAN_FAMILY_PICTORIAL = 5  '  Pictorial

Public Const PAN_SERIF_COVE = 2  '  Cove
Public Const PAN_SERIF_OBTUSE_COVE = 3  '  Obtuse Cove
Public Const PAN_SERIF_SQUARE_COVE = 4  '  Square Cove
Public Const PAN_SERIF_OBTUSE_SQUARE_COVE = 5  '  Obtuse Square Cove
Public Const PAN_SERIF_SQUARE = 6  '  Square
Public Const PAN_SERIF_THIN = 7  '  Thin
Public Const PAN_SERIF_BONE = 8  '  Bone
Public Const PAN_SERIF_EXAGGERATED = 9  '  Exaggerated
Public Const PAN_SERIF_TRIANGLE = 10  '  Triangle
Public Const PAN_SERIF_NORMAL_SANS = 11  '  Normal Sans
Public Const PAN_SERIF_OBTUSE_SANS = 12  '  Obtuse Sans
Public Const PAN_SERIF_PERP_SANS = 13  '  Prep Sans
Public Const PAN_SERIF_FLARED = 14  '  Flared
Public Const PAN_SERIF_ROUNDED = 15  '  Rounded

Public Const PAN_WEIGHT_VERY_LIGHT = 2  '  Very Light
Public Const PAN_WEIGHT_LIGHT = 3  '  Light
Public Const PAN_WEIGHT_THIN = 4  '  Thin
Public Const PAN_WEIGHT_BOOK = 5  '  Book
Public Const PAN_WEIGHT_MEDIUM = 6  '  Medium
Public Const PAN_WEIGHT_DEMI = 7  '  Demi
Public Const PAN_WEIGHT_BOLD = 8  '  Bold
Public Const PAN_WEIGHT_HEAVY = 9  '  Heavy
Public Const PAN_WEIGHT_BLACK = 10  '  Black
Public Const PAN_WEIGHT_NORD = 11  '  Nord

Public Const PAN_PROP_OLD_STYLE = 2  '  Old Style
Public Const PAN_PROP_MODERN = 3  '  Modern
Public Const PAN_PROP_EVEN_WIDTH = 4  '  Even Width
Public Const PAN_PROP_EXPANDED = 5  '  Expanded
Public Const PAN_PROP_CONDENSED = 6  '  Condensed
Public Const PAN_PROP_VERY_EXPANDED = 7  '  Very Expanded
Public Const PAN_PROP_VERY_CONDENSED = 8  '  Very Condensed
Public Const PAN_PROP_MONOSPACED = 9  '  Monospaced

Public Const PAN_CONTRAST_NONE = 2  '  None
Public Const PAN_CONTRAST_VERY_LOW = 3  '  Very Low
Public Const PAN_CONTRAST_LOW = 4  '  Low
Public Const PAN_CONTRAST_MEDIUM_LOW = 5  '  Medium Low
Public Const PAN_CONTRAST_MEDIUM = 6  '  Medium
Public Const PAN_CONTRAST_MEDIUM_HIGH = 7  '  Mediim High
Public Const PAN_CONTRAST_HIGH = 8  '  High
Public Const PAN_CONTRAST_VERY_HIGH = 9  '  Very High

Public Const PAN_STROKE_GRADUAL_DIAG = 2  '  Gradual/Diagonal
Public Const PAN_STROKE_GRADUAL_TRAN = 3  '  Gradual/Transitional
Public Const PAN_STROKE_GRADUAL_VERT = 4  '  Gradual/Vertical
Public Const PAN_STROKE_GRADUAL_HORZ = 5  '  Gradual/Horizontal
Public Const PAN_STROKE_RAPID_VERT = 6  '  Rapid/Vertical
Public Const PAN_STROKE_RAPID_HORZ = 7  '  Rapid/Horizontal
Public Const PAN_STROKE_INSTANT_VERT = 8  '  Instant/Vertical

Public Const PAN_STRAIGHT_ARMS_HORZ = 2  '  Straight Arms/Horizontal
Public Const PAN_STRAIGHT_ARMS_WEDGE = 3  '  Straight Arms/Wedge
Public Const PAN_STRAIGHT_ARMS_VERT = 4  '  Straight Arms/Vertical
Public Const PAN_STRAIGHT_ARMS_SINGLE_SERIF = 5 '  Straight Arms/Single-Serif
Public Const PAN_STRAIGHT_ARMS_DOUBLE_SERIF = 6 '  Straight Arms/Double-Serif
Public Const PAN_BENT_ARMS_HORZ = 7  '  Non-Straight Arms/Horizontal
Public Const PAN_BENT_ARMS_WEDGE = 8  '  Non-Straight Arms/Wedge
Public Const PAN_BENT_ARMS_VERT = 9  '  Non-Straight Arms/Vertical
Public Const PAN_BENT_ARMS_SINGLE_SERIF = 10  '  Non-Straight Arms/Single-Serif
Public Const PAN_BENT_ARMS_DOUBLE_SERIF = 11  '  Non-Straight Arms/Double-Serif

Public Const PAN_LETT_NORMAL_CONTACT = 2  '  Normal/Contact
Public Const PAN_LETT_NORMAL_WEIGHTED = 3  '  Normal/Weighted
Public Const PAN_LETT_NORMAL_BOXED = 4  '  Normal/Boxed
Public Const PAN_LETT_NORMAL_FLATTENED = 5  '  Normal/Flattened
Public Const PAN_LETT_NORMAL_ROUNDED = 6  '  Normal/Rounded
Public Const PAN_LETT_NORMAL_OFF_CENTER = 7  '  Normal/Off Center
Public Const PAN_LETT_NORMAL_SQUARE = 8  '  Normal/Square
Public Const PAN_LETT_OBLIQUE_CONTACT = 9  '  Oblique/Contact
Public Const PAN_LETT_OBLIQUE_WEIGHTED = 10  '  Oblique/Weighted
Public Const PAN_LETT_OBLIQUE_BOXED = 11  '  Oblique/Boxed
Public Const PAN_LETT_OBLIQUE_FLATTENED = 12  '  Oblique/Flattened
Public Const PAN_LETT_OBLIQUE_ROUNDED = 13  '  Oblique/Rounded
Public Const PAN_LETT_OBLIQUE_OFF_CENTER = 14  '  Oblique/Off Center
Public Const PAN_LETT_OBLIQUE_SQUARE = 15  '  Oblique/Square

Public Const PAN_MIDLINE_STANDARD_TRIMMED = 2  '  Standard/Trimmed
Public Const PAN_MIDLINE_STANDARD_POINTED = 3  '  Standard/Pointed
Public Const PAN_MIDLINE_STANDARD_SERIFED = 4  '  Standard/Serifed
Public Const PAN_MIDLINE_HIGH_TRIMMED = 5  '  High/Trimmed
Public Const PAN_MIDLINE_HIGH_POINTED = 6  '  High/Pointed
Public Const PAN_MIDLINE_HIGH_SERIFED = 7  '  High/Serifed
Public Const PAN_MIDLINE_CONSTANT_TRIMMED = 8  '  Constant/Trimmed
Public Const PAN_MIDLINE_CONSTANT_POINTED = 9  '  Constant/Pointed
Public Const PAN_MIDLINE_CONSTANT_SERIFED = 10  '  Constant/Serifed
Public Const PAN_MIDLINE_LOW_TRIMMED = 11  '  Low/Trimmed
Public Const PAN_MIDLINE_LOW_POINTED = 12  '  Low/Pointed
Public Const PAN_MIDLINE_LOW_SERIFED = 13  '  Low/Serifed

Public Const PAN_XHEIGHT_CONSTANT_SMALL = 2  '  Constant/Small
Public Const PAN_XHEIGHT_CONSTANT_STD = 3  '  Constant/Standard
Public Const PAN_XHEIGHT_CONSTANT_LARGE = 4  '  Constant/Large
Public Const PAN_XHEIGHT_DUCKING_SMALL = 5  '  Ducking/Small
Public Const PAN_XHEIGHT_DUCKING_STD = 6  '  Ducking/Standard
Public Const PAN_XHEIGHT_DUCKING_LARGE = 7  '  Ducking/Large

Public Const ELF_VENDOR_SIZE = 4

Type EXTLOGFONT
        elfLogFont  As LOGFONT
        elfFullName(LF_FULLFACESIZE) As Byte
        elfStyle(LF_FACESIZE) As Byte
        elfVersion As Long
        elfStyleSize As Long
        elfMatch As Long
        elfReserved As Long
        elfVendorId(ELF_VENDOR_SIZE) As Byte
        elfCulture As Long
        elfPanose As PANOSE
End Type

Public Const ELF_VERSION = 0
Public Const ELF_CULTURE_LATIN = 0

'  EnumFonts Masks
Public Const RASTER_FONTTYPE = &H1
Public Const DEVICE_FONTTYPE = &H2
Public Const TRUETYPE_FONTTYPE = &H4

' palette entry flags
Public Const PC_RESERVED = &H1  '  palette index used for animation
Public Const PC_EXPLICIT = &H2  '  palette index is explicit to device
Public Const PC_NOCOLLAPSE = &H4        '  do not match color to system palette

' Background Modes
Public Const TRANSPARENT = 1
Public Const OPAQUE = 2
Public Const BKMODE_LAST = 2

'  Graphics Modes
Public Const GM_COMPATIBLE = 1
Public Const GM_ADVANCED = 2
Public Const GM_LAST = 2

'  PolyDraw and GetPath point types
Public Const PT_CLOSEFIGURE = &H1
Public Const PT_LINETO = &H2
Public Const PT_BEZIERTO = &H4
Public Const PT_MOVETO = &H6

'  Mapping Modes
Public Const MM_TEXT = 1
Public Const MM_LOMETRIC = 2
Public Const MM_HIMETRIC = 3
Public Const MM_LOENGLISH = 4
Public Const MM_HIENGLISH = 5
Public Const MM_TWIPS = 6
Public Const MM_ISOTROPIC = 7
Public Const MM_ANISOTROPIC = 8

'  Min and Max Mapping Mode values
Public Const MM_MIN = MM_TEXT
Public Const MM_MAX = MM_ANISOTROPIC
Public Const MM_MAX_FIXEDSCALE = MM_TWIPS

' Coordinate Modes
Public Const ABSOLUTE = 1
Public Const RELATIVE = 2

' Stock Logical Objects
Public Const WHITE_BRUSH = 0
Public Const LTGRAY_BRUSH = 1
Public Const GRAY_BRUSH = 2
Public Const DKGRAY_BRUSH = 3
Public Const BLACK_BRUSH = 4
Public Const NULL_BRUSH = 5
Public Const HOLLOW_BRUSH = NULL_BRUSH
Public Const WHITE_PEN = 6
Public Const BLACK_PEN = 7
Public Const NULL_PEN = 8
Public Const OEM_FIXED_FONT = 10
Public Const ANSI_FIXED_FONT = 11
Public Const ANSI_VAR_FONT = 12
Public Const SYSTEM_FONT = 13
Public Const DEVICE_DEFAULT_FONT = 14
Public Const DEFAULT_PALETTE = 15
Public Const SYSTEM_FIXED_FONT = 16
Public Const STOCK_LAST = 16

Public Const CLR_INVALID = &HFFFF

' Brush Styles
Public Const BS_SOLID = 0
Public Const BS_NULL = 1
Public Const BS_HOLLOW = BS_NULL
Public Const BS_HATCHED = 2
Public Const BS_PATTERN = 3
Public Const BS_INDEXED = 4
Public Const BS_DIBPATTERN = 5
Public Const BS_DIBPATTERNPT = 6
Public Const BS_PATTERN8X8 = 7
Public Const BS_DIBPATTERN8X8 = 8

'  Hatch Styles
Public Const HS_HORIZONTAL = 0              '  -----
Public Const HS_VERTICAL = 1                '  |||||
Public Const HS_FDIAGONAL = 2               '  \\\\\
Public Const HS_BDIAGONAL = 3               '  /////
Public Const HS_CROSS = 4                   '  +++++
Public Const HS_DIAGCROSS = 5               '  xxxxx
Public Const HS_FDIAGONAL1 = 6
Public Const HS_BDIAGONAL1 = 7
Public Const HS_SOLID = 8
Public Const HS_DENSE1 = 9
Public Const HS_DENSE2 = 10
Public Const HS_DENSE3 = 11
Public Const HS_DENSE4 = 12
Public Const HS_DENSE5 = 13
Public Const HS_DENSE6 = 14
Public Const HS_DENSE7 = 15
Public Const HS_DENSE8 = 16
Public Const HS_NOSHADE = 17
Public Const HS_HALFTONE = 18
Public Const HS_SOLIDCLR = 19
Public Const HS_DITHEREDCLR = 20
Public Const HS_SOLIDTEXTCLR = 21
Public Const HS_DITHEREDTEXTCLR = 22
Public Const HS_SOLIDBKCLR = 23
Public Const HS_DITHEREDBKCLR = 24
Public Const HS_API_MAX = 25

'  Pen Styles
Public Const PS_SOLID = 0
Public Const PS_DASH = 1                    '  -------
Public Const PS_DOT = 2                     '  .......
Public Const PS_DASHDOT = 3                 '  _._._._
Public Const PS_DASHDOTDOT = 4              '  _.._.._
Public Const PS_NULL = 5
Public Const PS_INSIDEFRAME = 6
Public Const PS_USERSTYLE = 7
Public Const PS_ALTERNATE = 8
Public Const PS_STYLE_MASK = &HF

Public Const PS_ENDCAP_ROUND = &H0
Public Const PS_ENDCAP_SQUARE = &H100
Public Const PS_ENDCAP_FLAT = &H200
Public Const PS_ENDCAP_MASK = &HF00

Public Const PS_JOIN_ROUND = &H0
Public Const PS_JOIN_BEVEL = &H1000
Public Const PS_JOIN_MITER = &H2000
Public Const PS_JOIN_MASK = &HF000

Public Const PS_COSMETIC = &H0
Public Const PS_GEOMETRIC = &H10000
Public Const PS_TYPE_MASK = &HF0000

Public Const AD_COUNTERCLOCKWISE = 1
Public Const AD_CLOCKWISE = 2

'  Device Parameters for GetDeviceCaps()
Public Const DRIVERVERSION = 0      '  Device driver version
Public Const TECHNOLOGY = 2         '  Device classification
Public Const HORZSIZE = 4           '  Horizontal size in millimeters
Public Const VERTSIZE = 6           '  Vertical size in millimeters
Public Const HORZRES = 8            '  Horizontal width in pixels
Public Const VERTRES = 10           '  Vertical width in pixels
Public Const BITSPIXEL = 12         '  Number of bits per pixel
Public Const PLANES = 14            '  Number of planes
Public Const NUMBRUSHES = 16        '  Number of brushes the device has
Public Const NUMPENS = 18           '  Number of pens the device has
Public Const NUMMARKERS = 20        '  Number of markers the device has
Public Const NUMFONTS = 22          '  Number of fonts the device has
Public Const NUMCOLORS = 24         '  Number of colors the device supports
Public Const PDEVICESIZE = 26       '  Size required for device descriptor
Public Const CURVECAPS = 28         '  Curve capabilities
Public Const LINECAPS = 30          '  Line capabilities
Public Const POLYGONALCAPS = 32     '  Polygonal capabilities
Public Const TEXTCAPS = 34          '  Text capabilities
Public Const CLIPCAPS = 36          '  Clipping capabilities
Public Const RASTERCAPS = 38        '  Bitblt capabilities
Public Const ASPECTX = 40           '  Length of the X leg
Public Const ASPECTY = 42           '  Length of the Y leg
Public Const ASPECTXY = 44          '  Length of the hypotenuse

Public Const LOGPIXELSX = 88        '  Logical pixels/inch in X
Public Const LOGPIXELSY = 90        '  Logical pixels/inch in Y

Public Const SIZEPALETTE = 104      '  Number of entries in physical palette
Public Const NUMRESERVED = 106      '  Number of reserved entries in palette
Public Const COLORRES = 108         '  Actual color resolution

'  Printing related DeviceCaps. These replace the appropriate Escapes
Public Const PHYSICALWIDTH = 110 '  Physical Width in device units
Public Const PHYSICALHEIGHT = 111 '  Physical Height in device units
Public Const PHYSICALOFFSETX = 112 '  Physical Printable Area x margin
Public Const PHYSICALOFFSETY = 113 '  Physical Printable Area y margin
Public Const SCALINGFACTORX = 114 '  Scaling factor x
Public Const SCALINGFACTORY = 115 '  Scaling factor y

'  Device Capability Masks:

'  Device Technologies
Public Const DT_PLOTTER = 0             '  Vector plotter
Public Const DT_RASDISPLAY = 1          '  Raster display
Public Const DT_RASPRINTER = 2          '  Raster printer
Public Const DT_RASCAMERA = 3           '  Raster camera
Public Const DT_CHARSTREAM = 4          '  Character-stream, PLP
Public Const DT_METAFILE = 5            '  Metafile, VDM
Public Const DT_DISPFILE = 6            '  Display-file

'  Curve Capabilities
Public Const CC_NONE = 0                '  Curves not supported
Public Const CC_CIRCLES = 1             '  Can do circles
Public Const CC_PIE = 2                 '  Can do pie wedges
Public Const CC_CHORD = 4               '  Can do chord arcs
Public Const CC_ELLIPSES = 8            '  Can do ellipese
Public Const CC_WIDE = 16               '  Can do wide lines
Public Const CC_STYLED = 32             '  Can do styled lines
Public Const CC_WIDESTYLED = 64         '  Can do wide styled lines
Public Const CC_INTERIORS = 128 '  Can do interiors
Public Const CC_ROUNDRECT = 256 '

'  Line Capabilities
Public Const LC_NONE = 0                '  Lines not supported
Public Const LC_POLYLINE = 2            '  Can do polylines
Public Const LC_MARKER = 4              '  Can do markers
Public Const LC_POLYMARKER = 8          '  Can do polymarkers
Public Const LC_WIDE = 16               '  Can do wide lines
Public Const LC_STYLED = 32             '  Can do styled lines
Public Const LC_WIDESTYLED = 64         '  Can do wide styled lines
Public Const LC_INTERIORS = 128 '  Can do interiors

'  Polygonal Capabilities
Public Const PC_NONE = 0                '  Polygonals not supported
Public Const PC_POLYGON = 1             '  Can do polygons
Public Const PC_RECTANGLE = 2           '  Can do rectangles
Public Const PC_WINDPOLYGON = 4         '  Can do winding polygons
Public Const PC_TRAPEZOID = 4           '  Can do trapezoids
Public Const PC_SCANLINE = 8            '  Can do scanlines
Public Const PC_WIDE = 16               '  Can do wide borders
Public Const PC_STYLED = 32             '  Can do styled borders
Public Const PC_WIDESTYLED = 64         '  Can do wide styled borders
Public Const PC_INTERIORS = 128 '  Can do interiors

'  Polygonal Capabilities
Public Const CP_NONE = 0                '  No clipping of output
Public Const CP_RECTANGLE = 1           '  Output clipped to rects
Public Const CP_REGION = 2              '

'  Text Capabilities
Public Const TC_OP_CHARACTER = &H1              '  Can do OutputPrecision   CHARACTER
Public Const TC_OP_STROKE = &H2                 '  Can do OutputPrecision   STROKE
Public Const TC_CP_STROKE = &H4                 '  Can do ClipPrecision     STROKE
Public Const TC_CR_90 = &H8                     '  Can do CharRotAbility    90
Public Const TC_CR_ANY = &H10                   '  Can do CharRotAbility    ANY
Public Const TC_SF_X_YINDEP = &H20              '  Can do ScaleFreedom      X_YINDEPENDENT
Public Const TC_SA_DOUBLE = &H40                '  Can do ScaleAbility      DOUBLE
Public Const TC_SA_INTEGER = &H80               '  Can do ScaleAbility      INTEGER
Public Const TC_SA_CONTIN = &H100               '  Can do ScaleAbility      CONTINUOUS
Public Const TC_EA_DOUBLE = &H200               '  Can do EmboldenAbility   DOUBLE
Public Const TC_IA_ABLE = &H400                 '  Can do ItalisizeAbility  ABLE
Public Const TC_UA_ABLE = &H800                 '  Can do UnderlineAbility  ABLE
Public Const TC_SO_ABLE = &H1000                '  Can do StrikeOutAbility  ABLE
Public Const TC_RA_ABLE = &H2000                '  Can do RasterFontAble    ABLE
Public Const TC_VA_ABLE = &H4000                '  Can do VectorFontAble    ABLE
Public Const TC_RESERVED = &H8000
Public Const TC_SCROLLBLT = &H10000             '  do text scroll with blt

'  Raster Capabilities
Public Const RC_NONE = 0
Public Const RC_BITBLT = 1                  '  Can do standard BLT.
Public Const RC_BANDING = 2                 '  Device requires banding support
Public Const RC_SCALING = 4                 '  Device requires scaling support
Public Const RC_BITMAP64 = 8                '  Device can support >64K bitmap
Public Const RC_GDI20_OUTPUT = &H10             '  has 2.0 output calls
Public Const RC_GDI20_STATE = &H20
Public Const RC_SAVEBITMAP = &H40
Public Const RC_DI_BITMAP = &H80                '  supports DIB to memory
Public Const RC_PALETTE = &H100                 '  supports a palette
Public Const RC_DIBTODEV = &H200                '  supports DIBitsToDevice
Public Const RC_BIGFONT = &H400                 '  supports >64K fonts
Public Const RC_STRETCHBLT = &H800              '  supports StretchBlt
Public Const RC_FLOODFILL = &H1000              '  supports FloodFill
Public Const RC_STRETCHDIB = &H2000             '  supports StretchDIBits
Public Const RC_OP_DX_OUTPUT = &H4000
Public Const RC_DEVBITS = &H8000

' DIB color table identifiers
Public Const DIB_RGB_COLORS = 0 '  color table in RGBs
Public Const DIB_PAL_COLORS = 1 '  color table in palette indices
Public Const DIB_PAL_INDICES = 2 '  No color table indices into surf palette
Public Const DIB_PAL_PHYSINDICES = 2 '  No color table indices into surf palette
Public Const DIB_PAL_LOGINDICES = 4 '  No color table indices into DC palette

' constants for Get/SetSystemPaletteUse()
Public Const SYSPAL_ERROR = 0
Public Const SYSPAL_STATIC = 1
Public Const SYSPAL_NOSTATIC = 2

' constants for CreateDIBitmap
Public Const CBM_CREATEDIB = &H2      '  create DIB bitmap
Public Const CBM_INIT = &H4           '  initialize bitmap

' ExtFloodFill style flags
Public Const FLOODFILLBORDER = 0
Public Const FLOODFILLSURFACE = 1

'  size of a device name string
Public Const CCHDEVICENAME = 32

'  size of a form name string
Public Const CCHFORMNAME = 32

Type DEVMODE
        dmDeviceName As String * CCHDEVICENAME
        dmSpecVersion As Integer
        dmDriverVersion As Integer
        dmSize As Integer
        dmDriverExtra As Integer
        dmFields As Long
        dmOrientation As Integer
        dmPaperSize As Integer
        dmPaperLength As Integer
        dmPaperWidth As Integer
        dmScale As Integer
        dmCopies As Integer
        dmDefaultSource As Integer
        dmPrintQuality As Integer
        dmColor As Integer
        dmDuplex As Integer
        dmYResolution As Integer
        dmTTOption As Integer
        dmCollate As Integer
        dmFormName As String * CCHFORMNAME
        dmUnusedPadding As Integer
        dmBitsPerPel As Integer
        dmPelsWidth As Long
        dmPelsHeight As Long
        dmDisplayFlags As Long
        dmDisplayFrequency As Long
End Type
#1046

Public Const ASPECT_FILTERING = &H1

Public Const DCB_RESET = &H1
Public Const DCB_ACCUMULATE = &H2
Public Const DCB_DIRTY = DCB_ACCUMULATE
Public Const DCB_SET = (DCB_RESET Or DCB_ACCUMULATE)
Public Const DCB_ENABLE = &H4
Public Const DCB_DISABLE = &H8

' Metafile Functions
Public Const META_SETBKCOLOR = &H201
Public Const META_SETBKMODE = &H102
Public Const META_SETMAPMODE = &H103
Public Const META_SETROP2 = &H104
Public Const META_SETRELABS = &H105
Public Const META_SETPOLYFILLMODE = &H106
Public Const META_SETSTRETCHBLTMODE = &H107
Public Const META_SETTEXTCHAREXTRA = &H108
Public Const META_SETTEXTCOLOR = &H209
Public Const META_SETTEXTJUSTIFICATION = &H20A
Public Const META_SETWINDOWORG = &H20B
Public Const META_SETWINDOWEXT = &H20C
Public Const META_SETVIEWPORTORG = &H20D
Public Const META_SETVIEWPORTEXT = &H20E
Public Const META_OFFSETWINDOWORG = &H20F
Public Const META_SCALEWINDOWEXT = &H410
Public Const META_OFFSETVIEWPORTORG = &H211
Public Const META_SCALEVIEWPORTEXT = &H412
Public Const META_LINETO = &H213
Public Const META_MOVETO = &H214
Public Const META_EXCLUDECLIPRECT = &H415
Public Const META_INTERSECTCLIPRECT = &H416
Public Const META_ARC = &H817
Public Const META_ELLIPSE = &H418
Public Const META_FLOODFILL = &H419
Public Const META_PIE = &H81A
Public Const META_RECTANGLE = &H41B
Public Const META_ROUNDRECT = &H61C
Public Const META_PATBLT = &H61D
Public Const META_SAVEDC = &H1E
Public Const META_SETPIXEL = &H41F
Public Const META_OFFSETCLIPRGN = &H220
Public Const META_TEXTOUT = &H521
Public Const META_BITBLT = &H922
Public Const META_STRETCHBLT = &HB23
Public Const META_POLYGON = &H324
Public Const META_POLYLINE = &H325
Public Const META_ESCAPE = &H626
Public Const META_RESTOREDC = &H127
Public Const META_FILLREGION = &H228
Public Const META_FRAMEREGION = &H429
Public Const META_INVERTREGION = &H12A
Public Const META_PAINTREGION = &H12B
Public Const META_SELECTCLIPREGION = &H12C
Public Const META_SELECTOBJECT = &H12D
Public Const META_SETTEXTALIGN = &H12E
Public Const META_CHORD = &H830
Public Const META_SETMAPPERFLAGS = &H231
Public Const META_EXTTEXTOUT = &HA32
Public Const META_SETDIBTODEV = &HD33
Public Const META_SELECTPALETTE = &H234
Public Const META_REALIZEPALETTE = &H35
Public Const META_ANIMATEPALETTE = &H436
Public Const META_SETPALENTRIES = &H37
Public Const META_POLYPOLYGON = &H538
Public Const META_RESIZEPALETTE = &H139
Public Const META_DIBBITBLT = &H940
Public Const META_DIBSTRETCHBLT = &HB41
Public Const META_DIBCREATEPATTERNBRUSH = &H142
Public Const META_STRETCHDIB = &HF43
Public Const META_EXTFLOODFILL = &H548
Public Const META_DELETEOBJECT = &H1F0
Public Const META_CREATEPALETTE = &HF7
Public Const META_CREATEPATTERNBRUSH = &H1F9
Public Const META_CREATEPENINDIRECT = &H2FA
Public Const META_CREATEFONTINDIRECT = &H2FB
Public Const META_CREATEBRUSHINDIRECT = &H2FC
Public Const META_CREATEREGION = &H6FF


' GDI Escapes
Public Const NEWFRAME = 1
Public Const AbortDocC = 2
Public Const NEXTBAND = 3
Public Const SETCOLORTABLE = 4
Public Const GETCOLORTABLE = 5
Public Const FLUSHOUTPUT = 6
Public Const DRAFTMODE = 7
Public Const QUERYESCSUPPORT = 8
Public Const SETABORTPROC = 9
Public Const StartDocC = 10
Public Const EndDocC = 11
Public Const GETPHYSPAGESIZE = 12
Public Const GETPRINTINGOFFSET = 13
Public Const GETSCALINGFACTOR = 14
Public Const MFCOMMENT = 15
Public Const GETPENWIDTH = 16
Public Const SETCOPYCOUNT = 17
Public Const SELECTPAPERSOURCE = 18
Public Const DEVICEDATA = 19
Public Const PASSTHROUGH = 19
Public Const GETTECHNOLGY = 20
Public Const GETTECHNOLOGY = 20
Public Const SETLINECAP = 21
Public Const SETLINEJOIN = 22
Public Const SetMiterLimitC = 23
Public Const BANDINFO = 24
Public Const DRAWPATTERNRECT = 25
Public Const GETVECTORPENSIZE = 26
Public Const GETVECTORBRUSHSIZE = 27
Public Const ENABLEDUPLEX = 28
Public Const GETSETPAPERBINS = 29
Public Const GETSETPRINTORIENT = 30
Public Const ENUMPAPERBINS = 31
Public Const SETDIBSCALING = 32
Public Const EPSPRINTING = 33
Public Const ENUMPAPERMETRICS = 34
Public Const GETSETPAPERMETRICS = 35
Public Const POSTSCRIPT_DATA = 37
Public Const POSTSCRIPT_IGNORE = 38
Public Const MOUSETRAILS = 39
Public Const GETDEVICEUNITS = 42

Public Const GETEXTENDEDTEXTMETRICS = 256
Public Const GETEXTENTTABLE = 257
Public Const GETPAIRKERNTABLE = 258
Public Const GETTRACKKERNTABLE = 259
Public Const ExtTextOutC = 512
Public Const GETFACENAME = 513
Public Const DOWNLOADFACE = 514
Public Const ENABLERELATIVEWIDTHS = 768
Public Const ENABLEPAIRKERNING = 769
Public Const SETKERNTRACK = 770
Public Const SETALLJUSTVALUES = 771
Public Const SETCHARSET = 772

Public Const StretchBltC = 2048
Public Const GETSETSCREENPARAMS = 3072
Public Const BEGIN_PATH = 4096
Public Const CLIP_TO_PATH = 4097
Public Const END_PATH = 4098
Public Const EXT_DEVICE_CAPS = 4099
Public Const RESTORE_CTM = 4100
Public Const SAVE_CTM = 4101
Public Const SET_ARC_DIRECTION = 4102
Public Const SET_BACKGROUND_COLOR = 4103
Public Const SET_POLY_MODE = 4104
Public Const SET_SCREEN_ANGLE = 4105
Public Const SET_SPREAD = 4106
Public Const TRANSFORM_CTM = 4107
Public Const SET_CLIP_BOX = 4108
Public Const SET_BOUNDS = 4109
Public Const SET_MIRROR_MODE = 4110
Public Const OPENCHANNEL = 4110
Public Const DOWNLOADHEADER = 4111
Public Const CLOSECHANNEL = 4112
Public Const POSTSCRIPT_PASSTHROUGH = 4115
Public Const ENCAPSULATED_POSTSCRIPT = 4116

' Spooler Error Codes
Public Const SP_NOTREPORTED = &H4000
Public Const SP_ERROR = (-1)
Public Const SP_APPABORT = (-2)
Public Const SP_USERABORT = (-3)
Public Const SP_OUTOFDISK = (-4)
Public Const SP_OUTOFMEMORY = (-5)

Public Const PR_JOBSTATUS = &H0

'  Object Definitions for EnumObjects()
Public Const OBJ_PEN = 1
Public Const OBJ_BRUSH = 2
Public Const OBJ_DC = 3
Public Const OBJ_METADC = 4
Public Const OBJ_PAL = 5
Public Const OBJ_FONT = 6
Public Const OBJ_BITMAP = 7
Public Const OBJ_REGION = 8
Public Const OBJ_METAFILE = 9
Public Const OBJ_MEMDC = 10
Public Const OBJ_EXTPEN = 11
Public Const OBJ_ENHMETADC = 12
Public Const OBJ_ENHMETAFILE = 13

'  xform stuff
Public Const MWT_IDENTITY = 1
Public Const MWT_LEFTMULTIPLY = 2
Public Const MWT_RIGHTMULTIPLY = 3

Public Const MWT_MIN = MWT_IDENTITY
Public Const MWT_MAX = MWT_RIGHTMULTIPLY

Type XFORM
        eM11 As Double
        eM12 As Double
        eM21 As Double
        eM22 As Double
        eDx As Double
        eDy As Double
End Type

' Bitmap Header Definition
Type BITMAP '14 bytes
        bmType As Long
        bmWidth As Long
        bmHeight As Long
        bmWidthBytes As Long
        bmPlanes As Integer
        bmBitsPixel As Integer
        bmBits As Long
End Type

Type RGBTRIPLE
        rgbtBlue As Byte
        rgbtGreen As Byte
        rgbtRed As Byte
End Type

Type RGBQUAD
        rgbBlue As Byte
        rgbGreen As Byte
        rgbRed As Byte
        rgbReserved As Byte
End Type

' structures for defining DIBs
Type BITMAPCOREHEADER '12 bytes
        bcSize As Long
        bcWidth As Integer
        bcHeight As Integer
        bcPlanes As Integer
        bcBitCount As Integer
End Type

Type BITMAPINFOHEADER '40 bytes
        biSize As Long
        biWidth As Long
        biHeight As Long
        biPlanes As Integer
        biBitCount As Integer
        biCompression As Long
        biSizeImage As Long
        biXPelsPerMeter As Long
        biYPelsPerMeter As Long
        biClrUsed As Long
        biClrImportant As Long
End Type

' constants for the biCompression field
Public Const BI_RGB = 0&
Public Const BI_RLE8 = 1&
Public Const BI_RLE4 = 2&
Public Const BI_bitfields = 3&

Type BITMAPINFO
        bmiHeader As BITMAPINFOHEADER
        bmiColors As RGBQUAD
End Type

Type BITMAPCOREINFO
        bmciHeader As BITMAPCOREHEADER
        bmciColors As RGBTRIPLE
End Type

Type BITMAPFILEHEADER
        bfType As Integer
        bfSize As Long
        bfReserved1 As Integer
        bfReserved2 As Integer
        bfOffBits As Long
End Type


' Clipboard Metafile Picture Structure
Type HANDLETABLE
        objectHandle(1) As Long
End Type

Type METARECORD
        rdSize As Long
        rdFunction As Integer
        rdParm(1) As Integer
End Type


Type METAFILEPICT
        mm As Long
        xExt As Long
        yExt As Long
        hMF As Long
End Type

Type METAHEADER
        mtType As Integer
        mtHeaderSize As Integer
        mtVersion As Integer
        mtSize As Long
        mtNoObjects As Integer
        mtMaxRecord As Long
        mtNoParameters As Integer
End Type

Type ENHMETARECORD
        iType As Long
        nSize As Long
        dParm(1) As Long
End Type

Type SIZEL
    cx As Long
    cy As Long
End Type

Type ENHMETAHEADER
        iType As Long
        nSize As Long
        rclBounds As RECTL
        rclFrame As RECTL
        dSignature As Long
        nVersion As Long
        nBytes As Long
        nRecords As Long
        nHandles As Integer
        sReserved As Integer
        nDescription As Long
        offDescription As Long
        nPalEntries As Long
        szlDevice As SIZEL
        szlMillimeters As SIZEL
End Type

Type TEXTMETRIC
        tmHeight As Long
        tmAscent As Long
        tmDescent As Long
        tmInternalLeading As Long
        tmExternalLeading As Long
        tmAveCharWidth As Long
        tmMaxCharWidth As Long
        tmWeight As Long
        tmOverhang As Long
        tmDigitizedAspectX As Long
        tmDigitizedAspectY As Long
        tmFirstChar As Byte
        tmLastChar As Byte
        tmDefaultChar As Byte
        tmBreakChar As Byte
        tmItalic As Byte
        tmUnderlined As Byte
        tmStruckOut As Byte
        tmPitchAndFamily As Byte
        tmCharSet As Byte
End Type

' ntmFlags field flags
Public Const NTM_REGULAR = &H40&
Public Const NTM_BOLD = &H20&
Public Const NTM_ITALIC = &H1&

' Structure passed to FONTENUMPROC
' NOTE: NEWTEXTMETRIC is the same as TEXTMETRIC plus 4 new fields
Type NEWTEXTMETRIC
        tmHeight As Long
        tmAscent As Long
        tmDescent As Long
        tmInternalLeading As Long
        tmExternalLeading As Long
        tmAveCharWidth As Long
        tmMaxCharWidth As Long
        tmWeight As Long
        tmOverhang As Long
        tmDigitizedAspectX As Long
        tmDigitizedAspectY As Long
        tmFirstChar As Byte
        tmLastChar As Byte
        tmDefaultChar As Byte
        tmBreakChar As Byte
        tmItalic As Byte
        tmUnderlined As Byte
        tmStruckOut As Byte
        tmPitchAndFamily As Byte
        tmCharSet As Byte
        ntmFlags As Long
        ntmSizeEM As Long
        ntmCellHeight As Long
        ntmAveWidth As Long
End Type

'  tmPitchAndFamily flags
Public Const TMPF_FIXED_PITCH = &H1
Public Const TMPF_VECTOR = &H2
Public Const TMPF_DEVICE = &H8
Public Const TMPF_TRUETYPE = &H4


' GDI Logical Objects:

Type PELARRAY
        paXCount As Long
        paYCount As Long
        paXExt As Long
        paYExt As Long
        paRGBs As Integer
End Type

' Logical Brush (or Pattern)
Type LOGBRUSH
        lbStyle As Long
        lbColor As Long
        lbHatch As Long
End Type

' Logical Pen
Type LOGPEN
        lopnStyle As Long
        lopnWidth As POINTAPI
        lopnColor As Long
End Type

Type EXTLOGPEN
        elpPenStyle As Long
        elpWidth As Long
        elpBrushStyle As Long
        elpColor As Long
        elpHatch As Long
        elpNumEntries As Long
        elpStyleEntry(1) As Long
End Type

Type PALETTEENTRY
        peRed As Byte
        peGreen As Byte
        peBlue As Byte
        peFlags As Byte
End Type

' Logical Palette
Type LOGPALETTE
        palVersion As Integer
        palNumEntries As Integer
        palPalEntry(1) As PALETTEENTRY
End Type

' Logical Font
Public Const LF_FACESIZE = 32
Public Const LF_FULLFACESIZE = 64

Type LOGFONT
        lfHeight As Long
        lfWidth As Long
        lfEscapement As Long
        lfOrientation As Long
        lfWeight As Long
        lfItalic As Byte
        lfUnderline As Byte
        lfStrikeOut As Byte
        lfCharSet As Byte
        lfOutPrecision As Byte
        lfClipPrecision As Byte
        lfQuality As Byte
        lfPitchAndFamily As Byte
        lfFaceName(LF_FACESIZE) As Byte
End Type

Type NONCLIENTMETRICS
        cbSize As Long
        iBorderWidth As Long
        iScrollWidth As Long
        iScrollHeight As Long
        iCaptionWidth As Long
        iCaptionHeight As Long
        lfCaptionFont As LOGFONT
        iSMCaptionWidth As Long
        iSMCaptionHeight As Long
        lfSMCaptionFont As LOGFONT
        iMenuWidth As Long
        iMenuHeight As Long
        lfMenuFont As LOGFONT
        lfStatusFont As LOGFONT
        lfMessageFont As LOGFONT
End Type

Type ENUMLOGFONT
        elfLogFont As LOGFONT
        elfFullName(LF_FULLFACESIZE) As Byte
        elfStyle(LF_FACESIZE) As Byte
End Type

Public Const OUT_DEFAULT_PRECIS = 0
Public Const OUT_STRING_PRECIS = 1
Public Const OUT_CHARACTER_PRECIS = 2
Public Const OUT_STROKE_PRECIS = 3
Public Const OUT_TT_PRECIS = 4
Public Const OUT_DEVICE_PRECIS = 5
Public Const OUT_RASTER_PRECIS = 6
Public Const OUT_TT_ONLY_PRECIS = 7
Public Const OUT_OUTLINE_PRECIS = 8

Public Const CLIP_DEFAULT_PRECIS = 0
Public Const CLIP_CHARACTER_PRECIS = 1
Public Const CLIP_STROKE_PRECIS = 2
Public Const CLIP_MASK = &HF
Public Const CLIP_LH_ANGLES = 16
Public Const CLIP_TT_ALWAYS = 32
Public Const CLIP_EMBEDDED = 128

Public Const DEFAULT_QUALITY = 0
Public Const DRAFT_QUALITY = 1
Public Const PROOF_QUALITY = 2

Public Const DEFAULT_PITCH = 0
Public Const FIXED_PITCH = 1
Public Const VARIABLE_PITCH = 2

Public Const ANSI_CHARSET = 0
Public Const DEFAULT_CHARSET = 1
Public Const SYMBOL_CHARSET = 2
Public Const SHIFTJIS_CHARSET = 128
Public Const HANGEUL_CHARSET = 129
Public Const CHINESEBIG5_CHARSET = 136
Public Const OEM_CHARSET = 255
#1047

' LOCALE_NOUSEROVERRIDE is also used in GetTimeFormatW and GetDateFormatW.
Public Const LOCALE_NOUSEROVERRIDE = &H80000000  '  do not use user overrides

Public Const LOCALE_ILANGUAGE = &H1         '  language id
Public Const LOCALE_SLANGUAGE = &H2         '  localized name of language
Public Const LOCALE_SENGLANGUAGE = &H1001      '  English name of language
Public Const LOCALE_SABBREVLANGNAME = &H3         '  abbreviated language name
Public Const LOCALE_SNATIVELANGNAME = &H4         '  native name of language
Public Const LOCALE_ICOUNTRY = &H5         '  country code
Public Const LOCALE_SCOUNTRY = &H6         '  localized name of country
Public Const LOCALE_SENGCOUNTRY = &H1002      '  English name of country
Public Const LOCALE_SABBREVCTRYNAME = &H7         '  abbreviated country name
Public Const LOCALE_SNATIVECTRYNAME = &H8         '  native name of country
Public Const LOCALE_IDEFAULTLANGUAGE = &H9         '  default language id
Public Const LOCALE_IDEFAULTCOUNTRY = &HA         '  default country code
Public Const LOCALE_IDEFAULTCODEPAGE = &HB         '  default code page

Public Const LOCALE_SLIST = &HC         '  list item separator
Public Const LOCALE_IMEASURE = &HD         '  0 = metric, 1 = US

Public Const LOCALE_SDECIMAL = &HE         '  decimal separator
Public Const LOCALE_STHOUSAND = &HF         '  thousand separator
Public Const LOCALE_SGROUPING = &H10        '  digit grouping
Public Const LOCALE_IDIGITS = &H11        '  number of fractional digits
Public Const LOCALE_ILZERO = &H12        '  leading zeros for decimal
Public Const LOCALE_SNATIVEDIGITS = &H13        '  native ascii 0-9

Public Const LOCALE_SCURRENCY = &H14        '  local monetary symbol
Public Const LOCALE_SINTLSYMBOL = &H15        '  intl monetary symbol
Public Const LOCALE_SMONDECIMALSEP = &H16        '  monetary decimal separator
Public Const LOCALE_SMONTHOUSANDSEP = &H17        '  monetary thousand separator
Public Const LOCALE_SMONGROUPING = &H18        '  monetary grouping
Public Const LOCALE_ICURRDIGITS = &H19        '  # local monetary digits
Public Const LOCALE_IINTLCURRDIGITS = &H1A        '  # intl monetary digits
Public Const LOCALE_ICURRENCY = &H1B        '  positive currency mode
Public Const LOCALE_INEGCURR = &H1C        '  negative currency mode

Public Const LOCALE_SDATE = &H1D        '  date separator
Public Const LOCALE_STIME = &H1E        '  time separator
Public Const LOCALE_SSHORTDATE = &H1F        '  short date format string
Public Const LOCALE_SLONGDATE = &H20        '  long date format string
Public Const LOCALE_STIMEFORMAT = &H1003      '  time format string
Public Const LOCALE_IDATE = &H21        '  short date format ordering
Public Const LOCALE_ILDATE = &H22        '  long date format ordering
Public Const LOCALE_ITIME = &H23        '  time format specifier
Public Const LOCALE_ICENTURY = &H24        '  century format specifier
Public Const LOCALE_ITLZERO = &H25        '  leading zeros in time field
Public Const LOCALE_IDAYLZERO = &H26        '  leading zeros in day field
Public Const LOCALE_IMONLZERO = &H27        '  leading zeros in month field
Public Const LOCALE_S1159 = &H28        '  AM designator
Public Const LOCALE_S2359 = &H29        '  PM designator

Public Const LOCALE_SDAYNAME1 = &H2A        '  long name for Monday
Public Const LOCALE_SDAYNAME2 = &H2B        '  long name for Tuesday
Public Const LOCALE_SDAYNAME3 = &H2C        '  long name for Wednesday
Public Const LOCALE_SDAYNAME4 = &H2D        '  long name for Thursday
Public Const LOCALE_SDAYNAME5 = &H2E        '  long name for Friday
Public Const LOCALE_SDAYNAME6 = &H2F        '  long name for Saturday
Public Const LOCALE_SDAYNAME7 = &H30        '  long name for Sunday
Public Const LOCALE_SABBREVDAYNAME1 = &H31        '  abbreviated name for Monday
Public Const LOCALE_SABBREVDAYNAME2 = &H32        '  abbreviated name for Tuesday
Public Const LOCALE_SABBREVDAYNAME3 = &H33        '  abbreviated name for Wednesday
Public Const LOCALE_SABBREVDAYNAME4 = &H34        '  abbreviated name for Thursday
Public Const LOCALE_SABBREVDAYNAME5 = &H35        '  abbreviated name for Friday
Public Const LOCALE_SABBREVDAYNAME6 = &H36        '  abbreviated name for Saturday
Public Const LOCALE_SABBREVDAYNAME7 = &H37        '  abbreviated name for Sunday
Public Const LOCALE_SMONTHNAME1 = &H38        '  long name for January
Public Const LOCALE_SMONTHNAME2 = &H39        '  long name for February
Public Const LOCALE_SMONTHNAME3 = &H3A        '  long name for March
Public Const LOCALE_SMONTHNAME4 = &H3B        '  long name for April
Public Const LOCALE_SMONTHNAME5 = &H3C        '  long name for May
Public Const LOCALE_SMONTHNAME6 = &H3D        '  long name for June
Public Const LOCALE_SMONTHNAME7 = &H3E        '  long name for July
Public Const LOCALE_SMONTHNAME8 = &H3F        '  long name for August
Public Const LOCALE_SMONTHNAME9 = &H40        '  long name for September
Public Const LOCALE_SMONTHNAME10 = &H41        '  long name for October
Public Const LOCALE_SMONTHNAME11 = &H42        '  long name for November
Public Const LOCALE_SMONTHNAME12 = &H43        '  long name for December
Public Const LOCALE_SABBREVMONTHNAME1 = &H44        '  abbreviated name for January
Public Const LOCALE_SABBREVMONTHNAME2 = &H45        '  abbreviated name for February
Public Const LOCALE_SABBREVMONTHNAME3 = &H46        '  abbreviated name for March
Public Const LOCALE_SABBREVMONTHNAME4 = &H47        '  abbreviated name for April
Public Const LOCALE_SABBREVMONTHNAME5 = &H48        '  abbreviated name for May
Public Const LOCALE_SABBREVMONTHNAME6 = &H49        '  abbreviated name for June
Public Const LOCALE_SABBREVMONTHNAME7 = &H4A        '  abbreviated name for July
Public Const LOCALE_SABBREVMONTHNAME8 = &H4B        '  abbreviated name for August
Public Const LOCALE_SABBREVMONTHNAME9 = &H4C        '  abbreviated name for September
Public Const LOCALE_SABBREVMONTHNAME10 = &H4D        '  abbreviated name for October
Public Const LOCALE_SABBREVMONTHNAME11 = &H4E        '  abbreviated name for November
Public Const LOCALE_SABBREVMONTHNAME12 = &H4F        '  abbreviated name for December
Public Const LOCALE_SABBREVMONTHNAME13 = &H100F

Public Const LOCALE_SPOSITIVESIGN = &H50        '  positive sign
Public Const LOCALE_SNEGATIVESIGN = &H51        '  negative sign
Public Const LOCALE_IPOSSIGNPOSN = &H52        '  positive sign position
Public Const LOCALE_INEGSIGNPOSN = &H53        '  negative sign position
Public Const LOCALE_IPOSSYMPRECEDES = &H54        '  mon sym precedes pos amt
Public Const LOCALE_IPOSSEPBYSPACE = &H55        '  mon sym sep by space from pos amt
Public Const LOCALE_INEGSYMPRECEDES = &H56        '  mon sym precedes neg amt
Public Const LOCALE_INEGSEPBYSPACE = &H57        '  mon sym sep by space from neg amt

' Time Flags for GetTimeFormatW.
Public Const TIME_NOMINUTESORSECONDS = &H1         '  do not use minutes or seconds
Public Const TIME_NOSECONDS = &H2         '  do not use seconds
Public Const TIME_NOTIMEMARKER = &H4         '  do not use time marker
Public Const TIME_FORCE24HOURFORMAT = &H8         '  always use 24 hour format

' Date Flags for GetDateFormatW.
Public Const DATE_SHORTDATE = &H1         '  use short date picture
Public Const DATE_LONGDATE = &H2         '  use long date picture


' Code Page Dependent APIs

Declare Function IsValidCodePage Lib "kernel32" Alias "IsValidCodePage" (ByVal CodePage As Long) As Long
Declare Function GetACP Lib "kernel32" Alias "GetACP" () As Long
Declare Function GetOEMCP Lib "kernel32" Alias "GetOEMCP" () As Long
Declare Function GetCPInfo Lib "kernel32" Alias "GetCPInfo" (ByVal CodePage As Long, lpCPInfo As CPINFO) As Long
Declare Function IsDBCSLeadByte Lib "kernel32" Alias "IsDBCSLeadByte" (ByVal bTestChar As Byte) As Long
Declare Function MultiByteToWideChar Lib "kernel32" Alias "MultiByteToWideChar" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As String, ByVal cchMultiByte As Long, ByVal lpWideCharStr As String, ByVal cchWideChar As Long) As Long
Declare Function WideCharToMultiByte Lib "kernel32" Alias "WideCharToMultiByte" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As String, ByVal cchWideChar As Long, ByVal lpMultiByteStr As String, ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long

' Locale Dependent APIs

Declare Function CompareString Lib "kernel32" Alias "CompareStringA" (ByVal Locale As Long, ByVal dwCmpFlags As Long, ByVal lpString1 As String, ByVal cchCount1 As Long, ByVal lpString2 As String, ByVal cchCount2 As Long) As Long
Declare Function LCMapString Lib "kernel32" Alias "LCMapStringA" (ByVal Locale As Long, ByVal dwMapFlags As Long, ByVal lpSrcStr As String, ByVal cchSrc As Long, ByVal lpDestStr As String, ByVal cchDest As Long) As Long
Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Declare Function GetTimeFormat Lib "kernel32" Alias "GetTimeFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, lpTime As SYSTEMTIME, ByVal lpFormat As String, ByVal lpTimeStr As String, ByVal cchTime As Long) As Long
Declare Function GetDateFormat Lib "kernel32" Alias "GetDateFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, lpDate As SYSTEMTIME, ByVal lpFormat As String, ByVal lpDateStr As String, ByVal cchDate As Long) As Long
Declare Function SetThreadLocale Lib "kernel32" Alias "SetThreadLocale" (ByVal Locale As Long) As Long
Declare Function GetSystemDefaultLangID Lib "kernel32" Alias "GetSystemDefaultLangID" () As Integer
Declare Function GetUserDefaultLangID Lib "kernel32" Alias "GetUserDefaultLangID" () As Integer
Declare Function GetSystemDefaultLCID Lib "kernel32" Alias "GetSystemDefaultLCID" () As Long
Declare Function GetUserDefaultLCID Lib "kernel32" Alias "GetUserDefaultLCID" () As Long

' Locale Independent APIs

Declare Function GetStringTypeA Lib "kernel32" Alias "GetStringTypeA" (ByVal lcid As Long, ByVal dwInfoType As Long, ByVal lpSrcStr As String, ByVal cchSrc As Long, lpCharType As Long) As Long
Declare Function FoldString Lib "kernel32" Alias "FoldStringA" (ByVal dwMapFlags As Long, ByVal lpSrcStr As String, ByVal cchSrc As Long, ByVal lpDestStr As String, ByVal cchDest As Long) As Long

' *************************************************************************
' *                                                                         *
' * winnls.h -- NLS procedure declarations, constant definitions and macros *
' *                                                                         *
' * Copyright (c) 1991-1995, Microsoft Corp. All rights reserved.           *
' *                                                                         *
' **************************************************************************/

' *  Calendar Types.
'  *
'  *  These types are used for the GetALTCalendarInfoW NLS API routine.
'  */
Public Const MAX_DEFAULTCHAR = 2
Public Const CAL_ICALINTVALUE = &H1                     '  calendar type
Public Const CAL_SCALNAME = &H2                         '  native name of calendar
Public Const CAL_IYEAROFFSETRANGE = &H3                 '  starting years of eras
Public Const CAL_SERASTRING = &H4                       '  era name for IYearOffsetRanges
Public Const CAL_SSHORTDATE = &H5                       '  Integer date format string
Public Const CAL_SLONGDATE = &H6                        '  long date format string
Public Const CAL_SDAYNAME1 = &H7                        '  native name for Monday
Public Const CAL_SDAYNAME2 = &H8                        '  native name for Tuesday
Public Const CAL_SDAYNAME3 = &H9                        '  native name for Wednesday
Public Const CAL_SDAYNAME4 = &HA                        '  native name for Thursday
Public Const CAL_SDAYNAME5 = &HB                        '  native name for Friday
Public Const CAL_SDAYNAME6 = &HC                        '  native name for Saturday
Public Const CAL_SDAYNAME7 = &HD                        '  native name for Sunday
Public Const CAL_SABBREVDAYNAME1 = &HE                  '  abbreviated name for Monday
Public Const CAL_SABBREVDAYNAME2 = &HF                  '  abbreviated name for Tuesday
Public Const CAL_SABBREVDAYNAME3 = &H10                 '  abbreviated name for Wednesday
Public Const CAL_SABBREVDAYNAME4 = &H11                 '  abbreviated name for Thursday
Public Const CAL_SABBREVDAYNAME5 = &H12                 '  abbreviated name for Friday
Public Const CAL_SABBREVDAYNAME6 = &H13                 '  abbreviated name for Saturday
Public Const CAL_SABBREVDAYNAME7 = &H14                 '  abbreviated name for Sunday
Public Const CAL_SMONTHNAME1 = &H15                     '  native name for January
Public Const CAL_SMONTHNAME2 = &H16                     '  native name for February
Public Const CAL_SMONTHNAME3 = &H17                     '  native name for March
Public Const CAL_SMONTHNAME4 = &H18                     '  native name for April
Public Const CAL_SMONTHNAME5 = &H19                     '  native name for May
Public Const CAL_SMONTHNAME6 = &H1A                     '  native name for June
Public Const CAL_SMONTHNAME7 = &H1B                     '  native name for July
Public Const CAL_SMONTHNAME8 = &H1C                     '  native name for August
Public Const CAL_SMONTHNAME9 = &H1D                     '  native name for September
Public Const CAL_SMONTHNAME10 = &H1E                    '  native name for October
Public Const CAL_SMONTHNAME11 = &H1F                    '  native name for November
Public Const CAL_SMONTHNAME12 = &H20                    '  native name for December
Public Const CAL_SMONTHNAME13 = &H21                    '  native name for 13th month (if any)
Public Const CAL_SABBREVMONTHNAME1 = &H22               '  abbreviated name for January
Public Const CAL_SABBREVMONTHNAME2 = &H23               '  abbreviated name for February
Public Const CAL_SABBREVMONTHNAME3 = &H24               '  abbreviated name for March
Public Const CAL_SABBREVMONTHNAME4 = &H25               '  abbreviated name for April
Public Const CAL_SABBREVMONTHNAME5 = &H26               '  abbreviated name for May
Public Const CAL_SABBREVMONTHNAME6 = &H27               '  abbreviated name for June
Public Const CAL_SABBREVMONTHNAME7 = &H28               '  abbreviated name for July
Public Const CAL_SABBREVMONTHNAME8 = &H29               '  abbreviated name for August
Public Const CAL_SABBREVMONTHNAME9 = &H2A               '  abbreviated name for September
Public Const CAL_SABBREVMONTHNAME10 = &H2B              '  abbreviated name for October
Public Const CAL_SABBREVMONTHNAME11 = &H2C              '  abbreviated name for November
Public Const CAL_SABBREVMONTHNAME12 = &H2D              '  abbreviated name for December
Public Const CAL_SABBREVMONTHNAME13 = &H2E              '  abbreviated name for 13th month (if any)

'
'  *  Calendar Enumeration Value.
'  */
Public Const ENUM_ALL_CALENDARS = &HFFFF                '  enumerate all calendars
'
'  *  Calendar ID Values.
'  */
Public Const CAL_GREGORIAN = 1                 '  Gregorian (localized) calendar
Public Const CAL_GREGORIAN_US = 2              '  Gregorian (U.S.) calendar
Public Const CAL_JAPAN = 3                     '  Japanese Emperor Era calendar
Public Const CAL_TAIWAN = 4                    '  Republic of China Era calendar
Public Const CAL_KOREA = 5                     '  Korean Tangun Era calendar

' *************************************************************************** Typedefs
' *
' * Define all types for the NLS component here.
' \***************************************************************************/
'
'  *  CP Info.
'  */

Type CPINFO
        MaxCharSize As Long                    '  max length (Byte) of a char
        DefaultChar(MAX_DEFAULTCHAR) As Byte   '  default character
        LeadByte(MAX_LEADBYTES) As Byte        '  lead byte ranges
End Type

Type NUMBERFMT
        NumDigits As Long                 '  number of decimal digits
        LeadingZero As Long '  if leading zero in decimal fields
        Grouping As Long '  group size left of decimal
        lpDecimalSep As String              '  ptr to decimal separator string
        lpThousandSep As String             '  ptr to thousand separator string
        NegativeOrder As Long '  negative number ordering
End Type
'
'  *  Currency format.
'  */

Type CURRENCYFMT
        NumDigits As Long '  number of decimal digits
        LeadingZero As Long '  if leading zero in decimal fields
        Grouping As Long '  group size left of decimal
        lpDecimalSep As String              '  ptr to decimal separator string
        lpThousandSep As String             '  ptr to thousand separator string
        NegativeOrder As Long '  negative currency ordering
        PositiveOrder As Long '  positive currency ordering
        lpCurrencySymbol As String          '  ptr to currency symbol string
End Type

Declare Function EnumTimeFormats Lib "KERNEL32" Alias "EnumTimeFormats" (ByVal lpTimeFmtEnumProc As Long, ByVal Locale As Long, ByVal dwFlags As Long) As Long
Declare Function EnumDateFormats Lib "KERNEL32" Alias "EnumDateFormats" (ByVal lpDateFmtEnumProc As Long, ByVal Locale As Long, ByVal dwFlags As Long) As Long
Declare Function IsValidLocale Lib "KERNEL32" Alias "IsValidLocale" (ByVal Locale As Long, ByVal dwFlags As Long) As Long
Declare Function ConvertDefaultLocale Lib "KERNEL32" Alias "ConvertDefaultLocale" (ByVal Locale As Long) As Long
Declare Function GetThreadLocale Lib "KERNEL32" Alias "GetThreadLocale" () As Long
Declare Function EnumSystemLocales Lib "KERNEL32" Alias "EnumSystemLocales" (ByVal lpLocaleEnumProc As Long, ByVal dwFlags As Long) As Long
Declare Function EnumSystemCodePages Lib "KERNEL32" Alias "EnumSystemCodePages" (ByVal lpCodePageEnumProc As Long, ByVal dwFlags As Long) As Long

' The following section contains the public data structures, data types,
' and procedures exported by the NT console subsystem.

Type COORD
        x As Integer
        y As Integer
End Type

Type SMALL_RECT
        Left As Integer
        Top As Integer
        Right As Integer
        Bottom As Integer
End Type

Type KEY_EVENT_RECORD
        bKeyDown As Long
        wRepeatCount As Integer
        wVirtualKeyCode As Integer
        wVirtualScanCode As Integer
        uChar As Integer
        dwControlKeyState As Long
End Type

'  ControlKeyState flags
Public Const RIGHT_ALT_PRESSED = &H1     '  the right alt key is pressed.
Public Const LEFT_ALT_PRESSED = &H2     '  the left alt key is pressed.
Public Const RIGHT_CTRL_PRESSED = &H4     '  the right ctrl key is pressed.
Public Const LEFT_CTRL_PRESSED = &H8     '  the left ctrl key is pressed.
Public Const SHIFT_PRESSED = &H10    '  the shift key is pressed.
Public Const NUMLOCK_ON = &H20    '  the numlock light is on.
Public Const SCROLLLOCK_ON = &H40    '  the scrolllock light is on.
Public Const CAPSLOCK_ON = &H80    '  the capslock light is on.
Public Const ENHANCED_KEY = &H100   '  the key is enhanced.

Type MOUSE_EVENT_RECORD
        dwMousePosition As COORD
        dwButtonState As Long
        dwControlKeyState As Long
        dwEventFlags As Long
End Type

'  ButtonState flags
Public Const FROM_LEFT_1ST_BUTTON_PRESSED = &H1
Public Const RIGHTMOST_BUTTON_PRESSED = &H2
Public Const FROM_LEFT_2ND_BUTTON_PRESSED = &H4
Public Const FROM_LEFT_3RD_BUTTON_PRESSED = &H8
Public Const FROM_LEFT_4TH_BUTTON_PRESSED = &H10

'  EventFlags
Public Const MOUSE_MOVED = &H1
Public Const DOUBLE_CLICK = &H2

Type WINDOW_BUFFER_SIZE_RECORD
        dwSize As COORD
End Type

Type MENU_EVENT_RECORD
        dwCommandId As Long
End Type

Type FOCUS_EVENT_RECORD
        bSetFocus As Long
End Type

'   EventType flags:
Public Const KEY_EVENT = &H1     '  Event contains key event record
Public Const mouse_eventC = &H2     '  Event contains mouse event record
Public Const WINDOW_BUFFER_SIZE_EVENT = &H4     '  Event contains window change event record
Public Const MENU_EVENT = &H8     '  Event contains menu event record
Public Const FOCUS_EVENT = &H10    '  event contains focus change

Type CHAR_INFO
        Char As Integer
        Attributes As Integer
End Type

'  Attributes flags:
Public Const FOREGROUND_BLUE = &H1     '  text color contains blue.
Public Const FOREGROUND_GREEN = &H2     '  text color contains green.
Public Const FOREGROUND_RED = &H4     '  text color contains red.
Public Const FOREGROUND_INTENSITY = &H8     '  text color is intensified.
Public Const BACKGROUND_BLUE = &H10    '  background color contains blue.
Public Const BACKGROUND_GREEN = &H20    '  background color contains green.
Public Const BACKGROUND_RED = &H40    '  background color contains red.
Public Const BACKGROUND_INTENSITY = &H80    '  background color is intensified.

Type CONSOLE_SCREEN_BUFFER_INFO
        dwSize As COORD
        dwCursorPosition As COORD
        wAttributes As Integer
        srWindow As SMALL_RECT
        dwMaximumWindowSize As COORD
End Type

Type CONSOLE_CURSOR_INFO
        dwSize As Long
        bVisible As Long
End Type

Public Const CTRL_C_EVENT = 0
Public Const CTRL_BREAK_EVENT = 1
Public Const CTRL_CLOSE_EVENT = 2
'  3 is reserved!
'  4 is reserved!
Public Const CTRL_LOGOFF_EVENT = 5
Public Const CTRL_SHUTDOWN_EVENT = 6

' Input Mode flags:
Public Const ENABLE_PROCESSED_INPUT = &H1
Public Const ENABLE_LINE_INPUT = &H2
Public Const ENABLE_ECHO_INPUT = &H4
Public Const ENABLE_WINDOW_INPUT = &H8
Public Const ENABLE_MOUSE_INPUT = &H10

' Output Mode flags:
Public Const ENABLE_PROCESSED_OUTPUT = &H1
Public Const ENABLE_WRAP_AT_EOL_OUTPUT = &H2

Declare Function ReadConsoleOutput Lib "kernel32" Alias "ReadConsoleOutputA" (ByVal hConsoleOutput As Long, lpBuffer As CHAR_INFO, dwBufferSize As COORD, dwBufferCoord As COORD, lpReadRegion As SMALL_RECT) As Long
Declare Function WriteConsoleOutput Lib "kernel32" Alias "WriteConsoleOutputA" (ByVal hConsoleOutput As Long, lpBuffer As CHAR_INFO, dwBufferSize As COORD, dwBufferCoord As COORD, lpWriteRegion As SMALL_RECT) As Long
Declare Function ReadConsoleOutputCharacter Lib "kernel32" Alias "ReadConsoleOutputCharacterA" (ByVal hConsoleOutput As Long, ByVal lpCharacter As String, ByVal nLength As Long, dwReadCoord As COORD, lpNumberOfCharsRead As Long) As Long
Declare Function ReadConsoleOutputAttribute Lib "kernel32" Alias "ReadConsoleOutputAttribute" (ByVal hConsoleOutput As Long, lpAttribute As Long, ByVal nLength As Long, dwReadCoord As COORD, lpNumberOfAttrsRead As Long) As Long
Declare Function WriteConsoleOutputCharacter Lib "kernel32" Alias "WriteConsoleOutputCharacterA" (ByVal hConsoleOutput As Long, ByVal lpCharacter As String, ByVal nLength As Long, dwWriteCoord As COORD, lpNumberOfCharsWritten As Long) As Long

Declare Function WriteConsoleOutputAttribute Lib "kernel32" Alias "WriteConsoleOutputAttribute" (ByVal hConsoleOutput As Long, lpAttribute As Integer, ByVal nLength As Long, dwWriteCoord As COORD, lpNumberOfAttrsWritten As Long) As Long
Declare Function FillConsoleOutputCharacter Lib "kernel32" Alias "FillConsoleOutputCharacterA" (ByVal hConsoleOutput As Long, ByVal cCharacter As Byte, ByVal nLength As Long, dwWriteCoord As COORD, lpNumberOfCharsWritten As Long) As Long
Declare Function FillConsoleOutputAttribute Lib "kernel32" Alias "FillConsoleOutputAttribute" (ByVal hConsoleOutput As Long, ByVal wAttribute As Long, ByVal nLength As Long, dwWriteCoord As COORD, lpNumberOfAttrsWritten As Long) As Long
Declare Function GetConsoleMode Lib "kernel32" Alias "GetConsoleMode" (ByVal hConsoleHandle As Long, lpMode As Long) As Long
Declare Function GetNumberOfConsoleInputEvents Lib "kernel32" Alias "GetNumberOfConsoleInputEvents" (ByVal hConsoleInput As Long, lpNumberOfEvents As Long) As Long
Declare Function GetConsoleScreenBufferInfo Lib "kernel32" Alias "GetConsoleScreenBufferInfo" (ByVal hConsoleOutput As Long, lpConsoleScreenBufferInfo As CONSOLE_SCREEN_BUFFER_INFO) As Long
Declare Function GetLargestConsoleWindowSize Lib "kernel32" Alias "GetLargestConsoleWindowSize" (ByVal hConsoleOutput As Long) As COORD
Declare Function GetConsoleCursorInfo Lib "kernel32" Alias "GetConsoleCursorInfo" (ByVal hConsoleOutput As Long, lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As Long
Declare Function GetNumberOfConsoleMouseButtons Lib "kernel32" Alias "GetNumberOfConsoleMouseButtons" (lpNumberOfMouseButtons As Long) As Long
Declare Function SetConsoleMode Lib "kernel32" Alias "SetConsoleMode" (ByVal hConsoleHandle As Long, ByVal dwMode As Long) As Long
Declare Function SetConsoleActiveScreenBuffer Lib "kernel32" Alias "SetConsoleActiveScreenBuffer" (ByVal hConsoleOutput As Long) As Long
Declare Function FlushConsoleInputBuffer Lib "kernel32" Alias "FlushConsoleInputBuffer" (ByVal hConsoleInput As Long) As Long
Declare Function SetConsoleScreenBufferSize Lib "kernel32" Alias "SetConsoleScreenBufferSize" (ByVal hConsoleOutput As Long, dwSize As COORD) As Long
Declare Function SetConsoleCursorPosition Lib "kernel32" Alias "SetConsoleCursorPosition" (ByVal hConsoleOutput As Long, dwCursorPosition As COORD) As Long
Declare Function SetConsoleCursorInfo Lib "kernel32" Alias "SetConsoleCursorInfo" (ByVal hConsoleOutput As Long, lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As Long
Declare Function ScrollConsoleScreenBuffer Lib "kernel32" Alias "ScrollConsoleScreenBufferA" (ByVal hConsoleOutput As Long, lpScrollRectangle As SMALL_RECT, lpClipRectangle As SMALL_RECT, dwDestinationOrigin As COORD, lpFill As CHAR_INFO) As Long
Declare Function SetConsoleWindowInfo Lib "kernel32" Alias "SetConsoleWindowInfo" (ByVal hConsoleOutput As Long, ByVal bAbsolute As Long, lpConsoleWindow As SMALL_RECT) As Long
Declare Function SetConsoleTextAttribute Lib "kernel32" Alias "SetConsoleTextAttribute" (ByVal hConsoleOutput As Long, ByVal wAttributes As Long) As Long
Declare Function SetConsoleCtrlHandler Lib "kernel32" Alias "SetConsoleCtrlHandler" (ByVal HandlerRoutine As Long, ByVal Add As Long) As Long
Declare Function GenerateConsoleCtrlEvent Lib "kernel32" Alias "GenerateConsoleCtrlEvent" (ByVal dwCtrlEvent As Long, ByVal dwProcessGroupId As Long) As Long
Declare Function AllocConsole Lib "kernel32" Alias "AllocConsole" () As Long
Declare Function FreeConsole Lib "kernel32" Alias "FreeConsole" () As Long
Declare Function GetConsoleTitle Lib "kernel32" Alias "GetConsoleTitleA" (ByVal lpConsoleTitle As String, ByVal nSize As Long) As Long
Declare Function SetConsoleTitle Lib "kernel32" Alias "SetConsoleTitleA" (ByVal lpConsoleTitle As String) As Long
Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (ByVal hConsoleInput As Long, lpBuffer As Any, ByVal nNumberOfCharsToRead As Long, lpNumberOfCharsRead As Long, lpReserved As Any) As Long
Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long

Public Const CONSOLE_TEXTMODE_BUFFER = 1

Declare Function CreateConsoleScreenBuffer Lib "kernel32" Alias "CreateConsoleScreenBuffer" (ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwFlags As Long, lpScreenBufferData As Any) As Long
Declare Function GetConsoleCP Lib "kernel32" Alias "GetConsoleCP" () As Long
Declare Function SetConsoleCP Lib "kernel32" Alias "SetConsoleCP" (ByVal wCodePageID As Long) As Long
Declare Function GetConsoleOutputCP Lib "kernel32" Alias "GetConsoleOutputCP" () As Long
Declare Function SetConsoleOutputCP Lib "kernel32" Alias "SetConsoleOutputCP" (ByVal wCodePageID As Long) As Long


' -------------
'  GDI Section
' -------------

' Binary raster ops
Public Const R2_BLACK = 1       '   0
Public Const R2_NOTMERGEPEN = 2 '  DPon
Public Const R2_MASKNOTPEN = 3  '  DPna
Public Const R2_NOTCOPYPEN = 4  '  PN
Public Const R2_MASKPENNOT = 5  '  PDna
Public Const R2_NOT = 6 '  Dn
Public Const R2_XORPEN = 7      '  DPx
Public Const R2_NOTMASKPEN = 8  '  DPan
Public Const R2_MASKPEN = 9     '  DPa
Public Const R2_NOTXORPEN = 10  '  DPxn
Public Const R2_NOP = 11        '  D
Public Const R2_MERGENOTPEN = 12        '  DPno
Public Const R2_COPYPEN = 13    '  P
Public Const R2_MERGEPENNOT = 14        '  PDno
Public Const R2_MERGEPEN = 15   '  DPo
Public Const R2_WHITE = 16      '   1
Public Const R2_LAST = 16

'  Ternary raster operations
Public Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Public Const SRCPAINT = &HEE0086        ' (DWORD) dest = source OR dest
Public Const SRCAND = &H8800C6  ' (DWORD) dest = source AND dest
Public Const SRCINVERT = &H660046       ' (DWORD) dest = source XOR dest
Public Const SRCERASE = &H440328        ' (DWORD) dest = source AND (NOT dest )
Public Const NOTSRCCOPY = &H330008      ' (DWORD) dest = (NOT source)
Public Const NOTSRCERASE = &H1100A6     ' (DWORD) dest = (NOT src) AND (NOT dest)
Public Const MERGECOPY = &HC000CA       ' (DWORD) dest = (source AND pattern)
Public Const MERGEPAINT = &HBB0226      ' (DWORD) dest = (NOT source) OR dest
Public Const PATCOPY = &HF00021 ' (DWORD) dest = pattern
Public Const PATPAINT = &HFB0A09        ' (DWORD) dest = DPSnoo
Public Const PATINVERT = &H5A0049       ' (DWORD) dest = pattern XOR dest
Public Const DSTINVERT = &H550009       ' (DWORD) dest = (NOT dest)
Public Const BLACKNESS = &H42 ' (DWORD) dest = BLACK
Public Const WHITENESS = &HFF0062       ' (DWORD) dest = WHITE

Public Const GDI_ERROR = &HFFFF
Public Const HGDI_ERROR = &HFFFF

' Region Flags
Public Const ERRORAPI = 0
Public Const NULLREGION = 1
Public Const SIMPLEREGION = 2
Public Const COMPLEXREGION = 3

' CombineRgn() Styles
Public Const RGN_AND = 1
Public Const RGN_OR = 2
Public Const RGN_XOR = 3
Public Const RGN_DIFF = 4
Public Const RGN_COPY = 5
Public Const RGN_MIN = RGN_AND
Public Const RGN_MAX = RGN_COPY

' StretchBlt() Modes
Public Const BLACKONWHITE = 1
Public Const WHITEONBLACK = 2
Public Const COLORONCOLOR = 3
Public Const HALFTONE = 4
Public Const MAXSTRETCHBLTMODE = 4

' PolyFill() Modes
Public Const ALTERNATE = 1
Public Const WINDING = 2
Public Const POLYFILL_LAST = 2

' Text Alignment Options
Public Const TA_NOUPDATECP = 0
Public Const TA_UPDATECP = 1

Public Const TA_LEFT = 0
Public Const TA_RIGHT = 2
Public Const TA_CENTER = 6

Public Const TA_TOP = 0
Public Const TA_BOTTOM = 8
Public Const TA_BASELINE = 24
Public Const TA_MASK = (TA_BASELINE + TA_CENTER + TA_UPDATECP)

Public Const VTA_BASELINE = TA_BASELINE
Public Const VTA_LEFT = TA_BOTTOM
Public Const VTA_RIGHT = TA_TOP
Public Const VTA_CENTER = TA_CENTER
Public Const VTA_BOTTOM = TA_RIGHT
Public Const VTA_TOP = TA_LEFT

Public Const ETO_GRAYED = 1
Public Const ETO_OPAQUE = 2
Public Const ETO_CLIPPED = 4
#1048

Declare Function GetSecurityDescriptorControl Lib "advapi32.dll" Alias "GetSecurityDescriptorControl" (pSecurityDescriptor As SECURITY_DESCRIPTOR, pControl As Integer, lpdwRevision As Long) As Long
Declare Function SetSecurityDescriptorDacl Lib "advapi32.dll" Alias "SetSecurityDescriptorDacl" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal bDaclPresent As Long, pDacl As ACL, ByVal bDaclDefaulted As Long) As Long
Declare Function GetSecurityDescriptorDacl Lib "advapi32.dll" Alias "GetSecurityDescriptorDacl" (pSecurityDescriptor As SECURITY_DESCRIPTOR, lpbDaclPresent As Long, pDacl As ACL, lpbDaclDefaulted As Long) As Long
Declare Function SetSecurityDescriptorSacl Lib "advapi32.dll" Alias "SetSecurityDescriptorSacl" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal bSaclPresent As Long, pSacl As ACL, ByVal bSaclDefaulted As Long) As Long
Declare Function GetSecurityDescriptorSacl Lib "advapi32.dll" Alias "GetSecurityDescriptorSacl" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal lpbSaclPresent As Long, pSacl As ACL, ByVal lpbSaclDefaulted As Long) As Long
Declare Function SetSecurityDescriptorOwner Lib "advapi32.dll" Alias "SetSecurityDescriptorOwner" (pSecurityDescriptor As SECURITY_DESCRIPTOR, pOwner As Any, ByVal bOwnerDefaulted As Long) As Long
Declare Function GetSecurityDescriptorOwner Lib "advapi32.dll" Alias "GetSecurityDescriptorOwner" (pSecurityDescriptor As SECURITY_DESCRIPTOR, pOwner As Any, ByVal lpbOwnerDefaulted As Long) As Long
Declare Function SetSecurityDescriptorGroup Lib "advapi32.dll" Alias "SetSecurityDescriptorGroup" (pSecurityDescriptor As SECURITY_DESCRIPTOR, pGroup As Any, ByVal bGroupDefaulted As Long) As Long
Declare Function GetSecurityDescriptorGroup Lib "advapi32.dll" Alias "GetSecurityDescriptorGroup" (pSecurityDescriptor As SECURITY_DESCRIPTOR, pGroup As Any, ByVal lpbGroupDefaulted As Long) As Long
Declare Function CreatePrivateObjectSecurity Lib "advapi32.dll" Alias "CreatePrivateObjectSecurity" (ParentDescriptor As SECURITY_DESCRIPTOR, CreatorDescriptor As SECURITY_DESCRIPTOR, NewDescriptor As SECURITY_DESCRIPTOR, ByVal IsDirectoryObject As Long, ByVal Token As Long, GenericMapping As GENERIC_MAPPING) As Long
Declare Function SetPrivateObjectSecurity Lib "advapi32.dll" Alias "SetPrivateObjectSecurity" (ByVal SecurityInformation As Long, ModificationDescriptor As SECURITY_DESCRIPTOR, ObjectsSecurityDescriptor As SECURITY_DESCRIPTOR, GenericMapping As GENERIC_MAPPING, ByVal Token As Long) As Long
Declare Function GetPrivateObjectSecurity Lib "advapi32.dll" Alias "GetPrivateObjectSecurity" (ObjectDescriptor As SECURITY_DESCRIPTOR, ByVal SecurityInformation As Long, ResultantDescriptor As SECURITY_DESCRIPTOR, ByVal DescriptorLength As Long, ReturnLength As Long) As Long
Declare Function DestroyPrivateObjectSecurity Lib "advapi32.dll" Alias "DestroyPrivateObjectSecurity" (ObjectDescriptor As SECURITY_DESCRIPTOR) As Long
Declare Function MakeSelfRelativeSD Lib "advapi32.dll" Alias "MakeSelfRelativeSD" (pAbsoluteSecurityDescriptor As SECURITY_DESCRIPTOR, pSelfRelativeSecurityDescriptor As SECURITY_DESCRIPTOR, lpdwBufferLength As Long) As Long
Declare Function MakeAbsoluteSD Lib "advapi32.dll" Alias "MakeAbsoluteSD" (pSelfRelativeSecurityDescriptor As SECURITY_DESCRIPTOR, pAbsoluteSecurityDescriptor As SECURITY_DESCRIPTOR, lpdwAbsoluteSecurityDescriptorSize As Long, pDacl As ACL, lpdwDaclSize As Long, pSacl As ACL, lpdwSaclSize As Long, pOwner As Any, lpdwOwnerSize As Long, pPrimaryGroup As Any, lpdwPrimaryGroupSize As Long) As Long
Declare Function SetFileSecurity Lib "advapi32.dll" Alias "SetFileSecurityA" (ByVal lpFileName As String, ByVal SecurityInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR) As Long
Declare Function GetFileSecurity Lib "advapi32.dll" Alias "GetFileSecurityA" (ByVal lpFileName As String, ByVal RequestedInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal nLength As Long, lpnLengthNeeded As Long) As Long
Declare Function SetKernelObjectSecurity Lib "advapi32.dll" Alias "SetKernelObjectSecurity" (ByVal Handle As Long, ByVal SecurityInformation As Long, SecurityDescriptor As SECURITY_DESCRIPTOR) As Long
Declare Function FindFirstChangeNotification Lib "kernel32" Alias "FindFirstChangeNotificationA" (ByVal lpPathName As String, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long) As Long
Declare Function FindNextChangeNotification Lib "kernel32" Alias "FindNextChangeNotification" (ByVal hChangeHandle As Long) As Long
Declare Function FindCloseChangeNotification Lib "kernel32" Alias "FindCloseChangeNotification" (ByVal hChangeHandle As Long) As Long
Declare Function VirtualLock Lib "kernel32" Alias "VirtualLock" (lpAddress As Any, ByVal dwSize As Long) As Long
Declare Function VirtualUnlock Lib "kernel32" Alias "VirtualUnlock" (lpAddress As Any, ByVal dwSize As Long) As Long
Declare Function MapViewOfFileEx Lib "kernel32" Alias "MapViewOfFileEx" (ByVal hFileMappingObject As Long, ByVal dwDesiredAccess As Long, ByVal dwFileOffsetHigh As Long, ByVal dwFileOffsetLow As Long, ByVal dwNumberOfBytesToMap As Long, lpBaseAddress As Any) As Long
Declare Function SetPriorityClass Lib "kernel32" Alias "SetPriorityClass" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Declare Function GetPriorityClass Lib "kernel32" Alias "GetPriorityClass" (ByVal hProcess As Long) As Long

Type CONTEXT
FltF0 As Double
FltF1 As Double
FltF2 As Double
FltF3 As Double
FltF4 As Double
FltF5 As Double
FltF6 As Double
FltF7 As Double
FltF8 As Double
FltF9 As Double
FltF10 As Double
FltF11 As Double
FltF12 As Double
FltF13 As Double
FltF14 As Double
FltF15 As Double
FltF16 As Double
FltF17 As Double
FltF18 As Double
FltF19 As Double
FltF20 As Double
FltF21 As Double
FltF22 As Double
FltF23 As Double
FltF24 As Double
FltF25 As Double
FltF26 As Double
FltF27 As Double
FltF28 As Double
FltF29 As Double
FltF30 As Double
FltF31 As Double

IntV0 As Double
IntT0 As Double
IntT1 As Double
IntT2 As Double
IntT3 As Double
IntT4 As Double
IntT5 As Double
IntT6 As Double
IntT7 As Double
IntS0 As Double
IntS1 As Double
IntS2 As Double
IntS3 As Double
IntS4 As Double
IntS5 As Double
IntFp As Double
IntA0 As Double
IntA1 As Double
IntA2 As Double
IntA3 As Double
IntA4 As Double
IntA5 As Double
IntT8 As Double
IntT9 As Double
IntT10 As Double
IntT11 As Double
IntRa As Double
IntT12 As Double
IntAt As Double
IntGp As Double
IntSp As Double
IntZero As Double

Fpcr As Double
SoftFpcr As Double

Fir As Double
Psr As Long

ContextFlags As Long
Fill(4) As Long
End Type

Type EXCEPTION_POINTERS
    pExceptionRecord As EXCEPTION_RECORD
    ContextRecord As CONTEXT
End Type

Type LDT_BYTES ' Defined for use in LDT_ENTRY Type
BaseMid As Byte
Flags1 As Byte
Flags2 As Byte
BaseHi As Byte
End Type

Type LDT_ENTRY
LimitLow As Integer
BaseLow As Integer
HighWord As Long ' Can use LDT_BYTES Type
End Type

Declare Sub FatalExit Lib "kernel32" Alias "FatalExit" (ByVal code As Long)
Declare Function GetEnvironmentStrings Lib "kernel32" Alias "GetEnvironmentStringsA" () As String
Declare Sub RaiseException Lib "kernel32" Alias "RaiseException" (ByVal dwExceptionCode As Long, ByVal dwExceptionFlags As Long, ByVal nNumberOfArguments As Long, lpArguments As Long)
Declare Function UnhandledExceptionFilter Lib "kernel32" Alias "UnhandledExceptionFilter" (ExceptionInfo As EXCEPTION_POINTERS) As Long

Declare Function CreateThread Lib "kernel32" Alias "CreateThread" (lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal dwStackSize As Long, lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long
Declare Function CreateRemoteThread Lib "kernel32" Alias "CreateRemoteThread" (ByVal hProcess As Long, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal dwStackSize As Long, lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long
Declare Function GetCurrentThread Lib "kernel32" Alias "GetCurrentThread" () As Long
Declare Function GetCurrentThreadId Lib "kernel32" Alias "GetCurrentThreadId" () As Long
Declare Function SetThreadPriority Lib "kernel32" Alias "SetThreadPriority" (ByVal hThread As Long, ByVal nPriority As Long) As Long
Declare Function GetThreadPriority Lib "kernel32" Alias "GetThreadPriority" (ByVal hThread As Long) As Long
Declare Function GetThreadTimes Lib "kernel32" Alias "GetThreadTimes" (ByVal hThread As Long, lpCreationTime As FILETIME, lpExitTime As FILETIME, lpKernelTime As FILETIME, lpUserTime As FILETIME) As Long
Declare Sub ExitThread Lib "kernel32" Alias "ExitThread" (ByVal dwExitCode As Long)
Declare Function TerminateThread Lib "kernel32" Alias "TerminateThread" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
Declare Function GetExitCodeThread Lib "kernel32" Alias "GetExitCodeThread" (ByVal hThread As Long, lpExitCode As Long) As Long
Declare Function GetThreadSelectorEntry Lib "kernel32" Alias "GetThreadSelectorEntry" (ByVal hThread As Long, ByVal dwSelector As Long, lpSelectorEntry As LDT_ENTRY) As Long

' COMM declarations
Declare Function SetCommState Lib "kernel32" Alias "SetCommState" (ByVal hCommDev As Long, lpDCB As DCB) As Long
Declare Function SetCommTimeouts Lib "kernel32" Alias "SetCommTimeouts" (ByVal hFile As Long, lpCommTimeouts As COMMTIMEOUTS) As Long
Declare Function GetCommState Lib "kernel32" Alias "GetCommState" (ByVal nCid As Long, lpDCB As DCB) As Long
Declare Function GetCommTimeouts Lib "kernel32" Alias "GetCommTimeouts" (ByVal hFile As Long, lpCommTimeouts As COMMTIMEOUTS) As Long
Declare Function PurgeComm Lib "kernel32" Alias "PurgeComm" (ByVal hFile As Long, ByVal dwFlags As Long) As Long
Declare Function BuildCommDCB Lib "kernel32" Alias "BuildCommDCBA" (ByVal lpDef As String, lpDCB As DCB) As Long
Declare Function BuildCommDCBAndTimeouts Lib "kernel32" Alias "BuildCommDCBAndTimeoutsA" (ByVal lpDef As String, lpDCB As DCB, lpCommTimeouts As COMMTIMEOUTS) As Long
Declare Function TransmitCommChar Lib "kernel32" Alias "TransmitCommChar" (ByVal nCid As Long, ByVal cChar As Byte) As Long
Declare Function SetCommBreak Lib "kernel32" Alias "SetCommBreak" (ByVal nCid As Long) As Long
Declare Function SetCommMask Lib "kernel32" Alias "SetCommMask" (ByVal hFile As Long, ByVal dwEvtMask As Long) As Long
Declare Function ClearCommBreak Lib "kernel32" Alias "ClearCommBreak" (ByVal nCid As Long) As Long
Declare Function ClearCommError Lib "kernel32" Alias "ClearCommError" (ByVal hFile As Long, lpErrors As Long, lpStat As COMSTAT) As Long
Declare Function SetupComm Lib "kernel32" Alias "SetupComm" (ByVal hFile As Long, ByVal dwInQueue As Long, ByVal dwOutQueue As Long) As Long
Declare Function EscapeCommFunction Lib "kernel32" Alias "EscapeCommFunction" (ByVal nCid As Long, ByVal nFunc As Long) As Long
Declare Function GetCommMask Lib "kernel32" Alias "GetCommMask" (ByVal hFile As Long, lpEvtMask As Long) As Long
Declare Function GetCommProperties Lib "kernel32" Alias "GetCommProperties" (ByVal hFile As Long, lpCommProp As COMMPROP) As Long
Declare Function GetCommModemStatus Lib "kernel32" Alias "GetCommModemStatus" (ByVal hFile As Long, lpModemStat As Long) As Long
Declare Function WaitCommEvent Lib "kernel32" Alias "WaitCommEvent" (ByVal hFile As Long, lpEvtMask As Long, lpOverlapped As OVERLAPPED) As Long

Declare Function SetTapePosition Lib "kernel32" Alias "SetTapePosition" (ByVal hDevice As Long, ByVal dwPositionMethod As Long, ByVal dwPartition As Long, ByVal dwOffsetLow As Long, ByVal dwOffsetHigh As Long, ByVal bimmediate As Long) As Long
Declare Function GetTapePosition Lib "kernel32" Alias "GetTapePosition" (ByVal hDevice As Long, ByVal dwPositionType As Long, lpdwPartition As Long, lpdwOffsetLow As Long, lpdwOffsetHigh As Long) As Long
Declare Function PrepareTape Lib "kernel32" Alias "PrepareTape" (ByVal hDevice As Long, ByVal dwOperation As Long, ByVal bimmediate As Long) As Long
Declare Function EraseTape Lib "kernel32" Alias "EraseTape" (ByVal hDevice As Long, ByVal dwEraseType As Long, ByVal bimmediate As Long) As Long
Declare Function CreateTapePartition Lib "kernel32" Alias "CreateTapePartition" (ByVal hDevice As Long, ByVal dwPartitionMethod As Long, ByVal dwCount As Long, ByVal dwSize As Long) As Long
Declare Function WriteTapemark Lib "kernel32" Alias "WriteTapemark" (ByVal hDevice As Long, ByVal dwTapemarkType As Long, ByVal dwTapemarkCount As Long, ByVal bimmediate As Long) As Long
Declare Function GetTapeStatus Lib "kernel32" Alias "GetTapeStatus" (ByVal hDevice As Long) As Long
Declare Function GetTapeParameters Lib "kernel32" Alias "GetTapeParameters" (ByVal hDevice As Long, ByVal dwOperation As Long, lpdwSize As Long, lpTapeInformation As Any) As Long

Public Const GET_TAPE_MEDIA_INFORMATION = 0
Public Const GET_TAPE_DRIVE_INFORMATION = 1

Declare Function SetTapeParameters Lib "kernel32" Alias "SetTapeParameters" (ByVal hDevice As Long, ByVal dwOperation As Long, lpTapeInformation As Any) As Long

Public Const SET_TAPE_MEDIA_INFORMATION = 0
Public Const SET_TAPE_DRIVE_INFORMATION = 1

Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Declare Function MulDiv Lib "kernel32" Alias "MulDiv" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long

Declare Sub GetSystemTime Lib "kernel32" Alias "GetSystemTime" (lpSystemTime As SYSTEMTIME)
Declare Function SetSystemTime Lib "kernel32" Alias "SetSystemTime" (lpSystemTime As SYSTEMTIME) As Long
Declare Sub GetLocalTime Lib "kernel32" Alias "GetLocalTime" (lpSystemTime As SYSTEMTIME)
Declare Function SetLocalTime Lib "kernel32" Alias "SetLocalTime" (lpSystemTime As SYSTEMTIME) As Long
Declare Sub GetSystemInfo Lib "kernel32" Alias "GetSystemInfo" (lpSystemInfo As SYSTEM_INFO)

Type TIME_ZONE_INFORMATION
        Bias As Long
        StandardName(32) As Integer
        StandardDate As SYSTEMTIME
        StandardBias As Long
        DaylightName(32) As Integer
        DaylightDate As SYSTEMTIME
        DaylightBias As Long
End Type

Declare Function GetTimeZoneInformation Lib "kernel32" Alias "GetTimeZoneInformation" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Declare Function SetTimeZoneInformation Lib "kernel32" Alias "SetTimeZoneInformation" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

' Routines to convert back and forth
' between system time and file time

Declare Function SystemTimeToFileTime Lib "kernel32" Alias "SystemTimeToFileTime" (lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long
Declare Function FileTimeToLocalFileTime Lib "kernel32" Alias "FileTimeToLocalFileTime" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long
Declare Function LocalFileTimeToFileTime Lib "kernel32" Alias "LocalFileTimeToFileTime" (lpLocalFileTime As FILETIME, lpFileTime As FILETIME) As Long
Declare Function FileTimeToSystemTime Lib "kernel32" Alias "FileTimeToSystemTime" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Declare Function CompareFileTime Lib "kernel32" Alias "CompareFileTime" (lpFileTime1 As FILETIME, lpFileTime2 As FILETIME) As Long
Declare Function FileTimeToDosDateTime Lib "kernel32" Alias "FileTimeToDosDateTime" (lpFileTime As FILETIME, ByVal lpFatDate As Long, ByVal lpFatTime As Long) As Long
Declare Function DosDateTimeToFileTime Lib "kernel32" Alias "DosDateTimeToFileTime" (ByVal wFatDate As Long, ByVal wFatTime As Long, lpFileTime As FILETIME) As Long
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long

Public Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100
Public Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200
Public Const FORMAT_MESSAGE_FROM_STRING = &H400
Public Const FORMAT_MESSAGE_FROM_HMODULE = &H800
Public Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Public Const FORMAT_MESSAGE_ARGUMENT_ARRAY = &H2000
Public Const FORMAT_MESSAGE_MAX_WIDTH_MASK = &HFF

Declare Function CreatePipe Lib "kernel32" Alias "CreatePipe" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As SECURITY_ATTRIBUTES, ByVal nSize As Long) As Long
Declare Function ConnectNamedPipe Lib "kernel32" Alias "ConnectNamedPipe" (ByVal hNamedPipe As Long, lpOverlapped As OVERLAPPED) As Long
Declare Function DisconnectNamedPipe Lib "kernel32" Alias "DisconnectNamedPipe" (ByVal hNamedPipe As Long) As Long
Declare Function SetNamedPipeHandleState Lib "kernel32" Alias "SetNamedPipeHandleState" (ByVal hNamedPipe As Long, lpMode As Long, lpMaxCollectionCount As Long, lpCollectDataTimeout As Long) As Long
Declare Function GetNamedPipeInfo Lib "kernel32" Alias "GetNamedPipeInfo" (ByVal hNamedPipe As Long, lpFlags As Long, lpOutBufferSize As Long, lpInBufferSize As Long, lpMaxInstances As Long) As Long
Declare Function PeekNamedPipe Lib "kernel32" Alias "PeekNamedPipe" (ByVal hNamedPipe As Long, lpBuffer As Any, ByVal nBufferSize As Long, lpBytesRead As Long, lpTotalBytesAvail As Long, lpBytesLeftThisMessage As Long) As Long
Declare Function TransactNamedPipe Lib "kernel32" Alias "TransactNamedPipe" (ByVal hNamedPipe As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesRead As Long, lpOverlapped As OVERLAPPED) As Long

Declare Function CreateMailslot Lib "kernel32" Alias "CreateMailslotA" (ByVal lpName As String, ByVal nMaxMessageSize As Long, ByVal lReadTimeout As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Declare Function GetMailslotInfo Lib "kernel32" Alias "GetMailslotInfo" (ByVal hMailslot As Long, lpMaxMessageSize As Long, lpNextSize As Long, lpMessageCount As Long, lpReadTimeout As Long) As Long
Declare Function SetMailslotInfo Lib "kernel32" Alias "SetMailslotInfo" (ByVal hMailslot As Long, ByVal lReadTimeout As Long) As Long
Declare Function MapViewOfFile Lib "kernel32" Alias "MapViewOfFile" (ByVal hFileMappingObject As Long, ByVal dwDesiredAccess As Long, ByVal dwFileOffsetHigh As Long, ByVal dwFileOffsetLow As Long, ByVal dwNumberOfBytesToMap As Long) As Long
Declare Function FlushViewOfFile Lib "kernel32" Alias "FlushViewOfFile" (lpBaseAddress As Any, ByVal dwNumberOfBytesToFlush As Long) As Long
Declare Function UnmapViewOfFile Lib "kernel32" Alias "UnmapViewOfFile" (lpBaseAddress As Any) As Long

Declare Function lstrcmp Lib "kernel32" Alias "lstrcmpA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Declare Function lstrcmpi Lib "kernel32" Alias "lstrcmpiA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long

Declare Function lopen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Declare Function lclose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long) As Long
Declare Function lcreat Lib "kernel32" Alias "_lcreat" (ByVal lpPathName As String, ByVal iAttribute As Long) As Long
Declare Function llseek Lib "kernel32" Alias "_llseek" (ByVal hFile As Long, ByVal lOffset As Long, ByVal iOrigin As Long) As Long
Declare Function lread Lib "kernel32" Alias "_lread" (ByVal hFile As Long, lpBuffer As Any, ByVal wBytes As Long) As Long
Declare Function lwrite Lib "kernel32" Alias "_lwrite" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal wBytes As Long) As Long

Declare Function hread Lib "kernel32" Alias "_hread" (ByVal hFile As Long, lpBuffer As Any, ByVal lBytes As Long) As Long
Declare Function hwrite Lib "kernel32" Alias "_hwrite" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal lBytes As Long) As Long

Declare Function TlsAlloc Lib "kernel32" Alias "TlsAlloc" () As Long

Public Const TLS_OUT_OF_INDEXES = &HFFFF

Declare Function TlsGetValue Lib "kernel32" Alias "TlsGetValue" (ByVal dwTlsIndex As Long) As Long
Declare Function TlsSetValue Lib "kernel32" Alias "TlsSetValue" (ByVal dwTlsIndex As Long, lpTlsValue As Any) As Long
Declare Function TlsFree Lib "kernel32" Alias "TlsFree" (ByVal dwTlsIndex As Long) As Long
Declare Function SleepEx Lib "kernel32" Alias "SleepEx" (ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long
Declare Function WaitForSingleObjectEx Lib "kernel32" Alias "WaitForSingleObjectEx" (ByVal hHandle As Long, ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long
Declare Function WaitForMultipleObjectsEx Lib "kernel32" Alias "WaitForMultipleObjectsEx" (ByVal nCount As Long, lpHandles As Long, ByVal bWaitAll As Long, ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long
Declare Function BackupRead Lib "kernel32" Alias "BackupRead" (ByVal hFile As Long, lpBuffer As Byte, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal bAbort As Long, ByVal bProcessSecurity As Long, lpContext As Any) As Long
Declare Function BackupSeek Lib "kernel32" Alias "BackupSeek" (ByVal hFile As Long, ByVal dwLowBytesToSeek As Long, ByVal dwHighBytesToSeek As Long, lpdwLowByteSeeked As Long, lpdwHighByteSeeked As Long, lpContext As Long) As Long
Declare Function BackupWrite Lib "kernel32" Alias "BackupWrite" (ByVal hFile As Long, lpBuffer As Byte, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal bAbort As Long, ByVal bProcessSecurity As Long, lpContext As Long) As Long

' Stream ID type
Type WIN32_STREAM_ID
        dwStreamID As Long
        dwStreamAttributes As Long
        dwStreamSizeLow As Long
        dwStreamSizeHigh As Long
        dwStreamNameSize As Long
        cStreamName As Byte
End Type

' Stream IDs
Public Const BACKUP_DATA = &H1
Public Const BACKUP_EA_DATA = &H2
Public Const BACKUP_SECURITY_DATA = &H3
Public Const BACKUP_ALTERNATE_DATA = &H4
Public Const BACKUP_LINK = &H5

'   Stream Attributes
Public Const STREAM_MODIFIED_WHEN_READ = &H1
Public Const STREAM_CONTAINS_SECURITY = &H2

'  Dual Mode API below this line. Dual Mode Types also included.

Public Const STARTF_USESHOWWINDOW = &H1
Public Const STARTF_USESIZE = &H2
Public Const STARTF_USEPOSITION = &H4
Public Const STARTF_USECOUNTCHARS = &H8
Public Const STARTF_USEFILLATTRIBUTE = &H10
Public Const STARTF_RUNFULLSCREEN = &H20        '  ignored for non-x86 platforms
Public Const STARTF_FORCEONFEEDBACK = &H40
Public Const STARTF_FORCEOFFFEEDBACK = &H80
Public Const STARTF_USESTDHANDLES = &H100

Type STARTUPINFO
        cb As Long
        lpReserved As String
        lpDesktop As String
        lpTitle As String
        dwX As Long
        dwY As Long
        dwXSize As Long
        dwYSize As Long
        dwXCountChars As Long
        dwYCountChars As Long
        dwFillAttribute As Long
        dwFlags As Long
        wShowWindow As Integer
        cbReserved2 As Integer
        lpReserved2 As Byte
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
End Type

Public Const SHUTDOWN_NORETRY = &H1

Type WIN32_FIND_DATA
        dwFileAttributes As Long
        ftCreationTime As FILETIME
        ftLastAccessTime As FILETIME
        ftLastWriteTime As FILETIME
        nFileSizeHigh As Long
        nFileSizeLow As Long
        dwReserved0 As Long
        dwReserved1 As Long
        cFileName As String * MAX_PATH
        cAlternate As String * 14
End Type

Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (lpMutexAttributes As SECURITY_ATTRIBUTES, ByVal bInitialOwner As Long, ByVal lpName As String) As Long
Declare Function OpenMutex Lib "kernel32" Alias "OpenMutexA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA" (lpEventAttributes As SECURITY_ATTRIBUTES, ByVal bManualReset As Long, ByVal bInitialState As Long, ByVal lpName As String) As Long
Declare Function OpenEvent Lib "kernel32" Alias "OpenEventA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Declare Function CreateSemaphore Lib "kernel32" Alias "CreateSemaphoreA" (lpSemaphoreAttributes As SECURITY_ATTRIBUTES, ByVal lInitialCount As Long, ByVal lMaximumCount As Long, ByVal lpName As String) As Long
Declare Function OpenSemaphore Lib "kernel32" Alias "OpenSemaphoreA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Declare Function CreateFileMapping Lib "kernel32" Alias "CreateFileMappingA" (ByVal hFile As Long, lpFileMappigAttributes As SECURITY_ATTRIBUTES, ByVal flProtect As Long, ByVal dwMaximumSizeHigh As Long, ByVal dwMaximumSizeLow As Long, ByVal lpName As String) As Long
Declare Function OpenFileMapping Lib "kernel32" Alias "OpenFileMappingA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Declare Function IsBadReadPtr Lib "kernel32" Alias "IsBadReadPtr" (lp As Any, ByVal ucb As Long) As Long
Declare Function IsBadWritePtr Lib "kernel32" Alias "IsBadWritePtr" (lp As Any, ByVal ucb As Long) As Long
Declare Function IsBadStringPtr Lib "kernel32" Alias "IsBadStringPtrA" (ByVal lpsz As String, ByVal ucchMax As Long) As Long
Declare Function IsBadHugeReadPtr Lib "kernel32" Alias "IsBadHugeReadPtr" (lp As Any, ByVal ucb As Long) As Long
Declare Function IsBadHugeWritePtr Lib "kernel32" Alias "IsBadHugeWritePtr" (lp As Any, ByVal ucb As Long) As Long

Declare Function LookupAccountSid Lib "advapi32.dll" Alias "LookupAccountSidA" (ByVal lpSystemName As String, Sid As Any, ByVal name As String, cbName As Long, ByVal ReferencedDomainName As String, cbReferencedDomainName As Long, peUse As Integer) As Long

Declare Function LookupAccountName Lib "advapi32.dll" Alias "LookupAccountNameA" (ByVal lpSystemName As String, ByVal lpAccountName As String, Sid As Long, cbSid As Long, ByVal ReferencedDomainName As String, cbReferencedDomainName As Long, peUse As Integer) As Long
Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LARGE_INTEGER) As Long
Declare Function LookupPrivilegeName Lib "advapi32.dll" Alias "LookupPrivilegeNameA" (ByVal lpSystemName As String, lpLuid As LARGE_INTEGER, ByVal lpName As String, cbName As Long) As Long
Declare Function LookupPrivilegeDisplayName Lib "advapi32.dll" Alias "LookupPrivilegeDisplayNameA" (ByVal lpSystemName As String, ByVal lpName As String, ByVal lpDisplayName As String, cbDisplayName As Long, lpLanguageID As Long) As Long
Declare Function AllocateLocallyUniqueId Lib "advapi32.dll" Alias "AllocateLocallyUniqueId" (Luid As LARGE_INTEGER) As Long

Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

' Performance counter API's
Declare Function QueryPerformanceCounter Lib "kernel32" Alias "QueryPerformanceCounter" (lpPerformanceCount As LARGE_INTEGER) As Long
Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long

'  Abnormal termination codes
Public Const TC_NORMAL = 0
Public Const TC_HARDERR = 1
Public Const TC_GP_TRAP = 2
Public Const TC_SIGNAL = 3


' Procedure declarations, constant definitions, and macros
' for the NLS component

' String Length Maximums
Public Const MAX_LEADBYTES = 12  '  5 ranges, 2 bytes ea., 0 term.

' MBCS and Unicode Translation Flags.

Public Const MB_PRECOMPOSED = &H1         '  use precomposed chars
Public Const MB_COMPOSITE = &H2         '  use composite chars
Public Const MB_USEGLYPHCHARS = &H4         '  use glyph chars, not ctrl chars

Public Const WC_DEFAULTCHECK = &H100       '  check for default char
Public Const WC_COMPOSITECHECK = &H200       '  convert composite to precomposed
Public Const WC_DISCARDNS = &H10        '  discard non-spacing chars
Public Const WC_SEPCHARS = &H20        '  generate separate chars
Public Const WC_DEFAULTCHAR = &H40        '  replace w/ default char

' Character Type Flags.
Public Const CT_CTYPE1 = &H1         '  ctype 1 information
Public Const CT_CTYPE2 = &H2         '  ctype 2 information
Public Const CT_CTYPE3 = &H4         '  ctype 3 information

' CType 1 Flag Bits.
Public Const C1_UPPER = &H1     '  upper case
Public Const C1_LOWER = &H2     '  lower case
Public Const C1_DIGIT = &H4     '  decimal digits
Public Const C1_SPACE = &H8     '  spacing characters
Public Const C1_PUNCT = &H10    '  punctuation characters
Public Const C1_CNTRL = &H20    '  control characters
Public Const C1_BLANK = &H40    '  blank characters
Public Const C1_XDIGIT = &H80    '  other digits
Public Const C1_ALPHA = &H100   '  any letter

' CType 2 Flag Bits.

Public Const C2_LEFTTORIGHT = &H1     '  left to right
Public Const C2_RIGHTTOLEFT = &H2     '  right to left

Public Const C2_EUROPENUMBER = &H3     '  European number, digit
Public Const C2_EUROPESEPARATOR = &H4     '  European numeric separator
Public Const C2_EUROPETERMINATOR = &H5     '  European numeric terminator
Public Const C2_ARABICNUMBER = &H6     '  Arabic number
Public Const C2_COMMONSEPARATOR = &H7     '  common numeric separator

Public Const C2_BLOCKSEPARATOR = &H8     '  block separator
Public Const C2_SEGMENTSEPARATOR = &H9     '  segment separator
Public Const C2_WHITESPACE = &HA     '  white space
Public Const C2_OTHERNEUTRAL = &HB     '  other neutrals

Public Const C2_NOTAPPLICABLE = &H0     '  no implicit directionality

' CType 3 Flag Bits.
Public Const C3_NONSPACING = &H1     '  nonspacing character
Public Const C3_DIACRITIC = &H2     '  diacritic mark
Public Const C3_VOWELMARK = &H4     '  vowel mark
Public Const C3_SYMBOL = &H8     '  symbols

Public Const C3_NOTAPPLICABLE = &H0     '  ctype 3 is not applicable

' String Flags.
Public Const NORM_IGNORECASE = &H1         '  ignore case
Public Const NORM_IGNORENONSPACE = &H2         '  ignore nonspacing chars
Public Const NORM_IGNORESYMBOLS = &H4         '  ignore symbols

' Locale Independent Mapping Flags.
Public Const MAP_FOLDCZONE = &H10        '  fold compatibility zone chars
Public Const MAP_PRECOMPOSED = &H20        '  convert to precomposed chars
Public Const MAP_COMPOSITE = &H40        '  convert to composite chars
Public Const MAP_FOLDDIGITS = &H80        '  all digits to ASCII 0-9

' Locale Dependent Mapping Flags.
Public Const LCMAP_LOWERCASE = &H100       '  lower case letters
Public Const LCMAP_UPPERCASE = &H200       '  upper case letters
Public Const LCMAP_SORTKEY = &H400       '  WC sort key (normalize)
Public Const LCMAP_BYTEREV = &H800       '  byte reversal

' Sorting Flags.
Public Const SORT_STRINGSORT = &H1000      '  use string sort method

' Code Page Default Values.
Public Const CP_ACP = 0  '  default to ANSI code page
Public Const CP_OEMCP = 1  '  default to OEM  code page

' Country Codes.

Public Const CTRY_DEFAULT = 0

Public Const CTRY_AUSTRALIA = 61  '  Australia
Public Const CTRY_AUSTRIA = 43  '  Austria
Public Const CTRY_BELGIUM = 32  '  Belgium
Public Const CTRY_BRAZIL = 55  '  Brazil
Public Const CTRY_CANADA = 2  '  Canada
Public Const CTRY_DENMARK = 45  '  Denmark
Public Const CTRY_FINLAND = 358  '  Finland
Public Const CTRY_FRANCE = 33  '  France
Public Const CTRY_GERMANY = 49  '  Germany
Public Const CTRY_ICELAND = 354  '  Iceland
Public Const CTRY_IRELAND = 353  '  Ireland
Public Const CTRY_ITALY = 39  '  Italy
Public Const CTRY_JAPAN = 81  '  Japan
Public Const CTRY_MEXICO = 52  '  Mexico
Public Const CTRY_NETHERLANDS = 31  '  Netherlands
Public Const CTRY_NEW_ZEALAND = 64  '  New Zealand
Public Const CTRY_NORWAY = 47  '  Norway
Public Const CTRY_PORTUGAL = 351  '  Portugal
Public Const CTRY_PRCHINA = 86  '  PR China
Public Const CTRY_SOUTH_KOREA = 82  '  South Korea
Public Const CTRY_SPAIN = 34  '  Spain
Public Const CTRY_SWEDEN = 46  '  Sweden
Public Const CTRY_SWITZERLAND = 41  '  Switzerland
Public Const CTRY_TAIWAN = 886  '  Taiwan
Public Const CTRY_UNITED_KINGDOM = 44  '  United Kingdom
Public Const CTRY_UNITED_STATES = 1  '  United States

' Locale Types.
' These types are used for the GetLocaleInfoW NLS API routine.
#1049
Public Const EV_RXCHAR = &H1                '  Any Character received
Public Const EV_RXFLAG = &H2                '  Received certain character
Public Const EV_TXEMPTY = &H4               '  Transmitt Queue Empty
Public Const EV_CTS = &H8                   '  CTS changed state
Public Const EV_DSR = &H10                  '  DSR changed state
Public Const EV_RLSD = &H20                 '  RLSD changed state
Public Const EV_BREAK = &H40                '  BREAK received
Public Const EV_ERR = &H80                  '  Line status error occurred
Public Const EV_RING = &H100                '  Ring signal detected
Public Const EV_PERR = &H200                '  Printer error occured
Public Const EV_RX80FULL = &H400            '  Receive buffer is 80 percent full
Public Const EV_EVENT1 = &H800              '  Provider specific event 1
Public Const EV_EVENT2 = &H1000             '  Provider specific event 2

' Escape Functions
Public Const SETXOFF = 1  '  Simulate XOFF received
Public Const SETXON = 2 '  Simulate XON received
Public Const SETRTS = 3 '  Set RTS high
Public Const CLRRTS = 4 '  Set RTS low
Public Const SETDTR = 5 '  Set DTR high
Public Const CLRDTR = 6 '  Set DTR low
Public Const RESETDEV = 7       '  Reset device if possible
Public Const SETBREAK = 8  'Set the device break line
Public Const CLRBREAK = 9 ' Clear the device break line

'  PURGE function flags.
Public Const PURGE_TXABORT = &H1     '  Kill the pending/current writes to the comm port.
Public Const PURGE_RXABORT = &H2     '  Kill the pending/current reads to the comm port.
Public Const PURGE_TXCLEAR = &H4     '  Kill the transmit queue if there.
Public Const PURGE_RXCLEAR = &H8     '  Kill the typeahead buffer if there.

Public Const LPTx = &H80        '  Set if ID is for LPT device

'  Modem Status Flags
Public Const MS_CTS_ON = &H10&
Public Const MS_DSR_ON = &H20&
Public Const MS_RING_ON = &H40&
Public Const MS_RLSD_ON = &H80&

' WaitSoundState() Constants
Public Const S_QUEUEEMPTY = 0
Public Const S_THRESHOLD = 1
Public Const S_ALLTHRESHOLD = 2

' Accent Modes
Public Const S_NORMAL = 0
Public Const S_LEGATO = 1
Public Const S_STACCATO = 2

' SetSoundNoise() Sources
Public Const S_PERIOD512 = 0    '  Freq = N/512 high pitch, less coarse hiss
Public Const S_PERIOD1024 = 1   '  Freq = N/1024
Public Const S_PERIOD2048 = 2   '  Freq = N/2048 low pitch, more coarse hiss
Public Const S_PERIODVOICE = 3  '  Source is frequency from voice channel (3)
Public Const S_WHITE512 = 4     '  Freq = N/512 high pitch, less coarse hiss
Public Const S_WHITE1024 = 5    '  Freq = N/1024
Public Const S_WHITE2048 = 6    '  Freq = N/2048 low pitch, more coarse hiss
Public Const S_WHITEVOICE = 7   '  Source is frequency from voice channel (3)

Public Const S_SERDVNA = (-1)   '  Device not available
Public Const S_SEROFM = (-2)    '  Out of memory
Public Const S_SERMACT = (-3)   '  Music active
Public Const S_SERQFUL = (-4)   '  Queue full
Public Const S_SERBDNT = (-5)   '  Invalid note
Public Const S_SERDLN = (-6)    '  Invalid note length
Public Const S_SERDCC = (-7)    '  Invalid note count
Public Const S_SERDTP = (-8)    '  Invalid tempo
Public Const S_SERDVL = (-9)    '  Invalid volume
Public Const S_SERDMD = (-10)   '  Invalid mode
Public Const S_SERDSH = (-11)   '  Invalid shape
Public Const S_SERDPT = (-12)   '  Invalid pitch
Public Const S_SERDFQ = (-13)   '  Invalid frequency
Public Const S_SERDDR = (-14)   '  Invalid duration
Public Const S_SERDSR = (-15)   '  Invalid source
Public Const S_SERDST = (-16)   '  Invalid state

Public Const NMPWAIT_WAIT_FOREVER = &HFFFF
Public Const NMPWAIT_NOWAIT = &H1
Public Const NMPWAIT_USE_DEFAULT_WAIT = &H0
Public Const FS_CASE_IS_PRESERVED = FILE_CASE_PRESERVED_NAMES
Public Const FS_CASE_SENSITIVE = FILE_CASE_SENSITIVE_SEARCH
Public Const FS_UNICODE_STORED_ON_DISK = FILE_UNICODE_ON_DISK
Public Const FS_PERSISTENT_ACLS = FILE_PERSISTENT_ACLS

Public Const SECTION_QUERY = &H1
Public Const SECTION_MAP_WRITE = &H2
Public Const SECTION_MAP_READ = &H4
Public Const SECTION_MAP_EXECUTE = &H8
Public Const SECTION_EXTEND_SIZE = &H10
Public Const SECTION_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED Or SECTION_QUERY Or SECTION_MAP_WRITE Or SECTION_MAP_READ Or SECTION_MAP_EXECUTE Or SECTION_EXTEND_SIZE

Public Const FILE_MAP_COPY = SECTION_QUERY
Public Const FILE_MAP_WRITE = SECTION_MAP_WRITE
Public Const FILE_MAP_READ = SECTION_MAP_READ
Public Const FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS

' OpenFile() Flags
Public Const OF_READ = &H0
Public Const OF_WRITE = &H1
Public Const OF_READWRITE = &H2
Public Const OF_SHARE_COMPAT = &H0
Public Const OF_SHARE_EXCLUSIVE = &H10
Public Const OF_SHARE_DENY_WRITE = &H20
Public Const OF_SHARE_DENY_READ = &H30
Public Const OF_SHARE_DENY_NONE = &H40
Public Const OF_PARSE = &H100
Public Const OF_DELETE = &H200
Public Const OF_VERIFY = &H400
Public Const OF_CANCEL = &H800
Public Const OF_CREATE = &H1000
Public Const OF_PROMPT = &H2000
Public Const OF_EXIST = &H4000
Public Const OF_REOPEN = &H8000

Public Const OFS_MAXPATHNAME = 128

' OpenFile() Structure
Type OFSTRUCT
        cBytes As Byte
        fFixedDisk As Byte
        nErrCode As Integer
        Reserved1 As Integer
        Reserved2 As Integer
        szPathName(OFS_MAXPATHNAME) As Byte
End Type

Declare Function InterlockedIncrement Lib "kernel32" Alias "InterlockedIncrement" (lpAddend As Long) As Long
Declare Function InterlockedDecrement Lib "kernel32" Alias "InterlockedDecrement" (lpAddend As Long) As Long
Declare Function InterlockedExchange Lib "kernel32" Alias "InterlockedExchange" (Target As Long, ByVal Value As Long) As Long

' Loader Routines
Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long

Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Declare Function SetProcessShutdownParameters Lib "kernel32" Alias "SetProcessShutdownParameters" (ByVal dwLevel As Long, ByVal dwFlags As Long) As Long
Declare Function GetProcessShutdownParameters Lib "kernel32" Alias "GetProcessShutdownParameters" (lpdwLevel As Long, lpdwFlags As Long) As Long

Declare Sub FatalAppExit Lib "kernel32" Alias "FatalAppExitA" (ByVal uAction As Long, ByVal lpMessageText As String)
Declare Sub GetStartupInfo Lib "kernel32" Alias "GetStartupInfoA" (lpStartupInfo As STARTUPINFO)
Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA" () As String
Declare Function GetEnvironmentVariable Lib "kernel32" Alias "GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function SetEnvironmentVariable Lib "kernel32" Alias "SetEnvironmentVariableA" (ByVal lpName As String, ByVal lpValue As String) As Long
Declare Function ExpandEnvironmentStrings Lib "kernel32" Alias "ExpandEnvironmentStringsA" (ByVal lpSrc As String, ByVal lpDst As String, ByVal nSize As Long) As Long

Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Declare Function LoadLibraryEx Lib "kernel32" Alias "LoadLibraryExA" (ByVal lpLibFileName As String, ByVal hFile As Long, ByVal dwFlags As Long) As Long

Public Const DONT_RESOLVE_DLL_REFERENCES = &H1

Declare Function LoadModule Lib "kernel32" Alias "LoadModule" (ByVal lpModuleName As String, lpParameterBlock As Any) As Long
Declare Function FreeLibrary Lib "kernel32" Alias "FreeLibrary" (ByVal hLibModule As Long) As Long
Declare Function WinExec Lib "kernel32" Alias "WinExec" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long

Declare Sub DebugBreak Lib "kernel32" Alias "DebugBreak" ()
Declare Function ContinueDebugEvent Lib "kernel32" Alias "ContinueDebugEvent" (ByVal dwProcessId As Long, ByVal dwThreadId As Long, ByVal dwContinueStatus As Long) As Long
Declare Function DebugActiveProcess Lib "kernel32" Alias "DebugActiveProcess" (ByVal dwProcessId As Long) As Long

Type CRITICAL_SECTION
dummy As Long
End Type

Declare Sub InitializeCriticalSection Lib "kernel32" Alias "InitializeCriticalSection" (lpCriticalSection As CRITICAL_SECTION)

Declare Sub EnterCriticalSection Lib "kernel32" Alias "EnterCriticalSection" (lpCriticalSection As CRITICAL_SECTION)
Declare Sub LeaveCriticalSection Lib "kernel32" Alias "LeaveCriticalSection" (lpCriticalSection As CRITICAL_SECTION)
Declare Sub DeleteCriticalSection Lib "kernel32" Alias "DeleteCriticalSection" (lpCriticalSection As CRITICAL_SECTION)
Declare Function SetEvent Lib "kernel32" Alias "SetEvent" (ByVal hEvent As Long) As Long
Declare Function ResetEvent Lib "kernel32" Alias "ResetEvent" (ByVal hEvent As Long) As Long
Declare Function PulseEvent Lib "kernel32" Alias "PulseEvent" (ByVal hEvent As Long) As Long
Declare Function ReleaseSemaphore Lib "kernel32" Alias "ReleaseSemaphore" (ByVal hSemaphore As Long, ByVal lReleaseCount As Long, lpPreviousCount As Long) As Long
Declare Function ReleaseMutex Lib "kernel32" Alias "ReleaseMutex" (ByVal hMutex As Long) As Long
Declare Function WaitForSingleObject Lib "kernel32" Alias "WaitForSingleObject" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Declare Function WaitForMultipleObjects Lib "kernel32" Alias "WaitForMultipleObjects" (ByVal nCount As Long, lpHandles As Long, ByVal bWaitAll As Long, ByVal dwMilliseconds As Long) As Long
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Declare Sub OutputDebugString Lib "kernel32" Alias "OutputDebugStringA" (ByVal lpOutputString As String)
Declare Function GetVersion Lib "kernel32" Alias "GetVersion" () As Long

Declare Function OpenFile Lib "kernel32" Alias "OpenFile" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long

' GetTempFileName() Flags
'
Public Const TF_FORCEDRIVE = &H80

Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
Declare Function SetHandleCount Lib "kernel32" Alias "SetHandleCount" (ByVal wNumber As Long) As Long
Declare Function GetLogicalDrives Lib "kernel32" Alias "GetLogicalDrives" () As Long
Declare Function LockFile Lib "kernel32" Alias "LockFile" (ByVal hFile As Long, ByVal dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal nNumberOfBytesToLockLow As Long, ByVal nNumberOfBytesToLockHigh As Long) As Long
Declare Function UnlockFile Lib "kernel32" Alias "UnlockFile" (ByVal hFile As Long, ByVal dwFileOffsetLow As Long, ByVal dwFileOffsetHigh As Long, ByVal nNumberOfBytesToUnlockLow As Long, ByVal nNumberOfBytesToUnlockHigh As Long) As Long
Declare Function LockFileEx Lib "kernel32" Alias "LockFileEx" (ByVal hFile As Long, ByVal dwFlags As Long, ByVal dwReserved As Long, ByVal nNumberOfBytesToLockLow As Long, ByVal nNumberOfBytesToLockHigh As Long, lpOverlapped As OVERLAPPED) As Long

Public Const LOCKFILE_FAIL_IMMEDIATELY = &H1
Public Const LOCKFILE_EXCLUSIVE_LOCK = &H2

Declare Function UnlockFileEx Lib "kernel32" Alias "UnlockFileEx" (ByVal hFile As Long, ByVal dwReserved As Long, ByVal nNumberOfBytesToUnlockLow As Long, ByVal nNumberOfBytesToUnlockHigh As Long, lpOverlapped As OVERLAPPED) As Long

Type BY_HANDLE_FILE_INFORMATION
        dwFileAttributes As Long
        ftCreationTime As FILETIME
        ftLastAccessTime As FILETIME
        ftLastWriteTime As FILETIME
        dwVolumeSerialNumber As Long
        nFileSizeHigh As Long
        nFileSizeLow As Long
        nNumberOfLinks As Long
        nFileIndexHigh As Long
        nFileIndexLow As Long
End Type

Declare Function GetFileInformationByHandle Lib "kernel32" Alias "GetFileInformationByHandle" (ByVal hFile As Long, lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long
Declare Function GetFileType Lib "kernel32" Alias "GetFileType" (ByVal hFile As Long) As Long
Declare Function GetFileSize Lib "kernel32" Alias "GetFileSize" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Declare Function GetStdHandle Lib "kernel32" Alias "GetStdHandle" (ByVal nStdHandle As Long) As Long
Declare Function SetStdHandle Lib "kernel32" Alias "SetStdHandle" (ByVal nStdHandle As Long, ByVal nHandle As Long) As Long
Declare Function WriteFile Lib "kernel32" Alias "WriteFile" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, lpOverlapped As OVERLAPPED) As Long
Declare Function ReadFile Lib "kernel32" Alias "ReadFile" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As OVERLAPPED) As Long
Declare Function FlushFileBuffers Lib "kernel32" Alias "FlushFileBuffers" (ByVal hFile As Long) As Long
Declare Function DeviceIoControl Lib "kernel32" Alias "DeviceIoControl" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, lpOverlapped As OVERLAPPED) As Long
Declare Function SetEndOfFile Lib "kernel32" Alias "SetEndOfFile" (ByVal hFile As Long) As Long
Declare Function SetFilePointer Lib "kernel32" Alias "SetFilePointer" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
Declare Function FindClose Lib "kernel32" Alias "FindClose" (ByVal hFindFile As Long) As Long
Declare Function GetFileTime Lib "kernel32" Alias "GetFileTime" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Declare Function SetFileTime Lib "kernel32" Alias "SetFileTime" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Long) As Long
Declare Function DuplicateHandle Lib "kernel32" Alias "DuplicateHandle" (ByVal hSourceProcessHandle As Long, ByVal hSourceHandle As Long, ByVal hTargetProcessHandle As Long, lpTargetHandle As Long, ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwOptions As Long) As Long

Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

Declare Function GlobalAlloc Lib "kernel32" Alias "GlobalAlloc" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Declare Function GlobalFree Lib "kernel32" Alias "GlobalFree" (ByVal hMem As Long) As Long
Declare Function GlobalHandle Lib "kernel32" Alias "GlobalHandle" (wMem As Any) As Long
Declare Function GlobalLock Lib "kernel32" Alias "GlobalLock" (ByVal hMem As Long) As Long
Declare Function GlobalReAlloc Lib "kernel32" Alias "GlobalReAlloc" (ByVal hMem As Long, ByVal dwBytes As Long, ByVal wFlags As Long) As Long

Declare Function GlobalSize Lib "kernel32" Alias "GlobalSize" (ByVal hMem As Long) As Long
Declare Function GlobalUnlock Lib "kernel32" Alias "GlobalUnlock" (ByVal hMem As Long) As Long
Declare Function GlobalFlags Lib "kernel32" Alias "GlobalFlags" (ByVal hMem As Long) As Long
Declare Sub GlobalMemoryStatus Lib "kernel32" Alias "GlobalMemoryStatus" (lpBuffer As MEMORYSTATUS)

Public Const LNOTIFY_OUTOFMEM = 0
Public Const LNOTIFY_MOVE = 1
Public Const LNOTIFY_DISCARD = 2

Declare Function LocalAlloc Lib "kernel32" Alias "LocalAlloc" (ByVal wFlags As Long, ByVal wBytes As Long) As Long
Declare Function LocalFree Lib "kernel32" Alias "LocalFree" (ByVal hMem As Long) As Long
Declare Function LocalHandle Lib "kernel32" Alias "LocalHandle" (wMem As Any) As Long
Declare Function LocalLock Lib "kernel32" Alias "LocalLock" (ByVal hMem As Long) As Long
Declare Function LocalReAlloc Lib "kernel32" Alias "LocalReAlloc" (ByVal hMem As Long, ByVal wBytes As Long, ByVal wFlags As Long) As Long

Declare Function LocalSize Lib "kernel32" Alias "LocalSize" (ByVal hMem As Long) As Long
Declare Function LocalUnlock Lib "kernel32" Alias "LocalUnlock" (ByVal hMem As Long) As Long
Declare Function LocalFlags Lib "kernel32" Alias "LocalFlags" (ByVal hMem As Long) As Long

Type MEMORY_BASIC_INFORMATION
     BaseAddress as Long
     AllocationBase as Long
     AllocationProtect As Long
     RegionSize As Long
     State As Long
     Protect As Long
     lType As Long
End Type

Declare Function FlushInstructionCache Lib "kernel32" Alias "FlushInstructionCache" (ByVal hProcess As Long, lpBaseAddress As Any, ByVal dwSize As Long) As Long
Declare Function VirtualAlloc Lib "kernel32" Alias "VirtualAlloc" (lpAddress As Any, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Declare Function VirtualFree Lib "kernel32" Alias "VirtualFree" (lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Declare Function VirtualProtect Lib "kernel32" Alias "VirtualProtect" (lpAddress As Any, ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long
Declare Function VirtualQuery Lib "kernel32" Alias "VirtualQuery" (lpAddress As Any, lpBuffer As MEMORY_BASIC_INFORMATION, ByVal dwLength As Long) As Long
Declare Function VirtualProtectEx Lib "kernel32" Alias "VirtualProtectEx" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long
Declare Function VirtualQueryEx Lib "kernel32" Alias "VirtualQueryEx" (ByVal hProcess As Long, lpAddress As Any, lpBuffer As MEMORY_BASIC_INFORMATION, ByVal dwLength As Long) As Long
Declare Function HeapCreate Lib "kernel32" Alias "HeapCreate" (ByVal flOptions As Long, ByVal dwInitialSize As Long, ByVal dwMaximumSize As Long) As Long
Declare Function HeapDestroy Lib "kernel32" Alias "HeapDestroy" (ByVal hHeap As Long) As Long
Declare Function HeapAlloc Lib "kernel32" Alias "HeapAlloc" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Declare Function HeapReAlloc Lib "kernel32" Alias "HeapReAlloc" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any, ByVal dwBytes As Long) As Long
Declare Function HeapFree Lib "kernel32" Alias "HeapFree" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
Declare Function HeapSize Lib "kernel32" Alias "HeapSize" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
Declare Function GetProcessHeap Lib "kernel32" Alias "GetProcessHeap" () As Long
Declare Function GetProcessTimes Lib "kernel32" Alias "GetProcessTimes" (ByVal hProcess As Long, lpCreationTime As FILETIME, lpExitTime As FILETIME, lpKernelTime As FILETIME, lpUserTime As FILETIME) As Long
Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function GetCurrentProcess Lib "kernel32" Alias "GetCurrentProcess" () As Long
Declare Function GetCurrentProcessId Lib "kernel32" Alias "GetCurrentProcessId" () As Long
Declare Sub ExitProcess Lib "kernel32" Alias "ExitProcess" (ByVal uExitCode As Long)
Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" Alias "GetExitCodeProcess" (ByVal hProcess As Long, lpExitCode As Long) As Long

Declare Function GetLastError Lib "kernel32" Alias "GetLastError" () As Long
Declare Sub SetLastError Lib "kernel32" Alias "SetLastError" (ByVal dwErrCode As Long)

Public Const SLE_ERROR = &H1
Public Const SLE_MINORERROR = &H2
Public Const SLE_WARNING = &H3

Declare Sub SetLastErrorEx Lib "user32" Alias "SetLastErrorEx" (ByVal dwErrCode As Long, ByVal dwType As Long)
Declare Function GetOverlappedResult Lib "kernel32" Alias "GetOverlappedResult" (ByVal hFile As Long, lpOverlapped As OVERLAPPED, lpNumberOfBytesTransferred As Long, ByVal bWait As Long) As Long

Public Const SEM_FAILCRITICALERRORS = &H1
Public Const SEM_NOGPFAULTERRORBOX = &H2
Public Const SEM_NOOPENFILEERRORBOX = &H8000

Declare Sub SetDebugErrorLevel Lib "user32" Alias "SetDebugErrorLevel" (ByVal dwLevel As Long)
Declare Function SetErrorMode Lib "kernel32" Alias "SetErrorMode" (ByVal wMode As Long) As Long

Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function WriteProcessMemory Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function GetThreadContext Lib "kernel32" Alias "GetThreadContext" (ByVal hThread As Long, lpContext As CONTEXT) As Long
Declare Function SetThreadContext Lib "kernel32" Alias "SetThreadContext" (ByVal hThread As Long, lpContext As CONTEXT) As Long
Declare Function SuspendThread Lib "kernel32" Alias "SuspendThread" (ByVal hThread As Long) As Long
Declare Function ResumeThread Lib "kernel32" Alias "ResumeThread" (ByVal hThread As Long) As Long

Declare Function FindResource Lib "kernel32" Alias "FindResourceA" (ByVal hInstance As Long, ByVal lpName As String, ByVal lpType As String) As Long
Declare Function FindResourceEx Lib "kernel32" Alias "FindResourceExA" (ByVal hModule As Long, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long) As Long
Declare Function BeginUpdateResource Lib "kernel32" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingResources As Long) As Long
Declare Function UpdateResource Lib "kernel32" Alias "UpdateResourceA" (ByVal hUpdate As Long, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long, lpData As Any, ByVal cbData As Long) As Long
Declare Function EndUpdateResource Lib "kernel32" Alias "EndUpdateResourceA" (ByVal hUpdate As Long, ByVal fDiscard As Long) As Long
Declare Function LoadResource Lib "kernel32" Alias "LoadResource" (ByVal hInstance As Long, ByVal hResInfo As Long) As Long
Declare Function LockResource Lib "kernel32" Alias "LockResource" (ByVal hResData As Long) As Long
Declare Function SizeofResource Lib "kernel32" Alias "SizeofResource" (ByVal hInstance As Long, ByVal hResInfo As Long) As Long

' Predefined Resource Types
Public Const RT_CURSOR = 1&
Public Const RT_BITMAP = 2&
Public Const RT_ICON = 3&
Public Const RT_MENU = 4&
Public Const RT_DIALOG = 5&
Public Const RT_STRING = 6&
Public Const RT_FONTDIR = 7&
Public Const RT_FONT = 8&
Public Const RT_ACCELERATOR = 9&
Public Const RT_RCDATA = 10&

Declare Function InitAtomTable Lib "kernel32" Alias "InitAtomTable" (ByVal nSize As Long) As Long
Declare Function AddAtom Lib "kernel32" Alias "AddAtomA" (ByVal lpString As String) As Integer
Declare Function DeleteAtom Lib "kernel32" Alias "DeleteAtom" (ByVal nAtom As Integer) As Integer
Declare Function FindAtom Lib "kernel32" Alias "FindAtomA" (ByVal lpString As String) As Integer
Declare Function GetAtomName Lib "kernel32" Alias "GetAtomNameA" (ByVal nAtom As Integer, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString As String) As Integer
Declare Function GlobalDeleteAtom Lib "kernel32" Alias "GlobalDeleteAtom" (ByVal nAtom As Integer) As Integer
Declare Function GlobalFindAtom Lib "kernel32" Alias "GlobalFindAtomA" (ByVal lpString As String) As Integer
Declare Function GlobalGetAtomName Lib "kernel32" Alias "GlobalGetAtomNameA" (ByVal nAtom As Integer, ByVal lpBuffer As String, ByVal nSize As Long) As Long

' User Profile Routines
' NOTE: The lpKeyName argument for GetProfileString, WriteProfileString,
'       GetPrivateProfileString, and WritePrivateProfileString can be either
'       a string or NULL.  This is why the argument is defined as "As Any".
'          For example, to pass a string specify   ByVal "wallpaper"
'          To pass NULL specify                    ByVal 0&
'       You can also pass NULL for the lpString argument for WriteProfileString
'       and WritePrivateProfileString
Declare Function GetProfileInt Lib "kernel32" Alias "GetProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Long) As Long

Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long

Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long

Declare Function GetProfileSection Lib "kernel32" Alias "GetProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Declare Function WriteProfileSection Lib "kernel32" Alias "WriteProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String) As Long
Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long

Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long

Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long
Declare Function GetCurrentDirectory Lib "kernel32" Alias "GetCurrentDirectory" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long
Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Declare Function CreateDirectoryEx Lib "kernel32" Alias "CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal lpNewDirectory As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Declare Function RemoveDirectory Lib "kernel32" Alias "RemoveDirectoryA" (ByVal lpPathName As String) As Long
Declare Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long

Public Const DDD_RAW_TARGET_PATH = &H1
Public Const DDD_REMOVE_DEFINITION = &H2
Public Const DDD_EXACT_MATCH_ON_REMOVE = &H4

Public Const MAX_PATH = 260

Declare Function DefineDosDevice Lib "kernel32" Alias "DefineDosDeviceA" (ByVal dwFlags As Long, ByVal lpDeviceName As String, ByVal lpTargetPath As String) As Long
Declare Function QueryDosDevice Lib "kernel32" Alias "QueryDosDeviceA" (ByVal lpDeviceName As String, ByVal lpTargetPath As String, ByVal ucchMax As Long) As Long
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function SearchPath Lib "kernel32" Alias "SearchPathA" (ByVal lpPath As String, ByVal lpFileName As String, ByVal lpExtension As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Declare Function MoveFile Lib "kernel32" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Long) As Long

Public Const MOVEFILE_REPLACE_EXISTING = &H1
Public Const MOVEFILE_COPY_ALLOWED = &H2
Public Const MOVEFILE_DELAY_UNTIL_REBOOT = &H4

Type EVENTLOGRECORD
     Length as Long     '  Length of full record
     Reserved as Long     '  Used by the service
     RecordNumber as Long     '  Absolute record number
     TimeGenerated as Long     '  Seconds since 1-1-1970
     TimeWritten as Long     'Seconds since 1-1-1970
     EventID as Long
     EventType as Integer
     NumStrings as Integer
     EventCategory as Integer
     ReservedFlags as Integer     '  For use with paired events (auditing)
     ClosingRecordNumber as Long     'For use with paired events (auditing)
     StringOffset as Long     '  Offset from beginning of record
     UserSidLength as Long
     UserSidOffset as Long
     DataLength as Long
     DataOffset as Long     '  Offset from beginning of record
End Type

Declare Function CreateNamedPipe Lib "kernel32" Alias "CreateNamedPipeA" (ByVal lpName As String, ByVal dwOpenMode As Long, ByVal dwPipeMode As Long, ByVal nMaxInstances As Long, ByVal nOutBufferSize As Long, ByVal nInBufferSize As Long, ByVal nDefaultTimeOut As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Declare Function GetNamedPipeHandleState Lib "kernel32" Alias "GetNamedPipeHandleStateA" (ByVal hNamedPipe As Long, lpState As Long, lpCurInstances As Long, lpMaxCollectionCount As Long, lpCollectDataTimeout As Long, ByVal lpUserName As String, ByVal nMaxUserNameSize As Long) As Long
Declare Function CallNamedPipe Lib "kernel32" Alias "CallNamedPipeA" (ByVal lpNamedPipeName As String, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesRead As Long, ByVal nTimeOut As Long) As Long
Declare Function WaitNamedPipe Lib "kernel32" Alias "WaitNamedPipeA" (ByVal lpNamedPipeName As String, ByVal nTimeOut As Long) As Long
Declare Function SetVolumeLabel Lib "kernel32" Alias "SetVolumeLabelA" (ByVal lpRootPathName As String, ByVal lpVolumeName As String) As Long
Declare Sub SetFileApisToOEM Lib "kernel32" Alias "SetFileApisToOEM" ()
Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Declare Function ClearEventLog Lib "advapi32.dll" Alias "ClearEventLogA" (ByVal hEventLog As Long, ByVal lpBackupFileName As String) As Long
Declare Function BackupEventLog Lib "advapi32.dll" Alias "BackupEventLogA" (ByVal hEventLog As Long, ByVal lpBackupFileName As String) As Long
Declare Function CloseEventLog Lib "advapi32.dll" Alias "CloseEventLog" (ByVal hEventLog As Long) As Long
Declare Function DeregisterEventSource Lib "advapi32.dll" Alias "DeregisterEventSource" (ByVal hEventLog As Long) As Long
Declare Function GetNumberOfEventLogRecords Lib "advapi32.dll" Alias "GetNumberOfEventLogRecords" (ByVal hEventLog As Long, NumberOfRecords As Long) As Long
Declare Function GetOldestEventLogRecord Lib "advapi32.dll" Alias "GetOldestEventLogRecord" (ByVal hEventLog As Long, OldestRecord As Long) As Long
Declare Function OpenEventLog Lib "advapi32.dll" Alias "OpenEventLog" (ByVal lpUNCServerName As String, ByVal lpSourceName As String) As Long
Declare Function RegisterEventSource Lib "advapi32.dll" Alias "RegisterEventSourceA" (ByVal lpUNCServerName As String, ByVal lpSourceName As String) As Long
Declare Function OpenBackupEventLog Lib "advapi32.dll" Alias "OpenBackupEventLogA" (ByVal lpUNCServerName As String, ByVal lpFileName As String) As Long
Declare Function ReadEventLog Lib "advapi32.dll" Alias "ReadEventLogA" (ByVal hEventLog As Long, ByVal dwReadFlags As Long, ByVal dwRecordOffset As Long, lpBuffer As EVENTLOGRECORD, ByVal nNumberOfBytesToRead As Long, pnBytesRead As Long, pnMinNumberOfBytesNeeded As Long) As Long
Declare Function ReportEvent Lib "advapi32.dll" Alias "ReportEventA" (ByVal hEventLog As Long, ByVal wType As Long, ByVal wCategory As Long, ByVal dwEventID As Long, lpUserSid As Any, ByVal wNumStrings As Long, ByVal dwDataSize As Long, ByVal lpStrings As Long, lpRawData As Any) As Long

' Security APIs
Public Const TokenUser = 1
Public Const TokenGroups = 2
Public Const TokenPrivileges = 3
Public Const TokenOwner = 4
Public Const TokenPrimaryGroup = 5
Public Const TokenDefaultDacl = 6
Public Const TokenSource = 7
Public Const TokenType = 8
Public Const TokenImpersonationLevel = 9
Public Const TokenStatistics = 10

Type TOKEN_GROUPS
    GroupCount As Long
    Groups(ANYSIZE_ARRAY) As SID_AND_ATTRIBUTES
End Type

Declare Function DuplicateToken Lib "advapi32.dll" Alias "DuplicateToken" (ByVal ExistingTokenHandle As Long, ImpersonationLevel As Integer, DuplicateTokenHandle As Long) As Long
Declare Function GetKernelObjectSecurity Lib "advapi32.dll" Alias "GetKernelObjectSecurity" (ByVal Handle As Long, ByVal RequestedInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal nLength As Long, lpnLengthNeeded As Long) As Long
Declare Function ImpersonateNamedPipeClient Lib "advapi32.dll" Alias "ImpersonateNamedPipeClient" (ByVal hNamedPipe As Long) As Long
Declare Function ImpersonateSelf Lib "advapi32.dll" Alias "ImpersonateSelf" (ImpersonationLevel As Integer) As Long
Declare Function RevertToSelf Lib "advapi32.dll" Alias "RevertToSelf" () As Long
Declare Function AccessCheck Lib "advapi32.dll" Alias "AccessCheck" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal ClientToken As Long, ByVal DesiredAccess As Long, GenericMapping As GENERIC_MAPPING, PrivilegeSet As PRIVILEGE_SET, PrivilegeSetLength As Long, GrantedAccess As Long, ByVal Status As Long) As Long

Type TOKEN_PRIVILEGES
PrivilegeCount As Long
Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
End Type

Declare Function OpenProcessToken Lib "advapi32.dll" Alias "OpenProcessToken" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Declare Function OpenThreadToken Lib "advapi32.dll" Alias "OpenThreadToken" (ByVal ThreadHandle As Long, ByVal DesiredAccess As Long, ByVal OpenAsSelf As Long, TokenHandle As Long) As Long

Declare Function GetTokenInformation Lib "advapi32.dll" Alias "GetTokenInformation" (ByVal TokenHandle As Long, TokenInformationClass As Integer, TokenInformation As Any, ByVal TokenInformationLength As Long, ReturnLength As Long) As Long
Declare Function SetTokenInformation Lib "advapi32.dll" Alias "SetTokenInformation" (ByVal TokenHandle As Long, TokenInformationClass As Integer, TokenInformation As Any, ByVal TokenInformationLength As Long) As Long
Declare Function AdjustTokenPrivileges Lib "advapi32.dll" Alias "AdjustTokenPrivileges" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Declare Function AdjustTokenGroups Lib "advapi32.dll" Alias "AdjustTokenGroups" (ByVal TokenHandle As Long, ByVal ResetToDefault As Long, NewState As TOKEN_GROUPS, ByVal BufferLength As Long, PreviousState As TOKEN_GROUPS, ReturnLength As Long) As Long
Declare Function PrivilegeCheck Lib "advapi32.dll" Alias "PrivilegeCheck" (ByVal ClientToken As Long, RequiredPrivileges As PRIVILEGE_SET, ByVal pfResult As Long) As Long
Declare Function AccessCheckAndAuditAlarm Lib "advapi32.dll" Alias "AccessCheckAndAuditAlarmA" (ByVal SubsystemName As String, HandleId As Any, ByVal ObjectTypeName As String, ByVal ObjectName As String, SecurityDescriptor As SECURITY_DESCRIPTOR, ByVal DesiredAccess As Long, GenericMapping As GENERIC_MAPPING, ByVal ObjectCreation As Long, GrantedAccess As Long, ByVal AccessStatus As Long, ByVal pfGenerateOnClose As Long) As Long
Declare Function ObjectOpenAuditAlarm Lib "kernel32" Alias "ObjectOpenAuditAlarmA" (ByVal SubsystemName As String, HandleId As Any, ByVal ObjectTypeName As String, ByVal ObjectName As String, pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal ClientToken As Long, ByVal DesiredAccess As Long, ByVal GrantedAccess As Long, Privileges As PRIVILEGE_SET, ByVal ObjectCreation As Long, ByVal AccessGranted As Long, ByVal GenerateOnClose As Long) As Long
Declare Function ObjectPrivilegeAuditAlarm Lib "advapi32.dll" Alias "ObjectPrivilegeAuditAlarmA" (ByVal SubsystemName As String, HandleId As Any, ByVal ClientToken As Long, ByVal DesiredAccess As Long, Privileges As PRIVILEGE_SET, ByVal AccessGranted As Long) As Long
Declare Function ObjectCloseAuditAlarm Lib "advapi32.dll" Alias "ObjectCloseAuditAlarmA" (ByVal SubsystemName As String, HandleId As Any, ByVal GenerateOnClose As Long) As Long
Declare Function PrivilegedServiceAuditAlarm Lib "advapi32.dll" Alias "PrivilegedServiceAuditAlarmA" (ByVal SubsystemName As String, ByVal ServiceName As String, ByVal ClientToken As Long, Privileges As PRIVILEGE_SET, ByVal AccessGranted As Long) As Long
Declare Function IsValidSid Lib "advapi32.dll" Alias "IsValidSid" (pSid As Any) As Long
Declare Function EqualSid Lib "advapi32.dll" Alias "EqualSid" (pSid1 As Any, pSid2 As Any) As Long
Declare Function EqualPrefixSid Lib "advapi32.dll" Alias "EqualPrefixSid" (pSid1 As Any, pSid2 As Any) As Long
Declare Function GetSidLengthRequired Lib "advapi32.dll" Alias "GetSidLengthRequired" (ByVal nSubAuthorityCount As Byte) As Long
Declare Function AllocateAndInitializeSid Lib "advapi32.dll" Alias "AllocateAndInitializeSid" (pIdentifierAuthority As SID_IDENTIFIER_AUTHORITY, ByVal nSubAuthorityCount As Byte, ByVal nSubAuthority0 As Long, ByVal nSubAuthority1 As Long, ByVal nSubAuthority2 As Long, ByVal nSubAuthority3 As Long, ByVal nSubAuthority4 As Long, ByVal nSubAuthority5 As Long, ByVal nSubAuthority6 As Long, ByVal nSubAuthority7 As Long, lpPSid As Long) As Long
Declare Sub FreeSid Lib "advapi32.dll" Alias "FreeSid" (pSid As Any)
Declare Function InitializeSid Lib "advapi32.dll" Alias "InitializeSid" (Sid As Any, pIdentifierAuthority As SID_IDENTIFIER_AUTHORITY, ByVal nSubAuthorityCount As Byte) As Long
Declare Function GetSidIdentifierAuthority Lib "advapi32.dll" Alias "GetSidIdentifierAuthority" (pSid As Any) As SID_IDENTIFIER_AUTHORITY
Declare Function GetSidSubAuthority Lib "advapi32.dll" Alias "GetSidSubAuthority" (pSid As Any, ByVal nSubAuthority As Long) As Long
Declare Function GetSidSubAuthorityCount Lib "advapi32.dll" Alias "GetSidSubAuthorityCount" (pSid As Any) As Byte
Declare Function GetLengthSid Lib "advapi32.dll" Alias "GetLengthSid" (pSid As Any) As Long
Declare Function CopySid Lib "advapi32.dll" Alias "CopySid" (ByVal nDestinationSidLength As Long, pDestinationSid As Any, pSourceSid As Any) As Long
Declare Function AreAllAccessesGranted Lib "advapi32.dll" Alias "AreAllAccessesGranted" (ByVal GrantedAccess As Long, ByVal DesiredAccess As Long) As Long
Declare Function AreAnyAccessesGranted Lib "advapi32.dll" Alias "AreAnyAccessesGranted" (ByVal GrantedAccess As Long, ByVal DesiredAccess As Long) As Long
Declare Sub MapGenericMask Lib "advapi32.dll" Alias "MapGenericMask" (AccessMask As Long, GenericMapping As GENERIC_MAPPING)
Declare Function IsValidAcl Lib "advapi32.dll" Alias "IsValidAcl" (pAcl As ACL) As Long
Declare Function InitializeAcl Lib "advapi32.dll" Alias "InitializeAcl" (pAcl As ACL, ByVal nAclLength As Long, ByVal dwAclRevision As Long) As Long
Declare Function GetAclInformation Lib "advapi32.dll" Alias "GetAclInformation" (pAcl As ACL, pAclInformation As Any, ByVal nAclInformationLength As Long, ByVal dwAclInformationClass As Integer) As Long
Declare Function SetAclInformation Lib "advapi32.dll" Alias "SetAclInformation" (pAcl As ACL, pAclInformation As Any, ByVal nAclInformationLength As Long, ByVal dwAclInformationClass As Integer) As Long
Declare Function AddAce Lib "advapi32.dll" Alias "AddAce" (pAcl As ACL, ByVal dwAceRevision As Long, ByVal dwStartingAceIndex As Long, pAceList As Any, ByVal nAceListLength As Long) As Long
Declare Function DeleteAce Lib "advapi32.dll" Alias "DeleteAce" (pAcl As ACL, ByVal dwAceIndex As Long) As Long
Declare Function GetAce Lib "advapi32.dll" Alias "GetAce" (pAcl As ACL, ByVal dwAceIndex As Long, pAce As Any) As Long
Declare Function AddAccessAllowedAce Lib "advapi32.dll" Alias "AddAccessAllowedAce" (pAcl As ACL, ByVal dwAceRevision As Long, ByVal AccessMask As Long, pSid As Any) As Long
Declare Function AddAccessDeniedAce Lib "advapi32.dll" Alias "AddAccessDeniedAce" (pAcl As ACL, ByVal dwAceRevision As Long, ByVal AccessMask As Long, pSid As Any) As Long
Declare Function AddAuditAccessAce Lib "advapi32.dll" Alias "AddAuditAccessAce" (pAcl As ACL, ByVal dwAceRevision As Long, ByVal dwAccessMask As Long, pSid As Any, ByVal bAuditSuccess As Long, ByVal bAuditFailure As Long) As Long
Declare Function FindFirstFreeAce Lib "advapi32.dll" Alias "FindFirstFreeAce" (pAcl As ACL, pAce As Long) As Long
Declare Function InitializeSecurityDescriptor Lib "advapi32.dll" Alias "InitializeSecurityDescriptor" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal dwRevision As Long) As Long
Declare Function IsValidSecurityDescriptor Lib "advapi32.dll" Alias "IsValidSecurityDescriptor" (pSecurityDescriptor As SECURITY_DESCRIPTOR) As Long
Declare Function GetSecurityDescriptorLength Lib "advapi32.dll" Alias "GetSecurityDescriptorLength" (pSecurityDescriptor As SECURITY_DESCRIPTOR) As Long
#1050
Type ACCESS_ALLOWED_ACE
        Header As ACE_HEADER
        Mask As Long
        SidStart As Long
End Type

Type ACCESS_DENIED_ACE
        Header As ACE_HEADER
        Mask As Long
        SidStart As Long
End Type


Type SYSTEM_AUDIT_ACE
        Header As ACE_HEADER
        Mask As Long
        SidStart As Long
End Type

Type SYSTEM_ALARM_ACE
        Header As ACE_HEADER
        Mask As Long
        SidStart As Long
End Type

'   The following declarations are used for setting and querying information
'   about and ACL.  First are the various information classes available to
'   the user.
'

Public Const AclRevisionInformation = 1
Public Const AclSizeInformation = 2
'
'   This record is returned/sent if the user is requesting/setting the
'   AclRevisionInformation
'

Type ACL_REVISION_INFORMATION
        AclRevision As Long
End Type

'
'   This record is returned if the user is requesting AclSizeInformation
'

Type ACL_SIZE_INFORMATION
        AceCount As Long
        AclBytesInUse As Long
        AclBytesFree As Long
End Type

' //////////////////////////////////////////////////////////////////////
'                                                                     //
'                              SECURITY_DESCRIPTOR                    //
'                                                                     //
' //////////////////////////////////////////////////////////////////////
'
'   Define the Security Descriptor and related data types.
'   This is an opaque data structure.
'

'  begin_ntddk begin_ntifs
'
'  Current security descriptor revision value
'

Public Const SECURITY_DESCRIPTOR_REVISION = (1)
Public Const SECURITY_DESCRIPTOR_REVISION1 = (1)

'  end_ntddk

'
'  Minimum length, in bytes, needed to build a security descriptor
'  (NOTE: This must manually be kept consistent with the)
'  (sizeof(SECURITY_DESCRIPTOR)                         )
'

Public Const SECURITY_DESCRIPTOR_MIN_LENGTH = (20)



Public Const SE_OWNER_DEFAULTED = &H1
Public Const SE_GROUP_DEFAULTED = &H2
Public Const SE_DACL_PRESENT = &H4
Public Const SE_DACL_DEFAULTED = &H8
Public Const SE_SACL_PRESENT = &H10
Public Const SE_SACL_DEFAULTED = &H20
Public Const SE_SELF_RELATIVE = &H8000

'
'   Where:
'
'       SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the
'           SID pointed to by the Owner field was provided by a
'           defaulting mechanism rather than explicitly provided by the
'           original provider of the security descriptor.  This may
'           affect the treatment of the SID with respect to inheritence
'           of an owner.
'
'       SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the
'           SID in the Group field was provided by a defaulting mechanism
'           rather than explicitly provided by the original provider of
'           the security descriptor.  This may affect the treatment of
'           the SID with respect to inheritence of a primary group.
'
'       SE_DACL_PRESENT - This boolean flag, when set, indicates that the
'           security descriptor contains a discretionary ACL.  If this
'           flag is set and the Dacl field of the SECURITY_DESCRIPTOR is
'           null, then a null ACL is explicitly being specified.
'
'       SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the
'           ACL pointed to by the Dacl field was provided by a defaulting
'           mechanism rather than explicitly provided by the original
'           provider of the security descriptor.  This may affect the
'           treatment of the ACL with respect to inheritence of an ACL.
'           This flag is ignored if the DaclPresent flag is not set.
'
'       SE_SACL_PRESENT - This boolean flag, when set,  indicates that the
'           security descriptor contains a system ACL pointed to by the
'           Sacl field.  If this flag is set and the Sacl field of the
'           SECURITY_DESCRIPTOR is null, then an empty (but present)
'           ACL is being specified.
'
'       SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the
'           ACL pointed to by the Sacl field was provided by a defaulting
'           mechanism rather than explicitly provided by the original
'           provider of the security descriptor.  This may affect the
'           treatment of the ACL with respect to inheritence of an ACL.
'           This flag is ignored if the SaclPresent flag is not set.
'
'       SE_SELF_RELATIVE - This boolean flag, when set, indicates that the
'           security descriptor is in self-relative form.  In this form,
'           all fields of the security descriptor are contiguous in memory
'           and all pointer fields are expressed as offsets from the
'           beginning of the security descriptor.  This form is useful
'           for treating security descriptors as opaque data structures
'           for transmission in communication protocol or for storage on
'           secondary media.
'
'
'
'  In general, this data structure should be treated opaquely to ensure future
'  compatibility.
'
'

Type SECURITY_DESCRIPTOR
        Revision As Byte
        Sbz1 As Byte
        Control As Long
        Owner As Long
        Group As Long
        Sacl As ACL
        Dacl As ACL
End Type


'  Where:
'
'      Revision - Contains the revision level of the security
'          descriptor.  This allows this structure to be passed between
'          systems or stored on disk even though it is expected to
'          change in the future.
'
'      Control - A set of flags which qualify the meaning of the
'          security descriptor or individual fields of the security
'          descriptor.
'
'      Owner - is a pointer to an SID representing an object's owner.
'          If this field is null, then no owner SID is present in the
'          security descriptor.  If the security descriptor is in
'          self-relative form, then this field contains an offset to
'          the SID, rather than a pointer.
'
'      Group - is a pointer to an SID representing an object's primary
'          group.  If this field is null, then no primary group SID is
'          present in the security descriptor.  If the security descriptor
'          is in self-relative form, then this field contains an offset to
'          the SID, rather than a pointer.
'
'      Sacl - is a pointer to a system ACL.  This field value is only
'          valid if the DaclPresent control flag is set.  If the
'          SaclPresent flag is set and this field is null, then a null
'          ACL  is specified.  If the security descriptor is in
'          self-relative form, then this field contains an offset to
'          the ACL, rather than a pointer.
'
'      Dacl - is a pointer to a discretionary ACL.  This field value is
'          only valid if the DaclPresent control flag is set.  If the
'          DaclPresent flag is set and this field is null, then a null
'          ACL (unconditionally granting access) is specified.  If the
'          security descriptor is in self-relative form, then this field
'          contains an offset to the ACL, rather than a pointer.
'



' //////////////////////////////////////////////////////////////////////
'                                                                     //
'                Privilege Related Data Structures                    //
'                                                                     //
' //////////////////////////////////////////////////////////////////////


'  Privilege attributes
'

Public Const SE_PRIVILEGE_ENABLED_BY_DEFAULT = &H1
Public Const SE_PRIVILEGE_ENABLED = &H2
Public Const SE_PRIVILEGE_USED_FOR_ACCESS = &H80000000

'
'  Privilege Set Control flags
'

Public Const PRIVILEGE_SET_ALL_NECESSARY = (1)

'
'   Privilege Set - This is defined for a privilege set of one.
'                   If more than one privilege is needed, then this structure
'                   will need to be allocated with more space.
'
'   Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
'   structure (defined in se.h)
'

Type PRIVILEGE_SET
        PrivilegeCount As Long
        Control As Long
        Privilege(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
End Type


'//////////////////////////////////////////////////////////////////////
'                                                                     //
'                NT Defined Privileges                                //
'                                                                     //
' //////////////////////////////////////////////////////////////////////

Public Const SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
Public Const SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"
Public Const SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"
Public Const SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"
Public Const SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"
Public Const SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"
Public Const SE_TCB_NAME = "SeTcbPrivilege"
Public Const SE_SECURITY_NAME = "SeSecurityPrivilege"
Public Const SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"
Public Const SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
Public Const SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"
Public Const SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"
Public Const SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"
Public Const SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"
Public Const SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"
Public Const SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"
Public Const SE_BACKUP_NAME = "SeBackupPrivilege"
Public Const SE_RESTORE_NAME = "SeRestorePrivilege"
Public Const SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
Public Const SE_DEBUG_NAME = "SeDebugPrivilege"
Public Const SE_AUDIT_NAME = "SeAuditPrivilege"
Public Const SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"
Public Const SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"
Public Const SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"


' //////////////////////////////////////////////////////////////////
'                                                                 //
'            Security Quality Of Service                          //
'                                                                 //
'                                                                 //
' //////////////////////////////////////////////////////////////////

'  begin_ntddk begin_nthal begin_ntifs
'
'  Impersonation Level
'
'  Impersonation level is represented by a pair of bits in Windows.
'  If a new impersonation level is added or lowest value is changed from
'  0 to something else, fix the Windows CreateFile call.
'

Public Const SecurityAnonymous = 1
Public Const SecurityIdentification = 2

'//////////////////////////////////////////////////////////////////////
'                                                                     //
'                Registry API Constants                                //
'                                                                     //
' //////////////////////////////////////////////////////////////////////

' Reg Data Types...
Public Const REG_NONE = 0                       ' No value type
Public Const REG_SZ = 1                         ' Unicode nul terminated string
Public Const REG_EXPAND_SZ = 2                  ' Unicode nul terminated string
Public Const REG_BINARY = 3                     ' Free form binary
Public Const REG_DWORD = 4                      ' 32-bit number
Public Const REG_DWORD_LITTLE_ENDIAN = 4        ' 32-bit number (same as REG_DWORD)
Public Const REG_DWORD_BIG_ENDIAN = 5           ' 32-bit number
Public Const REG_LINK = 6                       ' Symbolic Link (unicode)
Public Const REG_MULTI_SZ = 7                   ' Multiple Unicode strings
Public Const REG_RESOURCE_LIST = 8              ' Resource list in the resource map
Public Const REG_FULL_RESOURCE_DESCRIPTOR = 9   ' Resource list in the hardware description
Public Const REG_RESOURCE_REQUIREMENTS_LIST = 10
Public Const REG_CREATED_NEW_KEY = &H1                      ' New Registry Key created
Public Const REG_OPENED_EXISTING_KEY = &H2                      ' Existing Key opened
Public Const REG_WHOLE_HIVE_VOLATILE = &H1                      ' Restore whole hive volatile
Public Const REG_REFRESH_HIVE = &H2                      ' Unwind changes to last flush
Public Const REG_NOTIFY_CHANGE_NAME = &H1                      ' Create or delete (child)
Public Const REG_NOTIFY_CHANGE_ATTRIBUTES = &H2
Public Const REG_NOTIFY_CHANGE_LAST_SET = &H4                      ' Time stamp
Public Const REG_NOTIFY_CHANGE_SECURITY = &H8
Public Const REG_LEGAL_CHANGE_FILTER = (REG_NOTIFY_CHANGE_NAME Or REG_NOTIFY_CHANGE_ATTRIBUTES Or REG_NOTIFY_CHANGE_LAST_SET Or REG_NOTIFY_CHANGE_SECURITY)
Public Const REG_LEGAL_OPTION = (REG_OPTION_RESERVED Or REG_OPTION_NON_VOLATILE Or REG_OPTION_VOLATILE Or REG_OPTION_CREATE_LINK Or REG_OPTION_BACKUP_RESTORE)

' Reg Create Type Values...
Public Const REG_OPTION_RESERVED = 0           ' Parameter is reserved
Public Const REG_OPTION_NON_VOLATILE = 0       ' Key is preserved when system is rebooted
Public Const REG_OPTION_VOLATILE = 1           ' Key is not preserved when system is rebooted
Public Const REG_OPTION_CREATE_LINK = 2        ' Created key is a symbolic link
Public Const REG_OPTION_BACKUP_RESTORE = 4     ' open for backup or restore

' Reg Key Security Options
Public Const READ_CONTROL = &H20000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
Public Const KEY_EXECUTE = (KEY_READ)
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Public Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)
Public Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))

' end winnt.txt

' Debug APIs
Public Const EXCEPTION_DEBUG_EVENT = 1
Public Const CREATE_THREAD_DEBUG_EVENT = 2
Public Const CREATE_PROCESS_DEBUG_EVENT = 3
Public Const EXIT_THREAD_DEBUG_EVENT = 4
Public Const EXIT_PROCESS_DEBUG_EVENT = 5
Public Const LOAD_DLL_DEBUG_EVENT = 6
Public Const UNLOAD_DLL_DEBUG_EVENT = 7
Public Const OUTPUT_DEBUG_STRING_EVENT = 8
Public Const RIP_EVENT = 9

Public Const EXCEPTION_MAXIMUM_PARAMETERS = 15

Type EXCEPTION_RECORD
    ExceptionCode As Long
    ExceptionFlags As Long
    pExceptionRecord As Long ' Pointer to an EXCEPTION_RECORD structure
    ExceptionAddress As Long
    NumberParameters As Long
    ExceptionInformation(EXCEPTION_MAXIMUM_PARAMETERS) As Long
End Type

Type EXCEPTION_DEBUG_INFO
        pExceptionRecord As EXCEPTION_RECORD
        dwFirstChance As Long
End Type

Type CREATE_THREAD_DEBUG_INFO
        hThread As Long
        lpThreadLocalBase As Long
        lpStartAddress As Long
End Type

Type CREATE_PROCESS_DEBUG_INFO
        hFile As Long
        hProcess As Long
        hThread As Long
        lpBaseOfImage As Long
        dwDebugInfoFileOffset As Long
        nDebugInfoSize As Long
        lpThreadLocalBase As Long
        lpStartAddress As Long
        lpImageName As Long
        fUnicode As Integer
End Type

Type EXIT_THREAD_DEBUG_INFO
        dwExitCode As Long
End Type

Type EXIT_PROCESS_DEBUG_INFO
        dwExitCode As Long
End Type

Type LOAD_DLL_DEBUG_INFO
        hFile As Long
        lpBaseOfDll As Long
        dwDebugInfoFileOffset As Long
        nDebugInfoSize As Long
        lpImageName As Long
        fUnicode As Integer
End Type

Type UNLOAD_DLL_DEBUG_INFO
        lpBaseOfDll As Long
End Type

Type OUTPUT_DEBUG_STRING_INFO
        lpDebugStringData As String
        fUnicode As Integer
        nDebugStringLength As Integer
End Type

Type RIP_INFO
        dwError As Long
        dwType As Long
End Type

' GetDriveType return values
Public Const DRIVE_REMOVABLE = 2
Public Const DRIVE_FIXED = 3
Public Const DRIVE_REMOTE = 4
Public Const DRIVE_CDROM = 5
Public Const DRIVE_RAMDISK = 6

Public Const FILE_TYPE_UNKNOWN = &H0
Public Const FILE_TYPE_DISK = &H1
Public Const FILE_TYPE_CHAR = &H2
Public Const FILE_TYPE_PIPE = &H3
Public Const FILE_TYPE_REMOTE = &H8000

Public Const STD_INPUT_HANDLE = -10&
Public Const STD_OUTPUT_HANDLE = -11&
Public Const STD_ERROR_HANDLE = -12&

Public Const NOPARITY = 0
Public Const ODDPARITY = 1
Public Const EVENPARITY = 2
Public Const MARKPARITY = 3
Public Const SPACEPARITY = 4

Public Const ONESTOPBIT = 0
Public Const ONE5STOPBITS = 1
Public Const TWOSTOPBITS = 2

Public Const IGNORE = 0 '  Ignore signal
Public Const INFINITE = &HFFFF      '  Infinite timeout

' Comm Baud Rate indices
Public Const CBR_110 = 110
Public Const CBR_300 = 300
Public Const CBR_600 = 600
Public Const CBR_1200 = 1200
Public Const CBR_2400 = 2400
Public Const CBR_4800 = 4800
Public Const CBR_9600 = 9600
Public Const CBR_14400 = 14400
Public Const CBR_19200 = 19200
Public Const CBR_38400 = 38400
Public Const CBR_56000 = 56000
Public Const CBR_57600 = 57600
Public Const CBR_115200 = 115200
Public Const CBR_128000 = 128000
Public Const CBR_256000 = 256000

' Error Flags
Public Const CE_RXOVER = &H1                '  Receive Queue overflow
Public Const CE_OVERRUN = &H2               '  Receive Overrun Error
Public Const CE_RXPARITY = &H4              '  Receive Parity Error
Public Const CE_FRAME = &H8                 '  Receive Framing error
Public Const CE_BREAK = &H10                '  Break Detected
Public Const CE_TXFULL = &H100              '  TX Queue is full
Public Const CE_PTO = &H200                 '  LPTx Timeout
Public Const CE_IOE = &H400                 '  LPTx I/O Error
Public Const CE_DNS = &H800                 '  LPTx Device not selected
Public Const CE_OOP = &H1000                '  LPTx Out-Of-Paper
Public Const CE_MODE = &H8000               '  Requested mode unsupported

Public Const IE_BADID = (-1)                '  Invalid or unsupported id
Public Const IE_OPEN = (-2)                 '  Device Already Open
Public Const IE_NOPEN = (-3)                '  Device Not Open
Public Const IE_MEMORY = (-4)               '  Unable to allocate queues
Public Const IE_DEFAULT = (-5)              '  Error in default parameters
Public Const IE_HARDWARE = (-10)            '  Hardware Not Present
Public Const IE_BYTESIZE = (-11)            '  Illegal Byte Size
Public Const IE_BAUDRATE = (-12)            '  Unsupported BaudRate

' Events