VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "dwSystem"
Attribute VB_Creatable = True
Attribute VB_Exposed = True
Option Explicit

' Class dwSystem
' System control and configuration class
' Copyright (c) 1996 by Desaware Inc.
' Part of the Desaware API Classes Library
' All rights reserved

' These flags will activate certain functions that require
' classes that most functions do not need.  If you do not
' need to use a function that is triggered by a flag, you
' can set the flag to False, and prevent an unneeded class
' from being loaded.
#Const FlagGlobalAlloc = True
#Const FlagGetSystemPowerStatus = True
#Const FlagGetVersionEx = True
#Const FlagGetCPInfo = True
#Const FlagDeviceContext = True
#Const FlagMetaFile = True

' Sub classes:
Public Metrics As New dwMetrics
Public SysColor As New dwSysColor

'**  Functions From Chapter 5 Index

#If Win32 Then
Private Declare Function apiAdjustWindowRect& Lib "user32" Alias "AdjustWindowRect" (lpRect As RECT, ByVal dwStyle As Long, ByVal bMenu As Long)
Private Declare Function apiAdjustWindowRectEx& Lib "user32" Alias "AdjustWindowRectEx" (lpRect As RECT, ByVal dsStyle As Long, ByVal bMenu As Long, ByVal dwEsStyle As Long)
Private Declare Function apiAnyPopup& Lib "user32" Alias "AnyPopup" ()
Private Declare Function apiGetActiveWindow& Lib "user32" Alias "GetActiveWindow" ()
Private Declare Function apiFindWindow& Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String)
Private Declare Function apiGetCapture& Lib "user32" Alias "GetCapture" ()
Private Declare Function apiGetDesktopWindow& Lib "user32" Alias "GetDesktopWindow" ()
Private Declare Function apiGetFocus& Lib "user32" Alias "GetFocus" ()
Private Declare Function apiGetForegroundWindow& Lib "user32" Alias "GetForegroundWindow" ()
Private Declare Function apiGetLastActivePopup& Lib "user32" Alias "GetLastActivePopup" (ByVal hwndOwnder As Long)
Private Declare Function apiWindowFromPoint& Lib "user32" Alias "WindowFromPoint" (ByVal x As Long, ByVal y As Long)

#Else
Private Declare Sub apiAdjustWindowRect Lib "user" Alias "AdjustWindowRec" (lpRect As RECT, ByVal dwStyle As Long, ByVal bMenu As Integer)
Private Declare Sub apiAdjustWindowRectEx Lib "user" Alias "AdjustWindowRectEx" (lpRect As RECT, ByVal dsStyle As Long, ByVal bMenu As Integer, ByVal dwEsStyle As Long)
Private Declare Function apiAnyPopup% Lib "user" Alias "AnyPopup" ()
Private Declare Function apiGetActiveWindow% Lib "user" Alias "GetActiveWindow" ()
Private Declare Function apiFindWindow% Lib "user" Alias "FindWindow" (ByVal lpClassName As Any, ByVal lpWindowName As Any)
Private Declare Function apiGetCapture% Lib "user" Alias "GetCapture" ()
Private Declare Function apiGetDesktopWindow% Lib "user" Alias "GetDesktopWindow" ()
Private Declare Function apiGetFocus% Lib "user" Alias "GetFocus" ()
'function apiGetForegroundWindow is not available in the WIN16 API.
Private Declare Function apiGetLastActivePopup% Lib "user" Alias "GetLastActivePopup" (ByVal hwndOwnder As Integer)
Private Declare Function apiWindowFromPoint% Lib "user" Alias "WindowFromPoint" (ByVal pnt As Any)
#End If 'WIN32

'**  Functions From Chapter 6 Index

