source: trunk/ab5.0/ablib/src/api_system.sbp @ 560

Last change on this file since 560 was 556, checked in by NoWest, 15 years ago

kernel系のAPIを追加。

File size: 51.0 KB
Line 
1' api_system.sbp - System API
2
3#ifdef UNICODE
4Const _FuncName_AddAtom = "AddAtomW"
5Const _FuncName_CompareString = "CompareStringW"
6Const _FuncName_CopyFile = "CopyFileW"
7Const _FuncName_CreateDirectory = "CreateDirectoryW"
8Const _FuncName_CreateEvent = "CreateEventW"
9Const _FuncName_CreateMutex = "CreateMutexW"
10Const _FuncName_CreateSemaphore = "CreateSemaphoreW"
11Const _FuncName_CreateWaitableTimer = "CreateWaitableTimerW"
12Const _FuncName_CreateFile = "CreateFileW"
13Const _FuncName_CreateFileMapping = "CreateFileMappingW"
14Const _FuncName_OpenFileMapping = "OpenFileMappingW"
15Const _FuncName_CreateMailslot = "CreateMailslotW"
16Const _FuncName_CreateProcess = "CreateProcessW"
17Const _FuncName_DeleteFile = "DeleteFileW"
18Const _FuncName_ExpandEnvironmentStrings = "ExpandEnvironmentStringsW"
19Const _FuncName_FatalAppExit = "FatalAppExitW"
20Const _FuncName_FindAtom = "FindAtomW"
21Const _FuncName_FindFirstChangeNotification = "FindFirstChangeNotificationW"
22Const _FuncName_FindFirstFile = "FindFirstFileW"
23Const _FuncName_FindNextFile = "FindNextFileW"
24Const _FuncName_FindResource = "FindResourceW"
25Const _FuncName_FormatMessage = "FormatMessageW"
26Const _FuncName_FreeEnvironmentStrings = "FreeEnvironmentStringsW"
27Const _FuncName_GetCompressedFileSize = "GetCompressedFileSizeW"
28Const _FuncName_GetComputerName = "GetComputerNameW"
29Const _FuncName_GetCurrentDirectory = "GetCurrentDirectoryW"
30Const _FuncName_GetDateFormat = "GetDateFormatW"
31Const _FuncName_GetDiskFreeSpace = "GetDiskFreeSpaceW"
32Const _FuncName_GetDiskFreeSpaceEx = "GetDiskFreeSpaceExW"
33Const _FuncName_GetVolumeInformation = "GetVolumeInformationW"
34Const _FuncName_GetDriveType = "GetDriveTypeW"
35Const _FuncName_GetEnvironmentVariable = "GetEnvironmentVariableW"
36Const _FuncName_GetEnvironmentStrings = "GetEnvironmentStringsW"
37Const _FuncName_GetFileAttributes = "GetFileAttributesW"
38Const _FuncName_GetFullPathName = "GetFullPathNameW"
39Const _FuncName_GetAtomName = "GetAtomNameW"
40Const _FuncName_GlobalAddAtom = "GlobalAddAtomW"
41Const _FuncName_GlobalFindAtom = "GlobalFindAtomW"
42Const _FuncName_GlobalGetAtomName = "GlobalGetAtomNameW"
43Const _FuncName_GetLogicalDriveStrings = "GetLogicalDriveStringsW"
44Const _FuncName_GetLongPathName = "GetLongPathNameW"
45Const _FuncName_GetModuleFileName = "GetModuleFileNameW"
46Const _FuncName_GetModuleHandle = "GetModuleHandleW"
47Const _FuncName_GetShortPathName = "GetShortPathNameW"
48Const _FuncName_GetStartupInfo = "GetStartupInfoW"
49Const _FuncName_GetSystemDirectory = "GetSystemDirectoryW"
50Const _FuncName_GetTempFileName = "GetTempFileNameW"
51Const _FuncName_GetTempPath = "GetTempPathW"
52Const _FuncName_GetTimeFormat = "GetTimeFormatW"
53Const _FuncName_GetUserName = "GetUserNameW"
54Const _FuncName_GetVersionEx = "GetVersionExW"
55Const _FuncName_GetWindowsDirectory = "GetWindowsDirectoryW"
56Const _FuncName_LCMapString = "LCMapStringW"
57Const _FuncName_LoadLibrary = "LoadLibraryW"
58Const _FuncName_LoadLibraryEx = "LoadLibraryExW"
59Const _FuncName_LookupPrivilegeValue = "LookupPrivilegeValueW"
60Const _FuncName_lstrcat = "lstrcatW"
61Const _FuncName_lstrcmp = "lstrcmpW"
62Const _FuncName_lstrcmpi = "lstrcmpiW"
63Const _FuncName_lstrcpy = "lstrcpyW"
64Const _FuncName_lstrcpyn = "lstrcpynW"
65Const _FuncName_MoveFile = "MoveFileW"
66Const _FuncName_OpenEvent = "OpenEventW"
67Const _FuncName_OpenMutex = "OpenMutexW"
68Const _FuncName_OpenSemaphore = "OpenSemaphoreW"
69Const _FuncName_OpenWaitableTimer = "OpenWaitableTimerW"
70Const _FuncName_RemoveDirectory = "RemoveDirectoryW"
71Const _FuncName_SetComputerName = "SetComputerNameW"
72Const _FuncName_SetCurrentDirectory = "SetCurrentDirectoryW"
73Const _FuncName_SearchPath = "SearchPathW"
74Const _FuncName_SetEnvironmentVariable = "SetEnvironmentVariableW"
75Const _FuncName_SetFileAttributes = "SetFileAttributesW"
76#else
77Const _FuncName_AddAtom = "AddAtomA"
78Const _FuncName_CompareString = "CompareStringA"
79Const _FuncName_CopyFile = "CopyFileA"
80Const _FuncName_CreateDirectory = "CreateDirectoryA"
81Const _FuncName_CreateEvent = "CreateEventA"
82Const _FuncName_CreateMutex = "CreateMutexA"
83Const _FuncName_CreateSemaphore = "CreateSemaphoreA"
84Const _FuncName_CreateWaitableTimer = "CreateWaitableTimerA"
85Const _FuncName_CreateFile = "CreateFileA"
86Const _FuncName_CreateFileMapping = "CreateFileMappingA"
87Const _FuncName_OpenFileMapping = "OpenFileMappingA"
88Const _FuncName_CreateMailslot = "CreateMailslotA"
89Const _FuncName_CreateProcess = "CreateProcessA"
90Const _FuncName_DeleteFile = "DeleteFileA"
91Const _FuncName_ExpandEnvironmentStrings = "ExpandEnvironmentStringsA"
92Const _FuncName_FatalAppExit = "FatalAppExitA"
93Const _FuncName_FindAtom = "FindAtomA"
94Const _FuncName_FindFirstChangeNotification = "FindFirstChangeNotificationA"
95Const _FuncName_FindFirstFile = "FindFirstFileA"
96Const _FuncName_FindNextFile = "FindNextFileA"
97Const _FuncName_FindResource = "FindResourceA"
98Const _FuncName_FormatMessage = "FormatMessageA"
99Const _FuncName_FreeEnvironmentStrings = "FreeEnvironmentStringsA"
100Const _FuncName_GetAtomName = "GetAtomNameA"
101Const _FuncName_GlobalAddAtom = "GlobalAddAtomA"
102Const _FuncName_GlobalFindAtom = "GlobalFindAtomA"
103Const _FuncName_GlobalGetAtomName = "GlobalGetAtomNameA"
104Const _FuncName_GetCompressedFileSize = "GetCompressedFileSizeA"
105Const _FuncName_GetComputerName = "GetComputerNameA"
106Const _FuncName_GetCurrentDirectory = "GetCurrentDirectoryA"
107Const _FuncName_GetDateFormat = "GetDateFormatA"
108Const _FuncName_GetDiskFreeSpace = "GetDiskFreeSpaceA"
109Const _FuncName_GetDiskFreeSpaceEx = "GetDiskFreeSpaceExA"
110Const _FuncName_GetVolumeInformation = "GetVolumeInformationA"
111Const _FuncName_GetDriveType = "GetDriveTypeA"
112Const _FuncName_GetEnvironmentVariable = "GetEnvironmentVariableA"
113Const _FuncName_GetEnvironmentStrings = "GetEnvironmentStringsA"
114Const _FuncName_GetFileAttributes = "GetFileAttributesA"
115Const _FuncName_GetFullPathName = "GetFullPathNameA"
116Const _FuncName_GetLogicalDriveStrings = "GetLogicalDriveStringsA"
117Const _FuncName_GetLongPathName = "GetLongPathNameA"
118Const _FuncName_GetModuleFileName = "GetModuleFileNameA"
119Const _FuncName_GetModuleHandle = "GetModuleHandleA"
120Const _FuncName_GetShortPathName = "GetShortPathNameA"
121Const _FuncName_GetStartupInfo = "GetStartupInfoA"
122Const _FuncName_GetSystemDirectory = "GetSystemDirectoryA"
123Const _FuncName_GetTempFileName = "GetTempFileNameA"
124Const _FuncName_GetTempPath = "GetTempPathA"
125Const _FuncName_GetTimeFormat = "GetTimeFormatA"
126Const _FuncName_GetUserName = "GetUserNameA"
127Const _FuncName_GetVersionEx = "GetVersionExA"
128Const _FuncName_GetWindowsDirectory = "GetWindowsDirectoryA"
129Const _FuncName_LCMapString = "LCMapStringA"
130Const _FuncName_LoadLibrary = "LoadLibraryA"
131Const _FuncName_LoadLibraryEx = "LoadLibraryExA"
132Const _FuncName_LookupPrivilegeValue = "LookupPrivilegeValueA"
133Const _FuncName_lstrcat = "lstrcatA"
134Const _FuncName_lstrcmp = "lstrcmpA"
135Const _FuncName_lstrcmpi = "lstrcmpiA"
136Const _FuncName_lstrcpy = "lstrcpyA"
137Const _FuncName_lstrcpyn = "lstrcpynA"
138Const _FuncName_MoveFile = "MoveFileA"
139Const _FuncName_OpenEvent = "OpenEventA"
140Const _FuncName_OpenMutex = "OpenMutexA"
141Const _FuncName_OpenSemaphore = "OpenSemaphoreA"
142Const _FuncName_OpenWaitableTimer = "OpenWaitableTimerA"
143Const _FuncName_RemoveDirectory = "RemoveDirectoryA"
144Const _FuncName_SetComputerName = "SetComputerNameA"
145Const _FuncName_SetCurrentDirectory = "SetCurrentDirectoryA"
146Const _FuncName_SearchPath = "SearchPathA"
147Const _FuncName_SetEnvironmentVariable = "SetEnvironmentVariableA"
148Const _FuncName_SetFileAttributes = "SetFileAttributesA"
149#endif
150
151
152'-------------------
153' default constants
154Const INVALID_HANDLE_VALUE = -1 As HANDLE
155Const INVALID_FILE_SIZE = &HFFFFFFFF As DWord
156Const INVALID_SET_FILE_POINTER = &HFFFFFFFF As DWord
157Const INVALID_FILE_ATTRIBUTES = &HFFFFFFFF As DWord
158
159'-----------------
160' data structs
161
162'variable type - System
163TypeDef HFILE = Long
164Type _System_DeclareHandle_HANDLE:unused As DWord:End Type
165TypeDef HRSRC = *_System_DeclareHandle_HANDLE
166
167' File structure
168Type SECURITY_ATTRIBUTES
169    nLength As DWord
170    lpSecurityDescriptor As VoidPtr
171    bInheritHandle As BOOL
172End Type
173
174Type OVERLAPPED
175    Internal As ULONG_PTR
176    InternalHigh As ULONG_PTR
177    Offset As DWord
178    OffsetHigh As DWord
179    hEvent As HANDLE
180End Type
181
182' System time
183Type SYSTEMTIME
184    wYear As Word
185    wMonth As Word
186    wDayOfWeek As Word
187    wDay As Word
188    wHour As Word
189    wMinute As Word
190    wSecond As Word
191    wMilliseconds As Word
192End Type
193
194' Global Memory Flags
195Const GMEM_FIXED =          &H0000
196Const GMEM_MOVEABLE =       &H0002
197Const GMEM_NOCOMPACT =      &H0010
198Const GMEM_NODISCARD =      &H0020
199Const GMEM_ZEROINIT =       &H0040
200Const GMEM_MODIFY =         &H0080
201Const GMEM_DISCARDABLE =    &H0100
202Const GMEM_NOT_BANKED =     &H1000
203Const GMEM_SHARE =          &H2000
204Const GMEM_DDESHARE =       &H2000
205Const GMEM_INVALID_HANDLE = &H8000
206Const GHND =                GMEM_MOVEABLE or GMEM_ZEROINIT
207Const GPTR =                GMEM_FIXED or GMEM_ZEROINIT
208Const GMEM_DISCARDED =      &H4000
209
210' Locale flag
211Const LOCALE_NOUSEROVERRIDE = &H80000000
212
213'Critical Section
214Type CRITICAL_SECTION
215    DebugInfo As VoidPtr
216    LockCount As Long
217    RecursionCount As Long
218    OwningThread As HANDLE
219    LockSemaphore As HANDLE
220    SpinCount As ULONG_PTR
221End Type
222
223'Mutex
224Const MUTEX_ALL_ACCESS = MUTANT_ALL_ACCESS
225
226'Lmcons.ab
227Const UNLEN = 256
228
229'----------------------
230' Kernel Operation API
231#ifdef _WIN64
232Function InterlockedIncrement(ByRef lpAddend As Long) As Long
233    lpAddend++
234    Return lpAddend
235End Function
236Function InterlockedDecrement(ByRef lpAddend As Long) As Long
237    lpAddend--
238    Return lpAddend
239End Function
240Function InterlockedExchange(ByRef Target As Long, Value As Long) As Long
241    InterlockedExchange=Target
242    Target = Value
243End Function
244Function InterlockedCompareExchange(ByRef Destination As Long, Exchange As Long, Comperand As Long) As Long
245    InterlockedCompareExchange = Destination
246    If Destination = Comperand Then
247        Destination = Exchange
248    End If
249End Function
250Function InterlockedExchangeAdd(ByRef Addend As Long, Value As Long) As Long
251    InterlockedExchangeAdd = Addend
252    Addend += Value
253End Function
254Function InterlockedExchangePointer(ByRef Target As VoidPtr, Value As VoidPtr) As VoidPtr
255    InterlockedExchangePointer = Target
256    Target = Value
257End Function
258Function InterlockedCompareExchangePointer(ByRef Destination As VoidPtr, Exchange As VoidPtr, Comperand As VoidPtr) As VoidPtr
259    InterlockedCompareExchangePointer = Destination
260    If Destination = Comperand Then
261        Destination = Exchange
262    End If
263End Function
264#else
265Declare Function InterlockedIncrement Lib "kernel32" (ByRef lpAddend As Long) As Long
266Declare Function InterlockedDecrement Lib "kernel32" (ByRef lpAddend As Long) As Long
267Declare Function InterlockedExchange Lib "kernel32" (ByRef Target As Long, Value As Long) As Long
268Declare Function InterlockedCompareExchange Lib "kernel32" (ByRef Destination As Long, Exchange As Long, Comperand As Long) As Long
269Declare Function InterlockedExchangeAdd Lib "kernel32" (ByRef Addend As Long, Value As Long) As Long
270Declare Function InterlockedCompareExchangePointer Lib "kernel32" Alias "InterlockedCompareExchange" (ByRef Destination As VoidPtr, Exchange As VoidPtr, Comperand As VoidPtr) As VoidPtr
271Declare Function InterlockedExchangePointer Lib "kernel32" Alias "InterlockedExchange" (ByRef Target As VoidPtr, Value As VoidPtr) As VoidPtr
272#endif
273
274
275Declare Function Beep Lib "kernel32" (dwFreq As DWord, dwDuration As DWord) As BOOL
276Declare Function CloseHandle Lib "kernel32" (hObject As HANDLE) As BOOL
277
278Declare Function CompareFileTime Lib "kernel32" (ByRef FileTime1 As FILETIME, ByRef FileTime2 As FILETIME) As Long
279
280Const NORM_IGNORECASE =     &H00000001
281Const NORM_IGNORENONSPACE = &H00000002
282Const NORM_IGNORESYMBOLS =  &H00000004
283Const SORT_STRINGSORT =     &H00001000
284Const NORM_IGNOREKANATYPE = &H00010000
285Const NORM_IGNOREWIDTH =    &H00020000
286Const CSTR_LESS_THAN =    1
287Const CSTR_EQUAL =        2
288Const CSTR_GREATER_THAN = 3
289Declare Function CompareString Lib "kernel32" Alias _FuncName_CompareString (Locale As LCID, dwCmpFlags As DWord, pString1 As PCTSTR, cchCount1 As Long, pString2 As PCTSTR, cchCount2 As Long) As Long
290
291Declare Function CopyFile Lib "kernel32" Alias _FuncName_CopyFile (pExistingFileName As PCTSTR, pNewFileName As PCTSTR, bFailIfExists As BOOL) As BOOL
292Declare Function CreateDirectory Lib "kernel32" Alias _FuncName_CreateDirectory (pPathName As PCTSTR, pSecurityAttributes As *SECURITY_ATTRIBUTES) As BOOL
293Declare Function CreateEvent Lib "kernel32" Alias _FuncName_CreateEvent (pEventAttributes As *SECURITY_ATTRIBUTES, bManualReset As BOOL, bInitialState As BOOL, pName As PCTSTR) As HANDLE
294Declare Function CreateMutex Lib "kernel32" Alias _FuncName_CreateMutex (lpMutexAttributes As *SECURITY_ATTRIBUTES, bInitialOwner As BOOL, lpName As PCTSTR) As HANDLE
295Declare Function CreatePipe Lib "Kernel32" (
296    ByRef hReadPipe As HANDLE,
297    ByRef hWritePipe As HANDLE,
298    ByVal pPipeAttributes As *SECURITY_ATTRIBUTES,
299    ByVal nSize As DWord) As Long
300Declare Function CreateSemaphore Lib "kernel32" Alias _FuncName_CreateSemaphore (pSemaphoreAttributes As *SECURITY_ATTRIBUTES, lInitialCount As Long, lMaximumCount As Long, pName As PCTSTR) As HANDLE
301
302TypeDef PTIMERAPCROUTINE = *Sub(lpArgToCompletionRoutine As VoidPtr, dwTimerLowValue As DWord, dwTimerHighValue As DWord)
303Declare Function CreateWaitableTimer Lib "kernel32" Alias _FuncName_CreateWaitableTimer (pTimerAttributes As *SECURITY_ATTRIBUTES, bManualReset As BOOL, pTimerName As PCTSTR) As HANDLE
304Declare Function OpenWaitableTimer Lib "kernel32" Alias _FuncName_OpenWaitableTimer (dwDesiredAccess As DWord, bInheritHandle As BOOL, pTimerName As PCTSTR) As HANDLE
305Declare Function SetWaitableTimer Lib "kernel32" (hTimer As HANDLE, pDueTime As *LARGE_INTEGER, lPeriod As Long, pfnCompletionRoutine As PTIMERAPCROUTINE, pArgToCompletionRoutine As VoidPtr, fResume As BOOL) As BOOL
306Declare Function CancelWaitableTimer Lib "kernel32" (hTimer As HANDLE) As BOOL
307
308Const CREATE_NEW =        1
309Const CREATE_ALWAYS =     2
310Const OPEN_EXISTING =     3
311Const OPEN_ALWAYS =       4
312Const TRUNCATE_EXISTING = 5
313Const FILE_FLAG_WRITE_THROUGH =       &H80000000
314Const FILE_FLAG_OVERLAPPED =          &H40000000
315Const FILE_FLAG_NO_BUFFERING =        &H20000000
316Const FILE_FLAG_RANDOM_ACCESS =       &H10000000
317Const FILE_FLAG_SEQUENTIAL_SCAN =     &H08000000
318Const FILE_FLAG_DELETE_ON_CLOSE =     &H04000000
319Const FILE_FLAG_BACKUP_SEMANTICS =    &H02000000
320Const FILE_FLAG_POSIX_SEMANTICS =     &H01000000
321Const FILE_FLAG_OPEN_REPARSE_POINT =  &H00200000
322Const FILE_FLAG_OPEN_NO_RECALL =      &H00100000
323Declare Function CreateFile Lib "kernel32" Alias _FuncName_CreateFile (pFileName As PCTSTR, dwDesiredAccess As DWord, dwShareMode As DWord, ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, dwCreationDisposition As DWord, dwFlagsAndAttributes As DWord, hTemplateFile As HANDLE) As HANDLE
324
325Const FILE_MAP_COPY   = SECTION_QUERY
326Const FILE_MAP_WRITE   = SECTION_MAP_WRITE
327Const FILE_MAP_READ   = SECTION_MAP_READ
328Const FILE_MAP_ALL_ACCESS  =  SECTION_ALL_ACCESS
329Declare Function CreateFileMapping Lib "kernel32" Alias _FuncName_CreateFileMapping (hFile As HANDLE, pFileMappingAttributes As *SECURITY_ATTRIBUTES, flProtect As DWord, dwMaximumSizeHigh As DWord, dwMaximumSizeLow As DWord, pName As PCSTR) As HANDLE
330Declare Function OpenFileMapping Lib "kernel32" Alias _FuncName_OpenFileMapping (dwDesiredAccess As DWord, bInheritHandle As BOOL, pName As PCSTR) As HANDLE
331Declare Function MapViewOfFile Lib "kernel32" (hFileMappingObject As HANDLE, dwDesiredAccess As DWord, dwFileOffsetHigh As DWord, dwFileOffsetLow As DWord, dwNumberOfBytesToMap As DWord) As VoidPtr
332Declare Function MapViewOfFileEx Lib "kernel32" (hFileMappingObject As HANDLE, dwDesiredAccess As DWord, dwFileOffsetHigh As DWord, dwFileOffsetLow As DWord, dwNumberOfBytesToMap As DWord, lpBaseAddress As VoidPtr) As VoidPtr
333Declare Function FlushViewOfFile Lib "kernel32" (lpBaseAddress As VoidPtr, dwNumberOfBytesToFlush As DWord) As BOOL
334Declare Function UnmapViewOfFile Lib "kernel32" (lpBaseAddress As VoidPtr) As BOOL
335Declare Function CreateMailslot Lib "kernel32" Alias _FuncName_CreateMailslot (pName As PCTSTR, nMaxMessageSize As DWord, lReadTimeout As DWord, pSecurityAttributes As *SECURITY_ATTRIBUTES) As HANDLE
336
337Const DEBUG_PROCESS =              &H00000001
338Const DEBUG_ONLY_THIS_PROCESS =    &H00000002
339Const CREATE_SUSPENDED =           &H00000004
340Const DETACHED_PROCESS =           &H00000008
341Const CREATE_NEW_CONSOLE =         &H00000010
342Const NORMAL_PRIORITY_CLASS =      &H00000020
343Const IDLE_PRIORITY_CLASS =        &H00000040
344Const HIGH_PRIORITY_CLASS =        &H00000080
345Const REALTIME_PRIORITY_CLASS =    &H00000100
346Const CREATE_NEW_PROCESS_GROUP =   &H00000200
347Const CREATE_UNICODE_ENVIRONMENT = &H00000400
348Const CREATE_SEPARATE_WOW_VDM =    &H00000800
349Const CREATE_SHARED_WOW_VDM =      &H00001000
350Const CREATE_FORCEDOS =            &H00002000
351Const CREATE_DEFAULT_ERROR_MODE =  &H04000000
352Const CREATE_NO_WINDOW =           &H08000000
353Const PROFILE_USER =               &H10000000
354Const PROFILE_KERNEL =             &H20000000
355Const PROFILE_SERVER =             &H40000000
356
357Const STARTF_USESHOWWINDOW =    &H00000001
358Const STARTF_USESIZE =          &H00000002
359Const STARTF_USEPOSITION =      &H00000004
360Const STARTF_USECOUNTCHARS =    &H00000008
361Const STARTF_USEFILLATTRIBUTE = &H00000010
362Const STARTF_RUNFULLSCREEN =    &H00000020
363Const STARTF_FORCEONFEEDBACK =  &H00000040
364Const STARTF_FORCEOFFFEEDBACK = &H00000080
365Const STARTF_USESTDHANDLES =    &H00000100
366Const STARTF_USEHOTKEY =        &H00000200
367Type STARTUPINFOW
368    cb As DWord
369    lpReserved As LPWSTR
370    lpDesktop As LPWSTR
371    lpTitle As LPWSTR
372    dwX As DWord
373    dwY As DWord
374    dwXSize As DWord
375    dwYSize As DWord
376    dwXCountChars As DWord
377    dwYCountChars As DWord
378    dwFillAttribute As DWord
379    dwFlags As DWord
380    wShowWindow As Word
381    cbReserved2 As Word
382    lpReserved2 As *Byte
383    hStdInput As HANDLE
384    hStdOutput As HANDLE
385    hStdError As HANDLE
386End Type
387Type STARTUPINFOA
388    cb As DWord
389    lpReserved As LPSTR
390    lpDesktop As LPSTR
391    lpTitle As LPSTR
392    dwX As DWord
393    dwY As DWord
394    dwXSize As DWord
395    dwYSize As DWord
396    dwXCountChars As DWord
397    dwYCountChars As DWord
398    dwFillAttribute As DWord
399    dwFlags As DWord
400    wShowWindow As Word
401    cbReserved2 As Word
402    lpReserved2 As *Byte
403    hStdInput As HANDLE
404    hStdOutput As HANDLE
405    hStdError As HANDLE
406End Type
407#ifdef UNICODE
408TypeDef STARTUPINFO = STARTUPINFOW
409#else
410TypeDef STARTUPINFO = STARTUPINFOA
411#endif
412Type PROCESS_INFORMATION
413    hProcess As HANDLE
414    hThread As HANDLE
415    dwProcessId As DWord
416    dwThreadId As DWord
417End Type
418Declare Function CreateProcess Lib "kernel32" Alias _FuncName_CreateProcess (pApplicationName As PCTSTR, pCommandLine As PTSTR, ByRef ProcessAttributes As SECURITY_ATTRIBUTES, ByRef ThreadAttributes As SECURITY_ATTRIBUTES, bInheritHandles As BOOL, dwCreationFlags As DWord, lpEnvironment As VoidPtr, pCurrentDirectory As PCTSTR, ByRef lpStartupInfo As STARTUPINFO, ByRef lpProcessInformation As PROCESS_INFORMATION) As BOOL
419
420TypeDef LPTHREAD_START_ROUTINE = *Function(lpThreadParameter As VoidPtr) As DWord
421Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As *SECURITY_ATTRIBUTES, dwStackSize As DWord, lpStartAddress As LPTHREAD_START_ROUTINE, pParameter As VoidPtr, dwCreationFlags As DWord, ByRef ThreadId As DWord) As HANDLE
422
423Declare Sub DebugBreak Lib "kernel32" ()
424Declare Sub DeleteCriticalSection Lib "kernel32" (ByRef CriticalSection As CRITICAL_SECTION)
425Declare Function DeleteFile Lib "kernel32" Alias _FuncName_DeleteFile (pFileName As PCTSTR) As BOOL
426Declare Function DeviceIoControl Lib "Kernel32" (
427    hDevice As HANDLE,
428    dwIoControlCode As DWord,
429    pInBuffer As VoidPtr,
430    nInBufferSize As DWord,
431    pOutBuffer As VoidPtr,
432    nOutBufferSize As DWord,
433    pBytesReturned As DWordPtr,
434    pOverlapped As *OVERLAPPED
435) As Long
436Declare Function DisableThreadLibraryCalls Lib "kernel32" (hLibModule As HINSTANCE) As BOOL
437Declare Function DosDateTimeToFileTime Lib "kernel32" (wFatDate As Word, wFatTime As Word, ByRef FileTime As FILETIME) As BOOL
438Declare Function DuplicateHandle Lib "kernel32" (hSourceProcessHandle As HANDLE, hSourceHandle As HANDLE, hTargetProcessHandle As HANDLE, ByRef TargetHandle As HANDLE, dwDesiredAccess As DWord, bInheritHandle As BOOL, dwOptions As DWord) As BOOL
439Declare Sub EnterCriticalSection Lib "kernel32" (ByRef lpCriticalSection As CRITICAL_SECTION)
440Declare Sub ExitProcess Lib "kernel32" (dwExitCode As DWord)
441Declare Sub ExitThread Lib "kernel32" (dwExitCode As DWord)
442Declare Sub FatalAppExit Lib "kernel32" Alias _FuncName_FatalAppExit (Action As DWord, pMessageText As PCTSTR)
443Declare Function FileTimeToDosDateTime Lib "kernel32" (ByRef lpFileTime As FILETIME, ByRef lpFatDate As Word, ByRef lpFatTime As Word) As BOOL
444Declare Function FileTimeToLocalFileTime Lib "kernel32" (ByRef lpFileTime As FILETIME, ByRef lpLocalFileTime As FILETIME) As BOOL
445Declare Function FileTimeToSystemTime Lib "kernel32" (ByRef lpFileTime As FILETIME, ByRef lpSystemTime As SYSTEMTIME) As BOOL
446Declare Sub FillMemory Lib "kernel32" Alias "RtlFillMemory" (pDest As VoidPtr, stLength As SIZE_T, c As Byte)
447Declare Function FindClose Lib "kernel32" (hFindFile As HANDLE) As BOOL
448Declare Function FindCloseChangeNotification Lib "kernel32" (hChangeHandle As HANDLE) As BOOL
449Declare Function FindFirstChangeNotification Lib "kernel32" Alias _FuncName_FindFirstChangeNotification (
450    pPathName As PCTSTR,
451    bWatchSubtree As BOOL,
452    dwNotifyFilter As DWord
453) As HANDLE
454
455Type WIN32_FIND_DATAW
456    dwFileAttributes As DWord
457    ftCreationTime As FILETIME
458    ftLastAccessTime As FILETIME
459    ftLastWriteTime As FILETIME
460    nFileSizeHigh As DWord
461    nFileSizeLow As DWord
462    dwReserved0 As DWord
463    dwReserved1 As DWord
464    cFileName[ELM(MAX_PATH)] As WCHAR
465    cAlternateFileName[13] As WCHAR
466End Type
467Type WIN32_FIND_DATAA
468    dwFileAttributes As DWord
469    ftCreationTime As FILETIME
470    ftLastAccessTime As FILETIME
471    ftLastWriteTime As FILETIME
472    nFileSizeHigh As DWord
473    nFileSizeLow As DWord
474    dwReserved0 As DWord
475    dwReserved1 As DWord
476    cFileName[ELM(MAX_PATH)] As SByte
477    cAlternateFileName[13] As SByte
478End Type
479#ifdef UNICODE
480TypeDef WIN32_FIND_DATA = WIN32_FIND_DATAW
481#else
482TypeDef WIN32_FIND_DATA = WIN32_FIND_DATAA
483#endif
484TypeDef LPWIN32_FIND_DATA = *WIN32_FIND_DATA
485Declare Function FindFirstFile Lib "kernel32" Alias _FuncName_FindFirstFile (pFileName As PCTSTR, ByRef FindFildData As WIN32_FIND_DATA) As HANDLE
486Declare Function FindNextChangeNotification Lib "kernel32" (hChangeHandle As HANDLE) As BOOL
487Declare Function FindNextFile Lib "kernel32" Alias _FuncName_FindNextFile (hFindFile As HANDLE, ByRef FindFildData As WIN32_FIND_DATA) As BOOL
488Declare Function FlushFileBuffers Lib "kernel32" (hFile As HANDLE) As BOOL
489Declare Function FlushInstructionCache Lib "kernel32" (hProcess As HANDLE, pBaseAddress As VoidPtr, Size As SIZE_T) As BOOL
490
491Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H00000100
492Const FORMAT_MESSAGE_IGNORE_INSERTS =  &H00000200
493Const FORMAT_MESSAGE_FROM_STRING =     &H00000400
494Const FORMAT_MESSAGE_FROM_HMODULE =    &H00000800
495Const FORMAT_MESSAGE_FROM_SYSTEM =     &H00001000
496Const FORMAT_MESSAGE_ARGUMENT_ARRAY =  &H00002000
497Declare Function FormatMessage Lib "kernel32" Alias _FuncName_FormatMessage (dwFlags As DWord, lpSource As VoidPtr, dwMessageId As DWord, dwLanguageId As DWord, pBuffer As PTSTR, nSize As DWord, Arguments As *DWord) As DWord
498Declare Function FreeEnvironmentStrings Lib "kernel32" Alias _FuncName_FreeEnvironmentStrings (pszEnvironmentBlock As PCTSTR) As BOOL
499Declare Function FreeLibrary Lib "kernel32" (hLibModule As HINSTANCE) As BOOL
500Declare Sub FreeLibraryAndExitThread Lib "kernel32" (hModule As HANDLE, dwExitCode As DWord)
501Declare Function GetCommandLineA Lib "kernel32" () As PCSTR
502Declare Function GetCommandLineW Lib "kernel32" () As PCWSTR
503#ifdef UNICODE
504Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineW" () As PCWSTR
505#else
506Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA" () As PCSTR
507#endif
508Declare Function GetCompressedFileSize Lib "kernel32" Alias _FuncName_GetCompressedFileSize (pFileName As PCTSTR, ByRef FileSizeHigh As DWord) As DWord
509
510Const MAX_COMPUTERNAME_LENGTH = 15
511Declare Function GetComputerName Lib "kernel32" Alias _FuncName_GetComputerName (pBuffer As PTSTR, ByRef nSize As DWord) As BOOL
512
513Declare Function GetCurrentDirectory Lib "kernel32" Alias _FuncName_GetCurrentDirectory (nBufferLength As DWord, pBuffer As PTSTR) As DWord
514Declare Function GetCurrentProcess Lib "kernel32" () As HANDLE
515Declare Function GetCurrentProcessId Lib "kernel32" () As DWord
516Declare Function GetCurrentThread Lib "kernel32" () As HANDLE
517Declare Function GetCurrentThreadId Lib "kernel32" () As DWord
518
519Const DATE_SHORTDATE =        &H00000001
520Const DATE_LONGDATE =         &H00000002
521Const DATE_USE_ALT_CALENDAR = &H00000004
522Declare Function GetDateFormat Lib "kernel32" Alias _FuncName_GetDateFormat (Locale As LCID, dwFlags As DWord, ByRef Date As SYSTEMTIME, pFormat As PCTSTR, pDateStr As PTSTR, cchDate As Long) As Long
523
524Declare Function GetDiskFreeSpace Lib "kernel32" Alias _FuncName_GetDiskFreeSpace (pRootPathName As PCTSTR, lpSectorsPerCluster As *DWord, pBytesPerSector As *DWord, pNumberOfFreeClusters As *DWord, pTotalNumberOfClusters As *DWord) As BOOL
525Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias _FuncName_GetDiskFreeSpaceEx (pDirectoryName As PCTSTR, ByRef lpFreeBytesAvailableToCaller As ULARGE_INTEGER, ByRef TotalNumberOfBytes As ULARGE_INTEGER, ByRef TotalNumberOfFreeBytes As ULARGE_INTEGER) As BOOL
526
527Const DRIVE_UNKNOWN =     0
528Const DRIVE_NO_ROOT_DIR = 1
529Const DRIVE_REMOVABLE =   2
530Const DRIVE_FIXED =       3
531Const DRIVE_REMOTE =      4
532Const DRIVE_CDROM =       5
533Const DRIVE_RAMDISK =     6
534Declare Function GetVolumeInformation Lib "kernel32" Alias _FuncName_GetVolumeInformation (pRootPathName As PCTSTR, pVolumeNameBuffer As PTSTR, nVolumeNameSize As DWord, lpVolumeSerialNumber As *Word, lpMaximumComponentLength As *Word, lpFileSystemFlags As *Word, pFileSystemNameBuffer As PTSTR, nFileSystemNameSize As DWord) As BOOL
535Declare Function GetDriveType Lib "kernel32" Alias _FuncName_GetDriveType (lpRootPathName As PCTSTR) As DWord
536
537Declare Function GetEnvironmentVariable Lib "kernel32" Alias _FuncName_GetEnvironmentVariable (lpName As PCTSTR, lpBuffer As PTSTR, nSize As DWord) As DWord
538Declare Function GetEnvironmentStrings Lib "kernel32" Alias _FuncName_GetEnvironmentStrings () As VoidPtr
539Const STILL_ACTIVE = &H00000103
540Declare Function GetExitCodeProcess Lib "kernel32" (hProcess As HANDLE, ByRef lpExitCode As DWord) As BOOL
541Declare Function GetExitCodeThread Lib "kernel32" (hThread As HANDLE, ByRef lpExitCode As DWord) As BOOL
542
543Declare Function GetFileAttributes Lib "kernel32" Alias _FuncName_GetFileAttributes (lpFileName As PCTSTR) As DWord
544Type BY_HANDLE_FILE_INFORMATION
545    dwFileAttributes As DWord
546    ftCreationTime As FILETIME
547    ftLastAccessTime As FILETIME
548    ftLastWriteTime As FILETIME
549    dwVolumeSerialNumber As DWord
550    nFileSizeHigh As DWord
551    nFileSizeLow As DWord
552    nNumberOfLinks As DWord
553    nFileIndexHigh As DWord
554    nFileIndexLow As DWord
555End Type
556Declare Function GetFileInformationByHandle Lib "kernel32" (
557    ByVal hFile As HANDLE,
558    ByRef FileInformation As BY_HANDLE_FILE_INFORMATION
559) As BOOL
560Declare Function GetFileSize Lib "kernel32" (hFile As HANDLE, pFileSizeHigh As *DWord) As DWord
561Declare Function GetFileSizeEx Lib "kernel32" (hFile As HANDLE, pFileSizeHigh As *QWord) As Boolean
562Declare Function GetFileTime Lib "kernel32" (hFile As HANDLE, ByRef lpCreationTime As FILETIME, ByRef lpLastAccessTime As FILETIME, ByRef lpLastWriteTime As FILETIME) As BOOL
563
564Const FILE_TYPE_UNKNOWN = &H0000
565Const FILE_TYPE_DISK =    &H0001
566Const FILE_TYPE_CHAR =    &H0002
567Const FILE_TYPE_PIPE =    &H0003
568Const FILE_TYPE_REMOTE =  &H8000
569Declare Function GetFileType Lib "kernel32" (hFile As HANDLE) As DWord
570
571Declare Function GetFullPathName Lib "kernel32" Alias _FuncName_GetFullPathName (lpFileName As PCSTR, nBufferLength As DWord, pBuffer As PSTR, lpFilePart As *DWord) As DWord
572Declare Function GetLastError Lib "kernel32" () As DWord
573Declare Sub GetLocalTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME)
574Declare Function GetLogicalDrives Lib "kernel32" () As DWord
575Declare Function GetLogicalDriveStrings Lib "kernel32" Alias _FuncName_GetLogicalDriveStrings (nBufferLength As DWord, pBuffer As PTSTR) As DWord
576Declare Function GetLongPathName Lib "kernel32" Alias _FuncName_GetLongPathName (lpszShortPath As LPCTSTR, lpszLongPath As LPTSTR, cchBuffer As DWord) As DWord
577Declare Function GetModuleFileName Lib "kernel32" Alias _FuncName_GetModuleFileName (hModule As HINSTANCE, lpFileName As PTSTR, nSize As DWord) As DWord
578Declare Function GetModuleHandle Lib "kernel32" Alias _FuncName_GetModuleHandle (lpModuleName As PTSTR) As HINSTANCE
579Declare Function GetOverlappedResult Lib "kernel32" (
580    hFile As HANDLE,
581    ByRef Overlapped As OVERLAPPED,
582    ByRef pNumberOfBytesTransferred As DWord,
583    bWait As BOOL
584) As BOOL
585Type SYSTEM_POWER_STATUS
586    ACLineStatus As Byte
587    BatteryFlag As Byte
588    BatteryLifePercent As Byte
589    Reserved1 As Byte
590    BatteryLifeTime As Long
591    BatteryFullLifeTime As Long
592End Type
593Declare Function GetSystemPowerStatus Lib "kernel32" (ByRef SystemPowerStatus As SYSTEM_POWER_STATUS) As Long
594Declare Function GetPriorityClass Lib "kernel32" (hProcess As HANDLE) As DWord
595Declare Function GetProcAddress Lib "kernel32" (hModule As HINSTANCE, pProcName As PCSTR) As DWord
596Declare Function GetProcessAffinityMask Lib "kernel32" (
597    hProcess As HANDLE,
598    ByRef ProcessAffinityMask As ULONG_PTR,
599    ByRef SystemAffinityMask As ULONG_PTR
600) As BOOL
601Declare Function GetProcessHeap Lib "kernel32" () As HANDLE
602Declare Function GetShortPathName Lib "kernel32" Alias _FuncName_GetShortPathName (
603    pszLongPath As PCTSTR,
604    pszShortPath As PTSTR,
605    cchBuffer As DWord
606) As DWord
607
608Declare Sub GetStartupInfo Lib "kernel32" Alias _FuncName_GetStartupInfo (ByRef StartupInfo As STARTUPINFO)
609
610Const STD_INPUT_HANDLE  = -10
611Const STD_OUTPUT_HANDLE = -11
612Const STD_ERROR_HANDLE  = -12
613Declare Function GetStdHandle Lib "kernel32" (nStdHandle As DWord) As HANDLE
614
615Declare Function GetSystemDirectory Lib "kernel32" Alias _FuncName_GetSystemDirectory (pBuffer As PTSTR, uSize As DWord) As DWord
616
617Type SYSTEM_INFO
618    dwOemId As DWord
619    dwPageSize As DWord
620    lpMinimumApplicationAddress As VoidPtr
621    lpMaximumApplicationAddress As VoidPtr
622    dwActiveProcessorMask As ULONG_PTR
623    dwNumberOfProcessors As DWord
624    dwProcessorType As DWord
625    dwAllocationGranularity As DWord
626    wProcessorLevel As Word
627    wProcessorRevision As Word
628End Type
629Declare Sub GetSystemInfo Lib "kernel32" (ByRef SystemInfo As SYSTEM_INFO)
630
631Declare Sub GetSystemTime Lib "kernel32" (ByRef SystemTime As SYSTEMTIME)
632Declare Sub GetSystemTimeAsFileTime Lib "kernel32" (ByRef SystemTimeAsFileTime As FILETIME)
633
634Declare Function GetTempFileName Lib "kernel32" Alias _FuncName_GetTempFileName (
635    pPathName As PCTSTR,
636    pPrefixString As PCTSTR,
637    uUnique As DWord,
638    pTempFileName As PTSTR
639) As DWord
640Declare Function GetTempPath Lib "kernel32" Alias _FuncName_GetTempPath (nBufferLength As DWord, lpBuffer As PTSTR) As DWord
641Declare Function GetThreadContext Lib "kernel32" (hThread As HANDLE, ByRef Context As CONTEXT) As BOOL
642/*
643Const THREAD_PRIORITY_LOWEST =        THREAD_BASE_PRIORITY_MIN
644Const THREAD_PRIORITY_BELOW_NORMAL =  THREAD_PRIORITY_LOWEST+1
645Const THREAD_PRIORITY_NORMAL =        0
646Const THREAD_PRIORITY_HIGHEST =       THREAD_BASE_PRIORITY_MAX
647Const THREAD_PRIORITY_ABOVE_NORMAL =  THREAD_PRIORITY_HIGHEST-1
648Const THREAD_PRIORITY_ERROR_RETURN =  LONG_MAX
649Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
650Const THREAD_PRIORITY_IDLE =          THREAD_BASE_PRIORITY_IDLE
651*/
652Declare Function GetThreadPriority Lib "kernel32" (hThread As HANDLE) As Long
653Declare Function GetThreadPriorityBoost Lib "kernel32" (
654    hThread As HANDLE,
655    ByRef pDisablePriorityBoost As BOOL) As BOOL
656Declare Function GetTickCount Lib "kernel32" () As DWord
657
658Const TIME_NOMINUTESORSECONDS  = &H00000001
659Const TIME_NOSECONDS           = &H00000002
660Const TIME_NOTIMEMARKER        = &H00000004
661Const TIME_FORCE24HOURFORMAT   = &H00000008
662Declare Function GetTimeFormat Lib "kernel32" Alias _FuncName_GetTimeFormat (Locale As LCID, dwFlags As DWord, ByRef Time As SYSTEMTIME, lpFormat As PCTSTR, lpTimeStr As PTSTR, cchTime As DWord) As BOOL
663Declare Function GetUserDefaultLCID Lib "kernel32" () As LCID
664Declare Function GetUserName Lib "advapi32" Alias _FuncName_GetUserName (pBuffer As PTSTR, ByRef nSize As DWord) As BOOL
665Declare Function GetVersionEx Lib "kernel32" Alias _FuncName_GetVersionEx (ByRef VersionInformation As OSVERSIONINFO) As BOOL
666Declare Function GetWindowsDirectory Lib "kernel32" Alias _FuncName_GetWindowsDirectory (pBuffer As PTSTR, uSize As DWord) As DWord
667Declare Function GlobalAlloc Lib "kernel32" (uFlags As DWord, dwBytes As SIZE_T) As HGLOBAL
668Declare Function GlobalFrags Lib "kernel32" (hMem As HGLOBAL) As DWord
669Declare Function GlobalFree Lib "kernel32" (hMem As HGLOBAL) As HGLOBAL
670Declare Function GlobalHandle Lib "kernel32" (pMem As VoidPtr) As HGLOBAL
671Declare Function GlobalLock Lib "kernel32" (hMem As HGLOBAL) As VoidPtr
672
673Type MEMORYSTATUS
674    dwLength As DWord
675    dwMemoryLoad As DWord
676    dwTotalPhys As SIZE_T
677    dwAvailPhys As SIZE_T
678    dwTotalPageFile As SIZE_T
679    dwAvailPageFile As SIZE_T
680    dwTotalVirtual As SIZE_T
681    dwAvailVirtual As SIZE_T
682End Type
683Declare Sub GlobalMemoryStatus Lib "kernel32" (ByRef lpMemStatus As MEMORYSTATUS)
684
685Declare Function GlobalReAlloc Lib "kernel32" (hMem As HGLOBAL, dwBytes As SIZE_T, uFlags As DWord) As HGLOBAL
686Declare Function GlobalSize Lib "kernel32" (hMem As HGLOBAL) As SIZE_T
687Declare Function GlobalUnlock Lib "kernel32" (hMem As HGLOBAL) As BOOL
688Declare Function HeapAlloc Lib "kernel32" (hHeap As HANDLE, dwFlags As DWord, dwBytes As SIZE_T) As VoidPtr
689Declare Function HeapCreate Lib "kernel32" (flOptions As DWord, dwInitialSize As SIZE_T, dwMaximumSize As SIZE_T) As HANDLE
690Declare Function HeapDestroy Lib "kernel32" (hHeap As HANDLE) As Long
691Declare Function HeapFree Lib "kernel32" (hHeap As HANDLE, dwFlags As DWord, lpMem As VoidPtr) As Long
692Declare Function HeapReAlloc Lib "kernel32" (hHeap As HANDLE, dwFlags As DWord, lpMem As VoidPtr, dwBytes As SIZE_T) As VoidPtr
693Declare Function HeapSize Lib "kernel32" (hHeap As HANDLE, dwFlags As DWord, lpMem As VoidPtr) As SIZE_T
694Declare Function HeapValidate Lib "kernel32" (hHeap As HANDLE, dwFlags As DWord, lpMem As VoidPtr) As BOOL
695Declare Sub InitializeCriticalSection Lib "kernel32" (ByRef CriticalSection As CRITICAL_SECTION)
696Declare Function IsBadReadPtr Lib "kernel32" (lp As VoidPtr, ucb As ULONG_PTR) As BOOL
697Declare Function IsBadWritePtr Lib "kernel32" (lp As VoidPtr, ucb As ULONG_PTR) As BOOL
698Declare Function IsDBCSLeadByte Lib "kernel32" (TestChar As Byte) As BOOL
699
700#ifdef _WIN64
701Declare Function IsWow64Process Lib "kernel32" (hProcess As HANDLE, ByRef bWow64Process As BOOL) As BOOL
702#endif
703
704Const LCMAP_LOWERCASE           = &H00000100  ' lower case letters
705Const LCMAP_UPPERCASE           = &H00000200  ' upper case letters
706Const LCMAP_SORTKEY             = &H00000400  ' WC sort key (normalize)
707Const LCMAP_BYTEREV             = &H00000800  ' byte reversal
708Const LCMAP_HIRAGANA            = &H00100000  ' map katakana to hiragana
709Const LCMAP_KATAKANA            = &H00200000  ' map hiragana to katakana
710Const LCMAP_HALFWIDTH           = &H00400000  ' map double byte to single byte
711Const LCMAP_FULLWIDTH           = &H00800000  ' map single byte to double byte
712Const LCMAP_LINGUISTIC_CASING   = &H01000000  ' use linguistic rules for casing
713Const LCMAP_SIMPLIFIED_CHINESE  = &H02000000  ' map traditional chinese to simplified chinese
714Const LCMAP_TRADITIONAL_CHINESE = &H04000000  ' map simplified chinese to traditional chinese
715Declare Function LCMapString Lib "kernel32" Alias _FuncName_LCMapString (Locale As LCID, dwMapFlags As DWord, lpSrcStr As LPCTSTR, cchSrc As Long, lpDestStr As LPTSTR, cchDest As Long) As Long
716
717Declare Sub LeaveCriticalSection Lib "kernel32" (ByRef lpCriticalSection As CRITICAL_SECTION)
718Declare Function LocalAlloc Lib "kernel32" (uFlags As DWord, uBytes As SIZE_T) As HLOCAL
719Declare Function LocalFileTimeToFileTime Lib "kernel32" (ByRef lpLocalFileTime As FILETIME, ByRef lpFileTime As FILETIME) As BOOL
720Declare Function LocalFree Lib "kernel32" (hMem As HLOCAL) As HLOCAL
721Declare Function LocalHandle Lib "kernel32" (pMem As VoidPtr) As HLOCAL
722Declare Function LocalLock Lib "kernel32" (hMem As HLOCAL) As VoidPtr
723Declare Function LocalReAlloc Lib "kernel32" (hMem As HLOCAL, dwBytes As SIZE_T, uFlags As DWord) As HLOCAL
724Declare Function LocalSize Lib "kernel32" (hMem As HLOCAL) As SIZE_T
725Declare Function LocalUnlock Lib "kernel32" (hMem As HLOCAL) As BOOL
726Declare Function LockFile Lib "kernel32" (hFile As HANDLE, dwFileOffsetLow As DWord, dwFileOffsetHigh As DWord, nNumberOfBytesToLockLow As DWord, nNumberOfBytesToLockHigh As DWord) As BOOL
727Declare Function LoadLibrary Lib "kernel32" Alias _FuncName_LoadLibrary (pLibFileName As PCTSTR) As HINSTANCE
728
729Const DONT_RESOLVE_DLL_REFERENCES   = &h00000001
730Const LOAD_LIBRARY_AS_DATAFILE      = &h00000002
731Const LOAD_WITH_ALTERED_SEARCH_PATH = &h00000008
732Const LOAD_IGNORE_CODE_AUTHZ_LEVEL  = &h00000010
733Declare Function LoadLibraryEx Lib "kernel32" Alias _FuncName_LoadLibraryEx (pLibFileName As PCTSTR, hFile As HANDLE, dwFlags As DWord) As HINSTANCE
734
735Declare Function lstrcat Lib "kernel32" Alias _FuncName_lstrcat (lpString1 As LPTSTR, lpString2 As LPCTSTR) As LPTSTR
736Declare Function lstrcmp Lib "kernel32" Alias _FuncName_lstrcmp (lpString1 As LPCTSTR, lpString2 As LPCTSTR) As Long
737Declare Function lstrcmpi Lib "kernel32" Alias _FuncName_lstrcmpi (lpString1 As LPCTSTR, lpString2 As LPCTSTR) As Long
738Declare Function lstrcpy Lib "kernel32" Alias _FuncName_lstrcpy (lpString1 As LPTSTR, lpString2 As LPCTSTR) As LPTSTR
739Declare Function lstrcpyn Lib "kernel32" Alias _FuncName_lstrcpyn (lpString1 As LPTSTR,ByVal lpString2 As LPCTSTR,ByVal iMaxLength As Long) As LPTSTR
740Declare Function lstrlenA Lib "kernel32" (lpString As LPCSTR) As Long
741Declare Function lstrlenW Lib "kernel32" (lpString As LPCWSTR) As Long
742#ifdef UNICODE
743Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" (lpString As LPCWSTR) As Long
744#else
745Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (lpString As LPCSTR) As Long
746#endif
747Declare Sub memcpy Lib "kernel32" Alias "RtlMoveMemory" (pDest As VoidPtr, pSrc As VoidPtr, length As SIZE_T)
748Declare Function MoveFile Lib "kernel32" Alias _FuncName_MoveFile (lpExistingFileName As LPCTSTR, lpNewFileName As LPCTSTR) As BOOL
749Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As PVOID, pSrc As VoidPtr, length As SIZE_T)
750
751Declare Function MulDiv Lib "kernel32" (
752    nNumber As Long,
753    nNumerator As Long,
754    nDenominator As Long
755) As Long
756
757Const CP_ACP        = 0      'default to ANSI code page
758Const CP_OEMCP      = 1      'default to OEM  code page
759Const CP_MACCP      = 2      'default to MAC  code page
760Const CP_THREAD_ACP = 3      'current thread's ANSI code page
761Const CP_SYMBOL     = 42     'SYMBOL translations
762Const CP_UTF7       = 65000  'UTF-7 translation
763Const CP_UTF8       = 65001  'UTF-8 translation
764
765Declare Function MultiByteToWideChar Lib "kernel32" (CodePage As DWord, dwFlags As DWord, pMultiByteStr As PCSTR, cchMultiByte As Long, pWideCharStr As PWSTR, cchWideChar As Long) As Long
766Declare Function OpenEvent Lib "kernel32" Alias _FuncName_OpenEvent (dwDesiredAccess As DWord, bInheritHandle As BOOL, lpName As LPCTSTR) As HANDLE
767Declare Function OpenMutex Lib "kernel32" Alias _FuncName_OpenMutex (dwDesiredAccess As DWord, bInheritHandle As BOOL, lpName As LPCTSTR) As HANDLE
768Declare Function OpenSemaphore Lib "kernel32" Alias _FuncName_OpenSemaphore (dwDesiredAccess As DWord, bInheritHandle As BOOL, lpName As LPCTSTR) As HANDLE
769Declare Function OpenProcess Lib "kernel32" (dwDesiredAccess As DWord, bInheritHandle As Long, dwProcessId As DWord) As HANDLE
770Declare Sub OutputDebugStringA Lib "kernel32" (pOutputString As PCSTR)
771Declare Sub OutputDebugStringW Lib "kernel32" (pOutputString As PCWSTR)
772#ifdef UNICODE
773Declare Sub OutputDebugString Lib "kernel32" Alias "OutputDebugStringW" (pOutputString As PCWSTR)
774#else
775Declare Sub OutputDebugString Lib "kernel32" Alias "OutputDebugStringA" (pOutputString As PCSTR)
776#endif
777Declare Function PulseEvent Lib "kernel32" (hEvent As HANDLE) As BOOL
778Declare Sub RaiseException Lib "kernel32" (
779    dwExceptionCode As DWord,
780    dwExceptionFlags As DWord,
781    NumberOfArguments As DWord,
782    pArguments As *ULONG_PTR)
783Declare Function ReadFile Lib "kernel32" (hFile As HANDLE, lpBuffer As VoidPtr, nNumberOfBytesToRead As DWord, lpNumberOfBytesRead As *DWord, ByRef Overlapped As OVERLAPPED) As BOOL
784Declare Function ReadProcessMemory Lib "Kernel32"  (hProcess As HANDLE, lpBaseAddress As VoidPtr, lpBuffer As VoidPtr, nSize As SIZE_T, lpNumberOfBytesRead As *SIZE_T) As BOOL
785Declare Function ReleaseMutex Lib "kernel32" (hMutex As HANDLE) As BOOL
786Declare Function ReleaseSemaphore Lib "kernel32" (hSemaphore As HANDLE, lReleaseCount As Long, ByRef lpPreviousCount As Long) As BOOL
787Declare Function RemoveDirectory Lib "kernel32" Alias _FuncName_RemoveDirectory (lpPathName As LPCTSTR) As BOOL
788Declare Function ResetEvent Lib "kernel32" (hEvent As HANDLE) As BOOL
789Declare Function ResumeThread Lib "kernel32" (hThread As HANDLE) As DWord
790Declare Function SetComputerName Lib "kernel32" Alias _FuncName_SetComputerName (lpComputerName As LPCTSTR) As BOOL
791Declare Function SetCurrentDirectory Lib "kernel32" Alias _FuncName_SetCurrentDirectory (lpPathName As LPCTSTR) As BOOL
792Declare Function SearchPath Lib "kernel32" Alias _FuncName_SearchPath (pPath As PCSTR, pFileName As PCTSTR, pExtension As PCTSTR, BufferLength As DWord, pBuffer As PTSTR, ByRef pFilePart As PTSTR) As DWord
793Declare Function SetEndOfFile Lib "kernel32" (hFile As HANDLE) As BOOL
794Declare Function SetEnvironmentVariable Lib "kernel32" Alias _FuncName_SetEnvironmentVariable (lpName As LPCTSTR, lpValue As LPTSTR) As BOOL
795
796Const SEM_FAILCRITICALERRORS = &h0001
797Const SEM_NOGPFAULTERRORBOX = &h0002
798Const SEM_NOALIGNMENTFAULTEXCEPT = &h0004
799Const SEM_NOOPENFILEERRORBOX = &h8000
800Declare Function SetErrorMode Lib "kernel32" (uMode As DWord) As DWord
801Declare Function SetEvent Lib "kernel32" (hEvent As HANDLE) As BOOL
802Declare Function SetFileAttributes Lib "kernel32" Alias _FuncName_SetFileAttributes (lpFileName As LPCTSTR, dwFileAttributes As DWord) As BOOL
803
804Const FILE_BEGIN =   0
805Const FILE_CURRENT = 1
806Const FILE_END =     2
807Declare Function SetFilePointer Lib "kernel32" (hFile As HANDLE, lDistanceToMove As Long, lpDistanceToMoveHigh As DWordPtr, dwMoveMethod As DWord) As DWord
808
809Declare Function SetFileTime Lib "kernel32" (hFile As HANDLE, ByRef lpCreationTime As FILETIME, ByRef lpLastAccessTime As FILETIME, ByRef lpLastWriteTime As FILETIME) As BOOL
810Declare Sub SetLastError Lib "kernel32" (dwErrCode As DWord)
811Declare Sub SetLastErrorEx Lib "kernel32" (dwErrCode As DWord, dwType As DWord)
812Declare Function SetLocalTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME) As BOOL
813Declare Function SetPriorityClass Lib "kernel32" (hProcess As HANDLE, dwPriorityClass As DWord) As BOOL
814Declare Function SetThreadContext Lib "kernel32" (hThread As HANDLE, ByRef Context As CONTEXT) As BOOL
815Declare Function SetThreadPriority Lib "kernel32" (hThread As HANDLE, nPriority As Long) As BOOL
816Declare Function SetThreadPriorityBoost Lib "kernel32" (
817    hThread As HANDLE,
818    DisablePriorityBoost As BOOL
819) As BOOL
820
821TypeDef PTOP_LEVEL_EXCEPTION_FILTER = *Function(ByRef ExceptionInfo As EXCEPTION_POINTERS) As Long
822
823Declare Function SetUnhandledExceptionFilter Lib "kernel32" (pTopLevelExceptionFilter As PTOP_LEVEL_EXCEPTION_FILTER) As PTOP_LEVEL_EXCEPTION_FILTER
824
825Const INFINITE = &HFFFFFFFF
826Declare Sub Sleep Lib "kernel32" (dwMilliseconds As DWord)
827Declare Function SleepEx Lib "kernel32" (dwMilliseconds As DWord, bAlertable As BOOL) As DWord
828
829Declare Function SuspendThread Lib "kernel32" (hThread As HANDLE) As DWord
830Declare Function SystemTimeToFileTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME, ByRef lpFileTime As FILETIME) As BOOL
831Declare Function TerminateProcess Lib "kernel32" (hProcess As HANDLE, dwExitCode As DWord) As BOOL
832Declare Function TerminateThread Lib "kernel32" (hThread As HANDLE, dwExitCode As DWord) As BOOL
833Declare Function TlsAlloc Lib "kernel32" () As DWord
834Declare Function TlsFree Lib "kernel32" (dwTlsIndex As DWord) As BOOL
835Declare Function TlsGetValue Lib "kernel32" (dwTlsIndex As DWord) As VoidPtr
836Declare Function TlsSetValue Lib "kernel32" (dwTlsIndex As DWord, pTlsValue As VoidPtr) As BOOL
837Declare Function UnlockFile Lib "kernel32" (hFile As HANDLE, dwFileOffsetLow As DWord, dwFileOffsetHigh As DWord, nNumberOfBytesToUnlockLow As DWord, nNumberOfBytesToUnlockHigh As DWord) As BOOL
838Declare Function UnhandledExceptionFilter Lib "kernel32" (ByRef ExceptionInfo As EXCEPTION_POINTERS) As Long
839Declare Function VirtualAlloc Lib "kernel32" (lpAddress As VoidPtr, dwSize As SIZE_T, flAllocationType As DWord, flProtect As DWord) As VoidPtr
840Declare Function VirtualFree Lib "kernel32" (lpAddress As VoidPtr, dwSize As SIZE_T, dwFreeType As DWord) As BOOL
841Declare Function VirtualLock Lib "kernel32" (lpAddress As VoidPtr, dwSize As SIZE_T) As BOOL
842Declare Function VirtualProtect Lib "kernel32" (
843    pAddress As VoidPtr,
844    Size As SIZE_T,
845    flNewProtect As DWord,
846    ByRef flOldProtect As DWord
847) As BOOL
848Declare Function VirtualProtectEx Lib "kernel32" (
849    hProcess As HANDLE,
850    pAddress As VoidPtr,
851    Size As SIZE_T,
852    flNewProtect As DWord,
853    ByRef flOldProtect As DWord
854) As BOOL
855Declare Function VirtualQuery Lib "kernel32" (
856    pAddress As VoidPtr,
857    ByRef mbi As MEMORY_BASIC_INFORMATION,
858    Length As SIZE_T
859) As SIZE_T
860Declare Function VirtualQueryEx Lib "kernel32" (
861    hProcess As HANDLE,
862    pAddress As VoidPtr,
863    ByRef mbi As MEMORY_BASIC_INFORMATION,
864    Length As SIZE_T
865) As SIZE_T
866Declare Function VirtualUnlock Lib "kernel32" (lpAddress As VoidPtr, dwSize As SIZE_T) As BOOL
867Declare Function WaitForMultipleObjects Lib "kernel32" (nCount As DWord, pHandles As *HANDLE, fWaitAll As BOOL, dwMilliseconds As DWord) As DWord
868Declare Function WaitForMultipleObjectsEx Lib "kernel32" (nCount As DWord, pHandles As *HANDLE, fWaitAll As BOOL, dwMilliseconds As DWord, bAlertable As BOOL) As DWord
869Declare Function WaitForSingleObject Lib "kernel32" (hHandle As HANDLE, dwMilliseconds As DWord) As DWord
870Declare Function WaitForSingleObjectEx Lib "kernel32" (hHandle As HANDLE, dwMilliseconds As DWord, bAlertable As BOOL) As DWord
871
872Const WC_COMPOSITECHECK    = &H00000200
873Const WC_DISCARDNS         = &H00000010
874Const WC_SEPCHARS          = &H00000020
875Const WC_DEFAULTCHAR       = &H00000040
876Const WC_NO_BEST_FIT_CHARS = &H00000400
877Declare Function WideCharToMultiByte Lib "Kernel32" (
878    CodePage As DWord,
879    dwFlags As DWord,
880    pWideCharStr As PCWSTR,
881    cchWideChar As Long,
882    pMultiByteStr As PSTR,
883    cbMultiByte As Long,
884    pDefaultChar As PCSTR,
885    pUsedDefaultChar As *BOOL
886) As Long
887
888Declare Function WriteFile Lib "kernel32" (hFile As HANDLE, lpBuffer As VoidPtr, nNumberOfBytesToWrite As DWord, lpNumberOfBytesWritten As *DWord, ByRef pOverlapped As OVERLAPPED) As BOOL
889Declare Sub ZeroMemory Lib "kernel32" Alias "RtlZeroMemory" (Destination As VoidPtr, dwLength As DWord)
890
891'
892'  Wait functions' results.
893'
894Const WAIT_FAILED = (&hFFFFFFFF As DWord)
895Const WAIT_OBJECT_0 = ((STATUS_WAIT_0 ) + 0)
896
897Const WAIT_ABANDONED = ((STATUS_ABANDONED_WAIT_0 ) + 0)
898Const WAIT_ABANDONED_0 = ((STATUS_ABANDONED_WAIT_0 ) + 0)
899
900Const WAIT_IO_COMPLETION = STATUS_USER_APC
901
902Declare Function FindResource Lib "kernel32" Alias _FuncName_FindResource (hInstance As HINSTANCE, lpName As LPCTSTR, lpType As LPCTSTR) As HRSRC
903Declare Function LoadResource Lib "kernel32" (hModule As HMODULE, hResInfo As HRSRC) As HGLOBAL
904Declare Function FreeResource Lib "kernel32" (hResData As HGLOBAL) As BOOL
905Declare Function LockResource Lib "kernel32" (hResData As HGLOBAL) As VoidPtr
906Declare Function SizeofResource Lib "kernel32" (hModule As HANDLE, hResInfo As HRSRC) As DWord
907
908Declare Function ExpandEnvironmentStrings Lib "kernel32" Alias _FuncName_ExpandEnvironmentStrings (lpSrc As LPCTSTR, lpDst As LPTSTR, nSize As DWord) As DWord
909
910Type DCB
911    DCBlength As DWord
912    BaudRate As DWord
913    fBitFields As DWord
914    wReserved As Word
915    XonLim As Word
916    XoffLim As Word
917    ByteSize As Byte
918    Parity As Byte
919    StopBits As Byte
920    XonChar As CHAR
921    XoffChar As CHAR
922    ErrorChar As CHAR
923    EofChar As CHAR
924    EvtChar As CHAR
925    wReserved1 As Word
926End Type
927
928Type COMMTIMEOUTS
929    ReadIntervalTimeout As DWord
930    ReadTotalTimeoutMultiplier As DWord
931    ReadTotalTimeoutConstant As DWord
932    WriteTotalTimeoutMultiplier As DWord
933    WriteTotalTimeoutConstant As DWord
934End Type
935
936Type COMSTAT
937    fCoBitFlds As Long 'See Comment in Win32API.Txt
938    cbInQue As DWord
939    cbOutQue As DWord
940End Type
941
942Declare Function SetCommState Lib "kernel32" (hCommDev As HANDLE, ByRef dcb As DCB) As BOOL
943Declare Function SetCommTimeouts Lib "kernel32" (hFile As HANDLE ,ByRef pCommTimeouts As COMMTIMEOUTS) As BOOL
944Declare Function ClearCommError Lib "kernel32" (hCommDevs As HANDLE, ByRef Errors As DWord, ByRef Stat As COMSTAT) As BOOL
945Declare Function EscapeCommFunction Lib "kernel32" (nCid As HANDLE, ByVal nFunc As DWord) As BOOL
946Declare Function GetCommModemStatus Lib "kernel32" (hFile As HANDLE, ByRef ModemStat As DWord) As BOOL
947Declare Function SetCommMask Lib "kernel32" (hFile As HANDLE, dwEvtMask As DWord) As BOOL
948Declare Function WaitCommEvent Lib "kernel32" (hFile As HANDLE, ByRef EvtMask As DWord, lpOverlapped As *OVERLAPPED)  As BOOL
949
950Const PURGE_TXABORT   =    &H0001
951Const PURGE_RXABORT   =    &H0002
952Const PURGE_TXCLEAR   =    &H0004
953Const PURGE_RXCLEAR   =    &H0008
954Declare Function PurgeComm Lib "kernel32" (hFile As HANDLE, dwFlags As DWord) As BOOL
955
956Declare Function OpenProcessToken Lib "advapi32" (ProcessHandle As HANDLE, DesiredAccess As DWord, ByRef TokenHandle As HANDLE) As BOOL
957Declare Function LookupPrivilegeValue Lib "advapi32" Alias _FuncName_LookupPrivilegeValue (lpSystemName As LPCTSTR, lpName As LPCTSTR, ByRef Luid As LUID) As Long
958Declare Function AdjustTokenPrivileges Lib "advapi32" (TokenHandle As Long, DisableAllPrivileges As Long,_
959    ByRef NewState As TOKEN_PRIVILEGES, BufferLength As Long,
960    ByRef PreviousState As TOKEN_PRIVILEGES, ByRef ReturnLength As Long) As Long
961
962Declare Function AddAtom Lib "kernel32" Alias _FuncName_AddAtom (lpString As LPCTSTR) As ATOM
963Declare Function DeleteAtom Lib "kernel32" (nAtom As ATOM) As ATOM
964Declare Function FindAtom Lib "kernel32" Alias _FuncName_AddAtom (lpString As LPCTSTR) As ATOM
965Declare Function GetAtomName Lib "kernel32" Alias _FuncName_GetAtomName (nAtom As ATOM, lpBuffer As LPCTSTR, nSize As Long) As DWord
966
967Declare Function GlobalAddAtom Lib "kernel32" Alias _FuncName_GlobalAddAtom (lpString As LPCTSTR) As ATOM
968Declare Function GlobalDeleteAtom Lib "kernel32" (a As ATOM) As ATOM
969Declare Function GlobalFindAtom Lib "kernel32" Alias _FuncName_GlobalAddAtom (lpString As LPCTSTR) As ATOM
970Declare Function GlobalGetAtomName Lib "kernel32" Alias _FuncName_GlobalGetAtomName (nAtom As ATOM, lpBuffer As LPCTSTR, nSize As Long) As DWord
971
972Declare Function InitAtomTable Lib "kernel32" (nSize As DWord) As BOOL
973
974Const MAXINTATOM = &hC000
975Const MAKEINTATOM(i) = (i As Word As ULONG_PTR As LPTSTR)
976Const INVALID_ATOM = 0 As ATOM
Note: See TracBrowser for help on using the repository browser.