Attribute VB_Name = "baswinAPI"
Option Explicit

'**********************************************************************************************************
' NAME:  WinAPI.BAS
' TITLE: Windows Application Programmer Interface Module.
' DESCR: This file defines some constants and declarations used to do Win32 API calls.
' NOTES: 1)
'
'**********************************************************************************************************

'----------------------------------------------------------------------------------------------------------
' Type Declarations
'----------------------------------------------------------------------------------------------------------

' CRITICAL_SECTION
' This is a type used with the Win32 API critical section calls.
' The VB API Viewer says the following is the definition of a CRITICAL_SECTION:
'
'   Type CRITICAL_SECTION
'        dummy As Long
'   End Type
'
' However, we've found out the hard way (crashing) that this is not the case.
' Using the WINNT.H and WINBASE.H files found in VC++, we have determined that this is closer to the truth:

Type CRITICAL_SECTION
    a As Long   ' PRTL_CRITICAL_SECTION_DEBUG DebugInfo;    (32-bit pointer)
    b As Long   ' LONG LockCount;                           (long)
    c As Long   ' LONG RecursionCount;                      (long)
    d As Long   ' HANDLE OwningThread;                      (HANDLE aka 32-bit pointer)
    e As Long   ' HANDLE LockSemaphore;                     (HANDLE aka 32-bit pointer)
    f As Long   ' DWORD Reserved;                           (Double Word 32-bits on Win32 platform)
End Type

'----------------------------------------------------------------------------------------------------------
' External Library Prototypes
'----------------------------------------------------------------------------------------------------------

Declare Sub InitializeCriticalSection Lib "kernel32" (lpCriticalSection As CRITICAL_SECTION)
Declare Sub EnterCriticalSection Lib "kernel32" (lpCriticalSection As CRITICAL_SECTION)
Declare Sub DeleteCriticalSection Lib "kernel32" (lpCriticalSection As CRITICAL_SECTION)
Declare Sub LeaveCriticalSection Lib "kernel32" (lpCriticalSection As CRITICAL_SECTION)