#If Win32 Then
Private Declare Function apiBeep& Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long)
Private Declare Function apiCharToOem& Lib "user32" Alias "CharToOemA" (ByVal lpszSrc As String, ByVal lpszDst As String)
Private Declare Function apiCharToOemBuff& Lib "user32" Alias "CharToOemBuffA" (ByVal lpszSrc As String, ByVal lpszDst As String, ByVal cchDstLength As Long)
Private Declare Function apiClipCursor& Lib "user32" Alias "ClipCursor" (lpRect As RECT)
Private Declare Function apiClipCursorBynum& Lib "user32" Alias "ClipCursor" (ByVal lpRect As Long)
Private Declare Function apiExitWindowsEx& Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long)
Private Declare Function apiGetACP& Lib "kernel32" Alias "GetACP" ()
Private Declare Function apiGetAsyncKeyState% Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long)
Private Declare Function apiGetCaretBlinkTime& Lib "user32" Alias "GetCaretBlinkTime" ()
Private Declare Function apiGetCPInfo& Lib "kernel32" Alias "GetCPInfo" (ByVal CodePage As Long, lpCPInfo As CPINFO)
Private Declare Function apiGetClipCursor& Lib "user32" Alias "GetClipCursor" (lprc As RECT)
Private Declare Function apiGetCommandLine& Lib "kernel32" Alias "GetCommandLineA" ()
Private Declare Function apiGetComputerName& Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long)
Private Declare Function apiGetCursorPos& Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI)
Private Declare Function apiGetDoubleClickTime& Lib "user32" Alias "GetDoubleClickTime" ()
Private Declare Function apiGetInputState& Lib "user32" Alias "GetInputState" ()
Private Declare Function apiGetKBCodePage& Lib "user32" Alias "GetKBCodePage" ()
Private Declare Function apiGetKeyboardLayoutName& Lib "user32" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String)
Private Declare Function apiGetKeyboardLayout& Lib "user32" Alias "GetKeyboardLayout" (ByVal dwLayout As Long)
Private Declare Function apiGetKeyboardState& Lib "user32" Alias "GetKeyboardState" (pbKeyState As Byte)
Private Declare Function apiGetKeyboardType& Lib "user32" Alias "GetKeyboardType" (ByVal nTypeFlag As Long)
Private Declare Function apiGetKeyNameText& Lib "user32" Alias "GetKeyNameTextA" (ByVal lParam As Long, ByVal lpBuffer As String, ByVal nSize As Long)
Private Declare Function apiGetKeyState% Lib "user32" Alias "GetKeyState" (ByVal nVirtKey As Long)
Private Declare Function apiGetOEMCP& Lib "kernel32" Alias "GetOEMCP" ()
Private Declare Function apiGetQueueStatus& Lib "user32" Alias "GetQueueStatus" (ByVal fuFlags As Long)
Private Declare Function apiGetSystemDefaultLangID% Lib "kernel32" Alias "GetSystemDefaultLangID" ()
Private Declare Function apiGetSystemDefaultLCID& Lib "kernel32" Alias "GetSystemDefaultLCID" ()
Private Declare Function apiGetSystemPowerStatus& Lib "kernel32" Alias "GetSystemPowerStatus" (lpSystemPowerStatus As SYSTEM_POWER_STATUS)
Private Declare Function apiGetThreadLocale& Lib "kernel32" Alias "GetThreadLocale" ()
Private Declare Function apiGetUserDefaultLangID% Lib "kernel32" Alias "GetUserDefaultLangID" ()
Private Declare Function apiGetUserDefaultLCID& Lib "kernel32" Alias "GetUserDefaultLCID" ()
Private Declare Function apiGetUserName& Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long)
Private Declare Function apiGetVersion& Lib "kernel32" Alias "GetVersion" ()
Private Declare Function apiGetVersionEx& Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO)
Private Declare Function apiIsValidCodePage& Lib "kernel32" Alias "IsValidCodePage" (ByVal CodePage As Long)
Private Declare Function apiIsValidLocale& Lib "kernel32" Alias "IsValidLocale" (ByVal Locale As Long, ByVal dwFlags As Long)
Private Declare Function apiMessageBeep& Lib "user32" Alias "MessageBeep" (ByVal wType As Long)
Private Declare Function apiSetCaretBlinkTime& Lib "user32" Alias "SetCaretBlinkTime" (ByVal wMSeconds As Long)
Private Declare Function apiSetComputerName& Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String)
Private Declare Function apiSetCursorPos& Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long)
Private Declare Function apiSetDoubleClickTime& Lib "user32" Alias "SetDoubleClickTime" (ByVal wCount As Long)
Private Declare Function apiSetThreadLocale& Lib "kernel32" Alias "SetThreadLocale" (ByVal Locale As Long)
Private Declare Function apiShowCursor& Lib "user32" Alias "ShowCursor" (ByVal bShow As Long)
Private Declare Function apiSwapMouseButton& Lib "user32" Alias "SwapMouseButton" (ByVal bSwap As Long)

#Else
'function apiBeep is not available in the WIN16 API.
'function apiCharToOem is not available in the WIN16 API.
'function apiCharToOemBuff is not available in the WIN16 API.
Private Declare Sub apiClipCursor Lib "user" Alias "ClipCursor" (lpRect As Any)
Private Declare Sub apiClipCursorBynum Lib "user" Alias "ClipCursor" (ByVal lpRect As Long)
'function apiExitWindowsEx is not available in the WIN16 API.
Private Declare Function apiExitWindows% Lib "user" Alias "ExitWindows" (ByVal dwReturnCode&, ByVal Reserved%)
'function apiGetACP is not available in the WIN16 API.
Private Declare Function apiGetAsyncKeyState% Lib "user" Alias "GetAsyncKeyState" (ByVal vKey As Integer)
Private Declare Function apiGetCaretBlinkTime% Lib "user" Alias "GetCaretBlinkTime" ()
'function apiGetCPInfo is not available in the WIN16 API.
Private Declare Sub apiGetClipCursor Lib "user" Alias "GetClipCursor" (lprc As RECT)
'function apiGetCommandLine is not available in the WIN16 API.
'function apiGetComputerName is not available in the WIN16 API.
Private Declare Sub apiGetCursorPos Lib "user" Alias "GetCursorPos" (lpPoint As POINTAPI)
Private Declare Function apiGetDoubleClickTime% Lib "user" Alias "GetDoubleClickTime" ()
Private Declare Function apiGetInputState% Lib "user" Alias "GetInputState" ()
Private Declare Function apiGetKBCodePage% Lib "keyboard.dll" Alias "GetKBCodePage" ()
'function apiGetKeyboardLayoutName is not available in the WIN16 API.
Private Declare Sub apiGetKeyboardState Lib "user" Alias "GetKeyboardState" (LpKeyState As Any)
Private Declare Function apiGetKeyboardType% Lib "keyboard.dll" Alias "GetKeyboardType" (ByVal nTypeFlag As Integer)
Private Declare Function apiGetKeyNameText% Lib "keyboard.dll" Alias "GetKeyNameText" (ByVal lParam As Long, ByVal lpBuffer As String, ByVal nSize As Integer)
Private Declare Function apiGetKeyState% Lib "user" Alias "GetKeyState" (ByVal nVirtKey As Integer)
'Function GetOEMCP is not available in the WIN16 API.
Private Declare Function apiGetQueueStatus& Lib "user" Alias "GetQueueStatus" (ByVal fuFlags As Integer)
'Function GetSystemDefaultLangID is not available in the WIN16 API.
'Function GetSystemDefaultLCID is not available in the WIN16 API.
'Function GetSystemPowerStatus is not available in the WIN16 API.
'Function GetThreadLocale is not available in the WIN16 API.
'Function GetUserDefaultLangID is not available in the WIN16 API.
'Function GetUserDefaultLCID is not available in the WIN16 API.
'Function GetUserName is not available in the WIN16 API.
Private Declare Function apiGetVersion& Lib "kernel" Alias "GetVersion" ()
'Function GetVersionEx is not available in the WIN16 API.
'Function IsValidCodePage is not available in the WIN16 API.
'Function IsValidLocale is not available in the WIN16 API.
Private Declare Sub apiMessageBeep Lib "user" Alias "MessageBeep" (ByVal wType As Integer)
Private Declare Sub apiSetCaretBlinkTime Lib "user" Alias "SetCaretBlinkTime" (ByVal wMSeconds As Integer)
'Function SetComputerName is not available in the WIN16 API.
Private Declare Sub apiSetCursorPos Lib "user" Alias "SetCursorPos" (ByVal x As Integer, ByVal y As Integer)
Private Declare Sub apiSetDoubleClickTime Lib "user" Alias "SetDoubleClickTime" (ByVal wCount As Integer)
'Function SetThreadLocale is not available in the WIN16 API.
Private Declare Function apiShowCursor% Lib "user" Alias "ShowCursor" (ByVal bShow As Integer)
Private Declare Function apiSwapMouseButton% Lib "user" Alias "SwapMouseButton" (ByVal bSwap As Integer)
#End If 'WIN32

'**  Functions From Chapter 8 Index

#If Win32 Then
Private Declare Function apiCreateMetaFile& Lib "gdi32" Alias "CreateMetaFileA" (ByVal lpstring As String)
Private Declare Function apiCreatePen& Lib "gdi32" Alias "CreatePen" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long)
Private Declare Function apiGdiFlush& Lib "gdi32" Alias "GdiFlush" ()
Private Declare Function apiGdiGetBatchLimit& Lib "gdi32" Alias "GdiGetBatchLimit" ()
Private Declare Function apiGdiSetBatchLimit& Lib "gdi32" Alias "GdiSetBatchLimit" (ByVal dwLimit As Long)
Private Declare Function apiGetEnhMetaFile& Lib "gdi32" Alias "GetEnhMetaFileA" (ByVal lpszMetaFile As String)
Private Declare Function apiGetMetaFile& Lib "gdi32" Alias "GetMetaFileA" (ByVal lpFileName As String)
#Else
Private Declare Function apiCreateMetaFile% Lib "gdi" Alias "CreateMetaFile" (ByVal lpstring As Any)
Private Declare Function apiCreatePen% Lib "gdi" Alias "CreatePen" (ByVal nPenStyle As Integer, ByVal nWidth As Integer, ByVal crColor As Long)
'function apiGdiFlush is not available in the WIN16 API.
'function apiGdiGetBatchLimit is not available in the WIN16 API.
'function apiGdiSetBatchLimit is not available in the WIN16 API.
'function apiGetEnhMetaFile is not available in the WIN16 API.
Private Declare Function apiGetMetaFile% Lib "gdi" Alias "GetMetaFile" (ByVal lpFileName As String)
#End If 'WIN32

#If Win32 Then
Private Declare Function apiGlobalAlloc& Lib "kernel32" Alias "GlobalAlloc" (ByVal fuFlags As Long, ByVal cdBytes As Long)
Private Declare Function apiMessageBox& Lib "user32" Alias "MessageBox" (ByVal hWnd&, ByVal lpText$, ByVal lpCaption$, ByVal wType&)
Private Declare Function apiGetTickCount& Lib "user32" Alias "GetTickCount" ()
#Else
Private Declare Function apiGlobalAlloc% Lib "kernel" Alias "GlobalAlloc" (ByVal fuFlags As Integer, ByVal cdBytes As Long)
Private Declare Function apiMessageBox% Lib "user" Alias "MessageBox" (ByVal hWnd%, ByVal lpText$, ByVal lpCaption$, ByVal wType%)
Private Declare Function apiGetTickCount& Lib "user" Alias "GetTickCount" ()
#End If 'WIN32


Private Sub RaiseSysError(Optional errval)
    If IsMissing(errval) Then
        RaiseError DWERR_APIRESULT, "dwSystem"
    Else
        RaiseError errval, "dwSystem"
    End If
End Sub

Public Function CreatePen(ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As dwPen
Attribute CreatePen.VB_HelpID = 2510
Attribute CreatePen.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim newPen As New dwPen
#If Win32 Then
    Dim penHandle As Long
#Else
    Dim penHandle As Integer
#End If
    
    penHandle = apiCreatePen(nPenStyle, nWidth, crColor)
    newPen.hPen = penHandle
    Set CreatePen = newPen
End Function

#If FlagDeviceContext Then
Public Function CreateMetafile(filename As String) As dwDeviceContext
Attribute CreateMetafile.VB_HelpID = 2508
Attribute CreateMetafile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim newHDC As New dwDeviceContext
#If Win32 Then
    Dim hDC As Long
#Else
    Dim hDC As Integer
#End If
    
    hDC = apiCreateMetaFile(filename)
    newHDC.DCsource = 3
    newHDC.hDC = hDC
    Set CreateMetafile = newHDC
End Function
#End If ' FlagDeviceContext

Public Sub Beep(ByVal lFreq As Long, ByVal lDuration As Long)
Attribute Beep.VB_HelpID = 2340
Attribute Beep.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiBeep(lFreq, lDuration)
    If ret& = 0 Then RaiseSysError
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Sub

Public Sub CharToOem(lpszSrc As String, lpszDst As String)
Attribute CharToOem.VB_HelpID = 2838
Attribute CharToOem.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    lpszDst = String$(Len(lpszSrc), 0)
    apiCharToOem lpszSrc, lpszDst
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Sub

Public Sub ClipCursor(lpRect As dwRECT)
Attribute ClipCursor.VB_HelpID = 2965
Attribute ClipCursor.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
#If Win32 Then
    ret& = apiClipCursorBynum(lpRect.GetAddress())
    If ret& = 0 Then RaiseSysError
#Else
    apiClipCursorBynum lpRect.GetAddress()
#End If
End Sub

' Use this to stop clipping the cursor.
Public Sub UnClipCursor()
Attribute UnClipCursor.VB_HelpID = 2965
Attribute UnClipCursor.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&

#If Win32 Then
    ret& = apiClipCursorBynum(0)
    If ret& = 0 Then RaiseSysError
#Else
    apiClipCursorBynum 0
#End If
End Sub

Public Sub ExitWindows(ByVal uFlags As Long) ' was ExitWindowsEx in 32-bit
Attribute ExitWindows.VB_HelpID = 2756
Attribute ExitWindows.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiExitWindowsEx(uFlags, 0)
    If ret& = 0 Then RaiseSysError
#Else
    Dim ret%
    
    ret% = apiExitWindows(uFlags, 0)
    If ret% = 0 Then RaiseSysError
#End If
End Sub

Public Function GetACP() As Long
Attribute GetACP.VB_HelpID = 2418
Attribute GetACP.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    GetACP = apiGetACP()
#Else
    GetACP = 0
#End If
End Function

Public Function GetAsyncKeyState(ByVal vKey As Long) As Integer
Attribute GetAsyncKeyState.VB_HelpID = 2857
Attribute GetAsyncKeyState.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    GetAsyncKeyState = apiGetAsyncKeyState(vKey)
End Function

Public Function GetCaretBlinkTime() As Long
Attribute GetCaretBlinkTime.VB_HelpID = 2970
Attribute GetCaretBlinkTime.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    GetCaretBlinkTime = apiGetCaretBlinkTime()
End Function

#If FlagGetCPInfo Then
Public Sub GetCPInfo(ByVal CodePage As Long, lpCPInfo As dwCPInfo)
Attribute GetCPInfo.VB_HelpID = 2420
Attribute GetCPInfo.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    Dim tempCPinfo As CPINFO
    
    ret& = apiGetCPInfo(CodePage, tempCPinfo)
    lpCPInfo.CopyFromCPINFO agGetAddressForObject(tempCPinfo)
    If ret& = 0 Then RaiseSysError
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Sub
#End If ' FlagGetCPInfo

Public Sub GetClipCursor(lprc As dwRECT)
Attribute GetClipCursor.VB_HelpID = 2968
Attribute GetClipCursor.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    Dim tmpRect As RECT
    
#If Win32 Then
    ret& = apiGetClipCursor(tmpRect)
    If ret& = 0 Then RaiseSysError
#Else
    apiGetClipCursor tmpRect
#End If
    lprc.SetRect tmpRect.left, tmpRect.top, tmpRect.right, tmpRect.bottom
End Sub

Public Function GetCommandLine() As String
Attribute GetCommandLine.VB_HelpID = 2057
Attribute GetCommandLine.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim addr As Long
    
    addr = apiGetCommandLine()
    GetCommandLine = agGetStringFromPointer(addr)
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetComputerName() As String
Attribute GetComputerName.VB_HelpID = 2412
Attribute GetComputerName.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    Dim strng$
    Dim strngLen&
    
    strng$ = String$(MAX_COMPUTERNAME_LENGTH + 1, 0)
    strngLen& = MAX_COMPUTERNAME_LENGTH
    ret& = apiGetComputerName(strng$, strngLen&)
    If ret& = 0 Then RaiseSysError
    GetComputerName = left$(strng$, strngLen&)
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetCursorPos() As dwPoint
Attribute GetCursorPos.VB_HelpID = 2964
Attribute GetCursorPos.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim tmpdwPoint As New dwPoint
    Dim tmpPoint As POINTAPI
    Dim ret&

#If Win32 Then
    ret& = apiGetCursorPos(tmpPoint)
    If ret& = 0 Then RaiseSysError
#Else
    apiGetCursorPos tmpPoint
#End If
    tmpdwPoint.x = tmpPoint.x
    tmpdwPoint.y = tmpPoint.y
    Set GetCursorPos = tmpdwPoint
End Function

Public Function GetDoubleClickTime() As Long
Attribute GetDoubleClickTime.VB_HelpID = 2778
Attribute GetDoubleClickTime.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    GetDoubleClickTime = apiGetDoubleClickTime()
End Function

Public Function GetInputState() As Boolean
Attribute GetInputState.VB_HelpID = 2869
Attribute GetInputState.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    If apiGetInputState() = 0 Then
        GetInputState = False
    Else
        GetInputState = True
    End If
End Function

Public Function GetKeyboardLayoutName() As String
Attribute GetKeyboardLayoutName.VB_HelpID = 2743
Attribute GetKeyboardLayoutName.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim strng As String
    Dim ret&
    
    strng = String$(KL_NAMELENGTH, 0)
    ret& = apiGetKeyboardLayoutName(strng)
    If ret& = 0 Then RaiseSysError
    GetKeyboardLayoutName = strng
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

' lpClassName as String, lpWindowName as String
Public Function FindWindow(Optional lpClassName As Variant, Optional lpWindowName As Variant) As dwWindow
Attribute FindWindow.VB_HelpID = 2790
Attribute FindWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    Dim newWindow As New dwWindow

    If lpClassName = Empty Then
        ret& = apiFindWindow(vbNullString, CStr(lpWindowName))
    ElseIf lpWindowName = Empty Then
        ret& = apiFindWindow(CStr(lpClassName), vbNullString)
    Else
        ret& = apiFindWindow(CStr(lpClassName), CStr(lpWindowName))
    End If
    
    If ret& = 0 Then RaiseSysError
    
    newWindow.hWnd = ret&
    Set FindWindow = newWindow
End Function

Public Function GetActiveWindow() As dwWindow
Attribute GetActiveWindow.VB_HelpID = 2854
Attribute GetActiveWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim newWindow As New dwWindow
    
    newWindow.hWnd = apiGetActiveWindow()
    Set GetActiveWindow = newWindow
End Function

Public Function GetCapture() As dwWindow
Attribute GetCapture.VB_HelpID = 2871
Attribute GetCapture.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim newWindow As New dwWindow

    newWindow.hWnd = apiGetCapture()
    Set GetCapture = newWindow
End Function

Public Function GetDesktopWindow() As dwWindow
Attribute GetDesktopWindow.VB_HelpID = 3007
Attribute GetDesktopWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim newWindow As New dwWindow

    newWindow.hWnd = apiGetDesktopWindow()
    Set GetDesktopWindow = newWindow
End Function

Public Function GetFocus() As dwWindow
Attribute GetFocus.VB_HelpID = 2853
Attribute GetFocus.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim newWindow As New dwWindow

    newWindow.hWnd = apiGetFocus()
    Set GetFocus = newWindow
End Function

Public Function GetForegroundWindow() As dwWindow
Attribute GetForegroundWindow.VB_HelpID = 2919
Attribute GetForegroundWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim newWindow As New dwWindow

    newWindow.hWnd = apiGetForegroundWindow()
    Set GetForegroundWindow = newWindow
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetLastActivePopup(hwndOwner As dwWindow) As dwWindow
Attribute GetLastActivePopup.VB_HelpID = 3015
Attribute GetLastActivePopup.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim newWindow As New dwWindow

    newWindow.hWnd = apiGetLastActivePopup(hwndOwner.hWnd)
    Set GetLastActivePopup = newWindow
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function WindowFromPoint(pPoint As dwPoint) As dwWindow
Attribute WindowFromPoint.VB_HelpID = 2980
Attribute WindowFromPoint.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret As Long
#Else
    Dim ret As Integer
    Dim lPnt As Long
#End If
    Dim newWindow As New dwWindow
    
#If Win32 Then
    ret = apiWindowFromPoint(pPoint.x, pPoint.y)
#Else
    lPnt = (pPoint.x * 65536) + pPoint.y ' convert point coordinates into a long integer
    ret = apiWindowFromPoint(lPnt)
#End If
    If ret = 0 Then RaiseSysError
    newWindow.hWnd = ret
    Set WindowFromPoint = newWindow
End Function

Public Sub AdjustWindowRect(lpRect As dwRECT, ByVal dwStyle As Long, ByVal bMenu As Long)
Attribute AdjustWindowRect.VB_HelpID = 2956
Attribute AdjustWindowRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    lpRect.AdjustWindowRect dwStyle, bMenu
End Sub

Public Sub AdjustWindowRectEx(lpRect As dwRECT, ByVal dwStyle, ByVal bMenu As Long, ByVal dwEsStyle As Long)
Attribute AdjustWindowRectEx.VB_HelpID = 2957
Attribute AdjustWindowRectEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    lpRect.AdjustWindowRectEx dwStyle, bMenu, dwEsStyle
End Sub

Public Sub GdiFlush()
Attribute GdiFlush.VB_HelpID = 2717
Attribute GdiFlush.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGdiFlush()
    If ret& = 0 Then RaiseSysError
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Sub

Public Function GdiGetBatchLimit() As Long
Attribute GdiGetBatchLimit.VB_HelpID = 2719
Attribute GdiGetBatchLimit.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGdiGetBatchLimit()
    If ret& = 0 Then RaiseSysError
    GdiGetBatchLimit = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GdiSetBatchLimit(ByVal dwLimit As Long) As Long
Attribute GdiSetBatchLimit.VB_HelpID = 2718
Attribute GdiSetBatchLimit.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGdiSetBatchLimit(dwLimit)
    If ret& = 0 Then RaiseSysError
    GdiSetBatchLimit = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

#If FlagMetaFile Then
Public Function GetEnhMetaFile(lpszMetaFile As String) As dwMetaFile
Attribute GetEnhMetaFile.VB_HelpID = 2645
Attribute GetEnhMetaFile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    Dim newMFile As New dwMetaFile
    
    ret& = apiGetEnhMetaFile(lpszMetaFile)
    newMFile.InitializeMetafile ret&, True
    Set GetEnhMetaFile = newMFile
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function
#End If ' FlagMetaFile

#If FlagMetaFile Then
Public Function GetMetaFile(lpszFileName As String) As dwMetaFile
Attribute GetMetaFile.VB_HelpID = 2558
Attribute GetMetaFile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    Dim newMFile As New dwMetaFile
    
    ret& = apiGetMetaFile(lpszFileName)
    newMFile.InitializeMetafile ret&, False
    Set GetMetaFile = newMFile
End Function
#End If ' FlagMetaFile

Public Function AnyPopup() As Long
Attribute AnyPopup.VB_HelpID = 2803
Attribute AnyPopup.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
    ret& = apiAnyPopup()
    If ret& = 0 Then RaiseSysError
    AnyPopup = ret&
End Function

Public Function GetKeyboardLayout(ByVal lLayout As Long) As Long
Attribute GetKeyboardLayout.VB_HelpID = 3550
Attribute GetKeyboardLayout.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGetKeyboardLayout(lLayout)
    If ret& = 0 Then RaiseSysError
    GetKeyboardLayout = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

#If Win32 Then
Public Sub GetKeyboardState(pbKeyState As Byte)
Attribute GetKeyboardState.VB_HelpID = 2858
Attribute GetKeyboardState.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
    ret& = apiGetKeyboardState(pbKeyState)
    If ret& = 0 Then RaiseSysError
End Sub
#Else ' pbKeyState should be a 256 character array
Public Sub GetKeyboardState(pbKeyState As Byte)
    apiGetKeyboardState pbKeyState
End Sub
#End If

Public Function GetKeyboardType(ByVal nTypeFlag As Long) As Long
Attribute GetKeyboardType.VB_HelpID = 2861
Attribute GetKeyboardType.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
    ret& = apiGetKeyboardType(nTypeFlag)
    If ret& = 0 Then RaiseSysError
    GetKeyboardType = ret&
End Function

Public Function GetKeyNameText(ByVal lParam As Long, lpBuffer As String, ByVal nSize As Long) As Long
Attribute GetKeyNameText.VB_HelpID = 2861
Attribute GetKeyNameText.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
    ret& = apiGetKeyNameText(lParam, lpBuffer, nSize)
    If ret& = 0 Then RaiseSysError
    GetKeyNameText = ret&
End Function

Public Function GetKeyState(ByVal nVirtKey As Long) As Integer
Attribute GetKeyState.VB_HelpID = 2856
Attribute GetKeyState.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    GetKeyState = apiGetKeyState(nVirtKey)
End Function

Public Function GetOEMCP() As Long
Attribute GetOEMCP.VB_HelpID = 2419
Attribute GetOEMCP.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGetOEMCP()
    If ret& = 0 Then RaiseSysError
    GetOEMCP = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetQueueStatus(ByVal fuFlags As Long) As Long
Attribute GetQueueStatus.VB_HelpID = 2870
Attribute GetQueueStatus.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
    ret& = apiGetQueueStatus(fuFlags)
    If ret& = 0 Then RaiseSysError
    GetQueueStatus = ret&
End Function


Public Function GetSystemDefaultLangID() As Integer
Attribute GetSystemDefaultLangID.VB_HelpID = 2431
Attribute GetSystemDefaultLangID.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGetSystemDefaultLangID()
    If ret& = 0 Then RaiseSysError
    GetSystemDefaultLangID = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetSystemDefaultLCID() As Long
Attribute GetSystemDefaultLCID.VB_HelpID = 2433
Attribute GetSystemDefaultLCID.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGetSystemDefaultLCID()
    If ret& = 0 Then RaiseSysError
    GetSystemDefaultLCID = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

'Only works under Win95
#If FlagGetSystemPowerStatus = True Then
Public Function GetSystemPowerStatus() As dwSysPower
Attribute GetSystemPowerStatus.VB_HelpID = 3421
Attribute GetSystemPowerStatus.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    Dim tempSysPower As SYSTEM_POWER_STATUS
    Dim tempSysPower2 As New dwSysPower
    
    ret& = apiGetSystemPowerStatus(tempSysPower)
    If ret& = 0 Then RaiseSysError
    Call tempSysPower2.SetSysPower(tempSysPower.ACLineStatus, tempSysPower.BatteryFlag, tempSysPower.BatteryLifePercent, tempSysPower.Reserved1, tempSysPower.BatteryLifeTime, tempSysPower.BatteryFullLifeTime)
    Set GetSystemPowerStatus = tempSysPower2
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function
#End If 'FlagGetSystemPowerStatus

Public Function GetThreadLocale() As Long
Attribute GetThreadLocale.VB_HelpID = 2441
Attribute GetThreadLocale.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGetThreadLocale()
    If ret& = 0 Then RaiseSysError
    GetThreadLocale = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetUserDefaultLangID() As Long
Attribute GetUserDefaultLangID.VB_HelpID = 2432
Attribute GetUserDefaultLangID.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGetUserDefaultLangID()
    If ret& = 0 Then RaiseSysError
    GetUserDefaultLangID = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetUserDefaultLCID() As Long
Attribute GetUserDefaultLCID.VB_HelpID = 2434
Attribute GetUserDefaultLCID.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiGetUserDefaultLCID()
    If ret& = 0 Then RaiseSysError
    GetUserDefaultLCID = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetUserName() As String
Attribute GetUserName.VB_HelpID = 2414
Attribute GetUserName.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim lpBuffer As String
    Dim ret&
    
    ret& = apiGetUserName(lpBuffer, MAX_LEN)
    If ret& = 0 Then RaiseSysError
    lpBuffer = left$(lpBuffer, ret&)
    GetUserName = lpBuffer
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function GetVersion() As Long
Attribute GetVersion.VB_HelpID = 2082
Attribute GetVersion.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
    ret& = apiGetVersion()
    If ret& = 0 Then RaiseSysError
    GetVersion = ret&
End Function

#If FlagGetVersionEx = True Then
Public Function GetVersionEx(lpVersionInformation As dwOSVersionInfo) As Long
Attribute GetVersionEx.VB_HelpID = 3420
Attribute GetVersionEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    Dim tempOSVerInfo As OSVERSIONINFO
    
    tempOSVerInfo.dwOSVersionInfoSize = 148
    ret& = apiGetVersionEx(tempOSVerInfo)
    lpVersionInformation.setOSVERSIONINFO tempOSVerInfo.dwOSVersionInfoSize, tempOSVerInfo.dwMajorVersion, tempOSVerInfo.dwMinorVersion, tempOSVerInfo.dwBuildNumber, tempOSVerInfo.dwPlatformId, tempOSVerInfo.szCSDVersion
    If ret& = 0 Then RaiseSysError
    GetVersionEx = ret&
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function
#End If 'FlagGetVersionEx

Public Function IsValidCodePage(CodePage As Long) As Boolean
Attribute IsValidCodePage.VB_HelpID = 2417
Attribute IsValidCodePage.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiIsValidCodePage(CodePage)
    If ret& = 0 Then
        IsValidCodePage = False
    Else
        IsValidCodePage = True
    End If
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Function IsValidLocale(Locale As Long, lFlags As Long) As Boolean
Attribute IsValidLocale.VB_HelpID = 2439
Attribute IsValidLocale.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiIsValidLocale(Locale, lFlags)
    If ret& = 0 Then
        IsValidLocale = False
    Else
        IsValidLocale = True
    End If
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Function

Public Sub MessageBeep(ByVal wType As Long)
Attribute MessageBeep.VB_HelpID = 2960
Attribute MessageBeep.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&

#If Win32 Then
    ret& = apiMessageBeep(wType)
    If ret& = 0 Then RaiseSysError
#Else
    apiMessageBeep wType
#End If
End Sub

Public Sub SetCaretBlinkTime(ByVal wMSeconds As Long)
Attribute SetCaretBlinkTime.VB_HelpID = 2971
Attribute SetCaretBlinkTime.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
#If Win32 Then
    ret& = apiSetCaretBlinkTime(wMSeconds)
    If ret& = 0 Then RaiseSysError
#Else
    apiSetCaretBlinkTime wMSeconds
#End If
End Sub

Public Sub SetComputerName(ByVlpComputerName As String)
Attribute SetComputerName.VB_HelpID = 2413
Attribute SetComputerName.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiSetComputerName(ByVlpComputerName)
    If ret& = 0 Then RaiseSysError
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Sub

Public Sub SetCursorPos(pPoint As dwPoint)
Attribute SetCursorPos.VB_HelpID = 2962
Attribute SetCursorPos.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiSetCursorPos(pPoint.x, pPoint.y)
    If ret& = 0 Then RaiseSysError
#Else
    apiSetCursorPos pPoint.x, pPoint.y
#End If
End Sub

Public Sub SetDoubleClickTime(ByVal wCount As Long)
Attribute SetDoubleClickTime.VB_HelpID = 2779
Attribute SetDoubleClickTime.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiSetDoubleClickTime(wCount)
    If ret& = 0 Then RaiseSysError
#Else
    apiSetDoubleClickTime wCount
#End If
End Sub

Public Sub SetThreadLocale(Locale As Long)
Attribute SetThreadLocale.VB_HelpID = 2430
Attribute SetThreadLocale.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
#If Win32 Then
    Dim ret&
    
    ret& = apiSetThreadLocale(Locale)
    If ret& = 0 Then RaiseSysError
#Else
    RaiseSysError DWERR_NOTINWIN16
#End If
End Sub

Public Function ShowCursor(ByVal bShow As Long) As Long
Attribute ShowCursor.VB_HelpID = 2961
Attribute ShowCursor.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
    ret& = apiShowCursor(bShow)
    ShowCursor = ret&
End Function

Public Sub SwapMouseButton(ByVal bSwap As Long)
Attribute SwapMouseButton.VB_HelpID = 2757
Attribute SwapMouseButton.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim ret&
    
    ret& = apiSwapMouseButton(bSwap)
End Sub

Public Function GetKBCodePage() As Long
Attribute GetKBCodePage.VB_HelpID = 2855
Attribute GetKBCodePage.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    GetKBCodePage = apiGetKBCodePage()
End Function
 
#If FlagGlobalAlloc = True Then
Public Function GlobalAlloc(ByVal fuFlags As Long, cBytes As Long) As dwGlobalMemory
Attribute GlobalAlloc.VB_HelpID = 2108
Attribute GlobalAlloc.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Dim newGMem As New dwGlobalMemory
#If Win32 Then
    Dim ret As Long
#Else
    Dim ret As Integer
#End If
    
    ret = apiGlobalAlloc(fuFlags, cBytes)
    If ret = 0 Then RaiseSysError
    newGMem.InitializeGlobalMem ret
    Set GlobalAlloc = newGMem
End Function
#End If ' FlagGlobalAlloc

Public Function GetTickCount() As Long
Attribute GetTickCount.VB_HelpID = 2356
Attribute GetTickCount.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    GetTickCount = apiGetTickCount()
End Function


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' The following is for compatibility with the API
' Foundation Library Standard.  It is not a full
' implementation, as this library was completed before
' the final version of the standard was completed.
' There are also a number of functions that are not
' completed because of a lack of time or because adequate
' documentation was not provided.  The standard
' may change at any time after this libray is released,
' so the functions below may not be correct.

' The "Attach" functions are ways of setting up the
' class.  Most of the functions below are the same
' as the API functions above, but are renamed for
' some reason.


Public Function ActiveWindow() As dwWindow
Attribute ActiveWindow.VB_HelpID = 2854
Attribute ActiveWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Set ActiveWindow = GetActiveWindow()
End Function

Public Function CaptureWindow() As dwWindow
Attribute CaptureWindow.VB_HelpID = 2871
Attribute CaptureWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Set CaptureWindow = GetCapture()
End Function

Public Function ComputerName() As String
Attribute ComputerName.VB_HelpID = 2412
Attribute ComputerName.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    ComputerName = GetComputerName()
End Function

Public Function CurrentDirectory()

End Function

Public Function CursorPosition() As dwPoint
Attribute CursorPosition.VB_HelpID = 2964
Attribute CursorPosition.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Set CursorPosition = GetCursorPos()
End Function

Public Function DesktopWindow() As dwWindow
Attribute DesktopWindow.VB_HelpID = 2007
Attribute DesktopWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Set DesktopWindow = GetDesktopWindow()
End Function

Public Function FocusWindow() As dwWindow
Attribute FocusWindow.VB_HelpID = 2853
Attribute FocusWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Set FocusWindow = GetFocus()
End Function

Public Function ForegroundWindow() As dwWindow
Attribute ForegroundWindow.VB_HelpID = 2919
Attribute ForegroundWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    Set ForegroundWindow = GetForegroundWindow()
End Function

Public Function MessageBox(label As String, Optional title As Variant, Optional Style As Variant) As Long
    Dim tmpTitle As String
    Dim tmpStyle As Integer
    
    If IsMissing(title) Then
        tmpTitle = ""
    Else
        tmpTitle = title
    End If
    
    If IsMissing(Style) Then
        tmpStyle = 0& ' MB_OK
    Else
        tmpStyle = Style
    End If
    MessageBox = apiMessageBox(0, label, tmpTitle, tmpStyle)
End Function

Public Function TickCount() As Long
Attribute TickCount.VB_HelpID = 2356
Attribute TickCount.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
    TickCount = apiGetTickCount()
End Function
