1 /***********************************************************************\
2 *                               winbase.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *             Translated from MinGW API for MS-Windows 3.10             *
7 *                                                                       *
8 *                       Placed into public domain                       *
9 \***********************************************************************/
10 module win32.winbase;
11 pragma(lib, "kernel32.lib");
12 
13 /**
14 Translation Notes:
15 The following macros are obsolete, and have no effect.
16 
17 LockSegment(w), MakeProcInstance(p, i), UnlockResource(h), UnlockSegment(w)
18 FreeModule(m), FreeProcInstance(p), GetFreeSpace(w), DefineHandleTable(w)
19 SetSwapAreaSize(w), LimitEmsPages(n), Yield()
20 
21 // The following Win16 functions are obselete in Win32.
22 
23  int _hread(HFILE, LPVOID, int);
24  int _hwrite(HFILE, LPCSTR, int);
25  HFILE _lclose(HFILE);
26  HFILE _lcreat(LPCSTR, int);
27  LONG _llseek(HFILE, LONG, int);
28  HFILE _lopen(LPCSTR, int);
29  UINT _lread(HFILE, LPVOID, UINT);
30  UINT _lwrite(HFILE, LPCSTR, UINT);
31  SIZE_T GlobalCompact(DWORD);
32  VOID GlobalFix(HGLOBAL);
33 * MSDN contradicts itself on GlobalFlags:
34 * "This function is provided only for compatibility with 16-bit versions of Windows."
35 * but also requires Windows 2000 or above
36  UINT GlobalFlags(HGLOBAL);
37  VOID GlobalUnfix(HGLOBAL);
38  BOOL GlobalUnWire(HGLOBAL);
39  PVOID GlobalWire(HGLOBAL);
40  SIZE_T LocalCompact(UINT);
41  UINT LocalFlags(HLOCAL);
42  SIZE_T LocalShrink(HLOCAL, UINT);
43 
44 // These are not required for DMD.
45 
46 //FIXME:
47 // #ifndef UNDER_CE
48 	int WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
49 #else
50 	int WinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
51 #endif
52 int wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
53 
54 */
55 
56 import win32.windef, win32.winver;
57 private import win32.basetyps, win32.w32api, win32.winnt;
58 
59 // FIXME:
60 alias void va_list;
61 
62 
63 /+
64 //--------------------------------------
65 // These functions are problematic
66 
67 version(UseNtoSKernel) {}else {
68 	/* CAREFUL: These are exported from ntoskrnl.exe and declared in winddk.h
69 	   as __fastcall functions, but are  exported from kernel32.dll as __stdcall */
70 	static if (_WIN32_WINNT >= 0x0501) {
71 	 VOID InitializeSListHead(PSLIST_HEADER);
72 	}
73 	LONG InterlockedCompareExchange(LPLONG, LONG, LONG);
74 	// PVOID WINAPI InterlockedCompareExchangePointer(PVOID*, PVOID, PVOID);
75 	(PVOID)InterlockedCompareExchange((LPLONG)(d)    (PVOID)InterlockedCompareExchange((LPLONG)(d), (LONG)(e), (LONG)(c))
76 	LONG InterlockedDecrement(LPLONG);
77 	LONG InterlockedExchange(LPLONG, LONG);
78 	// PVOID WINAPI InterlockedExchangePointer(PVOID*, PVOID);
79 	(PVOID)InterlockedExchange((LPLONG)((PVOID)InterlockedExchange((LPLONG)(t), (LONG)(v))
80 	LONG InterlockedExchangeAdd(LPLONG, LONG);
81 
82 	static if (_WIN32_WINNT >= 0x0501) {
83 	PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER);
84 	}
85 	LONG InterlockedIncrement(LPLONG);
86 	static if (_WIN32_WINNT >= 0x0501) {
87 	PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER);
88 	PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
89 	}
90 } // #endif //  __USE_NTOSKRNL__
91 //--------------------------------------
92 +/
93 
94 // COMMPROP structure, used by GetCommProperties()
95 // -----------------------------------------------
96 
97 // Communications provider type
98 enum : DWORD {
99 	PST_UNSPECIFIED,
100 	PST_RS232,
101 	PST_PARALLELPORT,
102 	PST_RS422,
103 	PST_RS423,
104 	PST_RS449,
105 	PST_MODEM,      // =      6
106 	PST_FAX            = 0x0021,
107 	PST_SCANNER        = 0x0022,
108 	PST_NETWORK_BRIDGE = 0x0100,
109 	PST_LAT            = 0x0101,
110 	PST_TCPIP_TELNET   = 0x0102,
111 	PST_X25            = 0x0103
112 }
113 
114 // Max baud rate
115 enum : DWORD {
116 	BAUD_075    = 0x00000001,
117 	BAUD_110    = 0x00000002,
118 	BAUD_134_5  = 0x00000004,
119 	BAUD_150    = 0x00000008,
120 	BAUD_300    = 0x00000010,
121 	BAUD_600    = 0x00000020,
122 	BAUD_1200   = 0x00000040,
123 	BAUD_1800   = 0x00000080,
124 	BAUD_2400   = 0x00000100,
125 	BAUD_4800   = 0x00000200,
126 	BAUD_7200   = 0x00000400,
127 	BAUD_9600   = 0x00000800,
128 	BAUD_14400  = 0x00001000,
129 	BAUD_19200  = 0x00002000,
130 	BAUD_38400  = 0x00004000,
131 	BAUD_56K    = 0x00008000,
132 	BAUD_128K   = 0x00010000,
133 	BAUD_115200 = 0x00020000,
134 	BAUD_57600  = 0x00040000,
135 	BAUD_USER   = 0x10000000
136 }
137 
138 // Comm capabilities
139 enum : DWORD {
140 	PCF_DTRDSR        = 0x0001,
141 	PCF_RTSCTS        = 0x0002,
142 	PCF_RLSD          = 0x0004,
143 	PCF_PARITY_CHECK  = 0x0008,
144 	PCF_XONXOFF       = 0x0010,
145 	PCF_SETXCHAR      = 0x0020,
146 	PCF_TOTALTIMEOUTS = 0x0040,
147 	PCF_INTTIMEOUTS   = 0x0080,
148 	PCF_SPECIALCHARS  = 0x0100,
149 	PCF_16BITMODE     = 0x0200
150 }
151 
152 enum  : DWORD {
153 	SP_PARITY       = 1,
154 	SP_BAUD         = 2,
155 	SP_DATABITS     = 4,
156 	SP_STOPBITS     = 8,
157 	SP_HANDSHAKING  = 16,
158 	SP_PARITY_CHECK = 32,
159 	SP_RLSD         = 64
160 }
161 
162 enum : DWORD {
163 	DATABITS_5   = 1,
164 	DATABITS_6   = 2,
165 	DATABITS_7   = 4,
166 	DATABITS_8   = 8,
167 	DATABITS_16  = 16,
168 	DATABITS_16X = 32
169 }
170 
171 enum : WORD {
172 	STOPBITS_10  = 0x0001,
173 	STOPBITS_15  = 0x0002,
174 	STOPBITS_20  = 0x0004,
175 	PARITY_NONE  = 0x0100,
176 	PARITY_ODD   = 0x0200,
177 	PARITY_EVEN  = 0x0400,
178 	PARITY_MARK  = 0x0800,
179 	PARITY_SPACE = 0x1000
180 }
181 
182 // used by dwServiceMask
183 const SP_SERIALCOMM = 1;
184 
185 struct COMMPROP {
186 	WORD  wPacketLength;
187 	WORD  wPacketVersion;
188 	DWORD dwServiceMask;
189 	DWORD dwReserved1;
190 	DWORD dwMaxTxQueue;
191 	DWORD dwMaxRxQueue;
192 	DWORD dwMaxBaud;
193 	DWORD dwProvSubType;
194 	DWORD dwProvCapabilities;
195 	DWORD dwSettableParams;
196 	DWORD dwSettableBaud;
197 	WORD  wSettableData;
198 	WORD  wSettableStopParity;
199 	DWORD dwCurrentTxQueue;
200 	DWORD dwCurrentRxQueue;
201 	DWORD dwProvSpec1;
202 	DWORD dwProvSpec2;
203 	WCHAR _wcProvChar;
204 
205 	WCHAR* wcProvChar() { return &_wcProvChar; }
206 }
207 alias COMMPROP* LPCOMMPROP;
208 
209 // ----------
210 
211 // for DEBUG_EVENT
212 enum : DWORD {
213 	EXCEPTION_DEBUG_EVENT = 1,
214 	CREATE_THREAD_DEBUG_EVENT,
215 	CREATE_PROCESS_DEBUG_EVENT,
216 	EXIT_THREAD_DEBUG_EVENT,
217 	EXIT_PROCESS_DEBUG_EVENT,
218 	LOAD_DLL_DEBUG_EVENT,
219 	UNLOAD_DLL_DEBUG_EVENT,
220 	OUTPUT_DEBUG_STRING_EVENT,
221 	RIP_EVENT
222 }
223 
224 const HFILE HFILE_ERROR = cast(HFILE) (-1);
225 
226 // for SetFilePointer()
227 enum : DWORD {
228 	FILE_BEGIN   = 0,
229 	FILE_CURRENT = 1,
230 	FILE_END     = 2
231 }
232 const DWORD INVALID_SET_FILE_POINTER = -1;
233 
234 
235 // for OpenFile()
236 deprecated enum : UINT {
237 	OF_READ             = 0,
238 	OF_WRITE            = 0x0001,
239 	OF_READWRITE        = 0x0002,
240 	OF_SHARE_COMPAT     = 0,
241 	OF_SHARE_EXCLUSIVE  = 0x0010,
242 	OF_SHARE_DENY_WRITE = 0x0020,
243 	OF_SHARE_DENY_READ  = 0x0030,
244 	OF_SHARE_DENY_NONE  = 0x0040,
245 	OF_PARSE            = 0x0100,
246 	OF_DELETE           = 0x0200,
247 	OF_VERIFY           = 0x0400,
248 	OF_CANCEL           = 0x0800,
249 	OF_CREATE           = 0x1000,
250 	OF_PROMPT           = 0x2000,
251 	OF_EXIST            = 0x4000,
252 	OF_REOPEN           = 0x8000
253 }
254 
255 enum : DWORD {
256 	NMPWAIT_NOWAIT           =  1,
257 	NMPWAIT_WAIT_FOREVER     = -1,
258 	NMPWAIT_USE_DEFAULT_WAIT =  0
259 }
260 
261 // for ClearCommError()
262 const DWORD
263 	CE_RXOVER   = 0x0001,
264 	CE_OVERRUN  = 0x0002,
265 	CE_RXPARITY = 0x0004,
266 	CE_FRAME    = 0x0008,
267 	CE_BREAK    = 0x0010,
268 	CE_TXFULL   = 0x0100,
269 	CE_PTO      = 0x0200,
270 	CE_IOE      = 0x0400,
271 	CE_DNS      = 0x0800,
272 	CE_OOP      = 0x1000,
273 	CE_MODE     = 0x8000;
274 
275 // for CopyProgressRoutine callback.
276 enum : DWORD {
277 	PROGRESS_CONTINUE = 0,
278 	PROGRESS_CANCEL   = 1,
279 	PROGRESS_STOP     = 2,
280 	PROGRESS_QUIET    = 3
281 }
282 
283 enum : DWORD {
284 	CALLBACK_CHUNK_FINISHED = 0,
285 	CALLBACK_STREAM_SWITCH  = 1
286 }
287 
288 // CopyFileEx()
289 enum : DWORD {
290 	COPY_FILE_FAIL_IF_EXISTS = 1,
291 	COPY_FILE_RESTARTABLE    = 2
292 }
293 
294 enum : DWORD {
295 	FILE_MAP_COPY       = 1,
296 	FILE_MAP_WRITE      = 2,
297 	FILE_MAP_READ       = 4,
298 	FILE_MAP_ALL_ACCESS = 0x000F001F
299 }
300 
301 enum : DWORD {
302 	MUTEX_ALL_ACCESS       = 0x001f0001,
303 	MUTEX_MODIFY_STATE     = 0x00000001,
304 	SEMAPHORE_ALL_ACCESS   = 0x001f0003,
305 	SEMAPHORE_MODIFY_STATE = 0x00000002,
306 	EVENT_ALL_ACCESS       = 0x001f0003,
307 	EVENT_MODIFY_STATE     = 0x00000002
308 }
309 
310 // CreateNamedPipe()
311 enum : DWORD {
312 	PIPE_ACCESS_INBOUND  = 1,
313 	PIPE_ACCESS_OUTBOUND = 2,
314 	PIPE_ACCESS_DUPLEX   = 3
315 }
316 
317 const DWORD
318 	PIPE_TYPE_BYTE        = 0,
319 	PIPE_TYPE_MESSAGE     = 4,
320 	PIPE_READMODE_BYTE    = 0,
321 	PIPE_READMODE_MESSAGE = 2,
322 	PIPE_WAIT             = 0,
323 	PIPE_NOWAIT           = 1;
324 
325 // GetNamedPipeInfo()
326 const DWORD
327 	PIPE_CLIENT_END  = 0,
328 	PIPE_SERVER_END  = 1;
329 
330 const DWORD PIPE_UNLIMITED_INSTANCES = 255;
331 
332 // dwCreationFlags for CreateProcess() and CreateProcessAsUser()
333 enum : DWORD {
334 	DEBUG_PROCESS               = 0x00000001,
335 	DEBUG_ONLY_THIS_PROCESS     = 0x00000002,
336 	CREATE_SUSPENDED            = 0x00000004,
337 	DETACHED_PROCESS            = 0x00000008,
338 	CREATE_NEW_CONSOLE          = 0x00000010,
339 	NORMAL_PRIORITY_CLASS       = 0x00000020,
340 	IDLE_PRIORITY_CLASS         = 0x00000040,
341 	HIGH_PRIORITY_CLASS         = 0x00000080,
342 	REALTIME_PRIORITY_CLASS     = 0x00000100,
343 	CREATE_NEW_PROCESS_GROUP    = 0x00000200,
344 	CREATE_UNICODE_ENVIRONMENT  = 0x00000400,
345 	CREATE_SEPARATE_WOW_VDM     = 0x00000800,
346 	CREATE_SHARED_WOW_VDM       = 0x00001000,
347 	CREATE_FORCEDOS             = 0x00002000,
348 	BELOW_NORMAL_PRIORITY_CLASS = 0x00004000,
349 	ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000,
350 	CREATE_BREAKAWAY_FROM_JOB   = 0x01000000,
351 	CREATE_WITH_USERPROFILE     = 0x02000000,
352 	CREATE_DEFAULT_ERROR_MODE   = 0x04000000,
353 	CREATE_NO_WINDOW            = 0x08000000,
354 	PROFILE_USER                = 0x10000000,
355 	PROFILE_KERNEL              = 0x20000000,
356 	PROFILE_SERVER              = 0x40000000
357 }
358 
359 const DWORD CONSOLE_TEXTMODE_BUFFER = 1;
360 
361 // CreateFile()
362 enum : DWORD {
363 	CREATE_NEW = 1,
364 	CREATE_ALWAYS,
365 	OPEN_EXISTING,
366 	OPEN_ALWAYS,
367 	TRUNCATE_EXISTING
368 }
369 
370 // CreateFile()
371 const DWORD
372 	FILE_FLAG_WRITE_THROUGH      = 0x80000000,
373 	FILE_FLAG_OVERLAPPED         = 0x40000000,
374 	FILE_FLAG_NO_BUFFERING       = 0x20000000,
375 	FILE_FLAG_RANDOM_ACCESS      = 0x10000000,
376 	FILE_FLAG_SEQUENTIAL_SCAN    = 0x08000000,
377 	FILE_FLAG_DELETE_ON_CLOSE    = 0x04000000,
378 	FILE_FLAG_BACKUP_SEMANTICS   = 0x02000000,
379 	FILE_FLAG_POSIX_SEMANTICS    = 0x01000000,
380 	FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000,
381 	FILE_FLAG_OPEN_NO_RECALL     = 0x00100000;
382 
383 static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
384 	const DWORD FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000;
385 }
386 
387 // for CreateFile()
388 const DWORD
389 	SECURITY_ANONYMOUS        = SECURITY_IMPERSONATION_LEVEL.SecurityAnonymous<<16,
390 	SECURITY_IDENTIFICATION   = SECURITY_IMPERSONATION_LEVEL.SecurityIdentification<<16,
391 	SECURITY_IMPERSONATION    = SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation<<16,
392 	SECURITY_DELEGATION       = SECURITY_IMPERSONATION_LEVEL.SecurityDelegation<<16,
393 	SECURITY_CONTEXT_TRACKING = 0x00040000,
394 	SECURITY_EFFECTIVE_ONLY   = 0x00080000,
395 	SECURITY_SQOS_PRESENT     = 0x00100000,
396 	SECURITY_VALID_SQOS_FLAGS = 0x001F0000;
397 
398 
399 // Thread exit code
400 const DWORD STILL_ACTIVE = 0x103;
401 
402 /*	??? The only documentation of this seems to be about Windows CE and to
403  *	state what _doesn't_ support it.
404  */
405 const DWORD FIND_FIRST_EX_CASE_SENSITIVE = 1;
406 
407 // GetBinaryType()
408 enum : DWORD {
409 	SCS_32BIT_BINARY = 0,
410 	SCS_DOS_BINARY,
411 	SCS_WOW_BINARY,
412 	SCS_PIF_BINARY,
413 	SCS_POSIX_BINARY,
414 	SCS_OS216_BINARY
415 }
416 
417 const size_t
418 	MAX_COMPUTERNAME_LENGTH = 15,
419 	HW_PROFILE_GUIDLEN      = 39,
420 	MAX_PROFILE_LEN         = 80;
421 
422 // HW_PROFILE_INFO
423 const DWORD
424 	DOCKINFO_UNDOCKED      = 1,
425 	DOCKINFO_DOCKED        = 2,
426 	DOCKINFO_USER_SUPPLIED = 4,
427 	DOCKINFO_USER_UNDOCKED = DOCKINFO_USER_SUPPLIED | DOCKINFO_UNDOCKED,
428 	DOCKINFO_USER_DOCKED   = DOCKINFO_USER_SUPPLIED | DOCKINFO_DOCKED;
429 
430 // DriveType(), RealDriveType()
431 enum : int {
432 	DRIVE_UNKNOWN = 0,
433 	DRIVE_NO_ROOT_DIR,
434 	DRIVE_REMOVABLE,
435 	DRIVE_FIXED,
436 	DRIVE_REMOTE,
437 	DRIVE_CDROM,
438 	DRIVE_RAMDISK
439 }
440 
441 // GetFileType()
442 enum : DWORD {
443 	FILE_TYPE_UNKNOWN = 0,
444 	FILE_TYPE_DISK,
445 	FILE_TYPE_CHAR,
446 	FILE_TYPE_PIPE,
447 	FILE_TYPE_REMOTE = 0x8000
448 }
449 
450 // Get/SetHandleInformation()
451 const DWORD
452 	HANDLE_FLAG_INHERIT            = 0x01,
453 	HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x02;
454 
455 enum : DWORD {
456 	STD_INPUT_HANDLE  = 0xFFFFFFF6,
457 	STD_OUTPUT_HANDLE = 0xFFFFFFF5,
458 	STD_ERROR_HANDLE  = 0xFFFFFFF4
459 }
460 
461 const HANDLE INVALID_HANDLE_VALUE = cast(HANDLE) (-1);
462 
463 enum : DWORD {
464 	GET_TAPE_MEDIA_INFORMATION = 0,
465 	GET_TAPE_DRIVE_INFORMATION = 1
466 }
467 
468 enum : DWORD {
469 	SET_TAPE_MEDIA_INFORMATION = 0,
470 	SET_TAPE_DRIVE_INFORMATION = 1
471 }
472 
473 // SetThreadPriority()/GetThreadPriority()
474 enum : int {
475 	THREAD_PRIORITY_IDLE          = -15,
476 	THREAD_PRIORITY_LOWEST        =  -2,
477 	THREAD_PRIORITY_BELOW_NORMAL  =  -1,
478 	THREAD_PRIORITY_NORMAL        =   0,
479 	THREAD_PRIORITY_ABOVE_NORMAL  =   1,
480 	THREAD_PRIORITY_HIGHEST       =   2,
481 	THREAD_PRIORITY_TIME_CRITICAL =  15,
482 	THREAD_PRIORITY_ERROR_RETURN  = 2147483647
483 }
484 
485 enum : DWORD {
486 	TIME_ZONE_ID_UNKNOWN,
487 	TIME_ZONE_ID_STANDARD,
488 	TIME_ZONE_ID_DAYLIGHT,
489 	TIME_ZONE_ID_INVALID = 0xFFFFFFFF
490 }
491 
492 const DWORD
493 	FS_CASE_SENSITIVE         =     1,
494 	FS_CASE_IS_PRESERVED      =     2,
495 	FS_UNICODE_STORED_ON_DISK =     4,
496 	FS_PERSISTENT_ACLS        =     8,
497 	FS_FILE_COMPRESSION       =    16,
498 	FS_VOL_IS_COMPRESSED      = 32768;
499 
500 // Flags for GlobalAlloc
501 const UINT
502 	GMEM_FIXED       = 0,
503 	GMEM_MOVEABLE    = 0x0002,
504 	GMEM_ZEROINIT    = 0x0040,
505 	GPTR             = 0x0040,
506 	GHND             = 0x0042,
507 	GMEM_MODIFY      = 0x0080,  // used only for GlobalRealloc
508 	GMEM_VALID_FLAGS = 0x7F72;
509 
510 /+  // Obselete flags (Win16 only)
511 	GMEM_NOCOMPACT=16;
512 	GMEM_NODISCARD=32;
513 	GMEM_DISCARDABLE=256;
514 	GMEM_NOT_BANKED=4096;
515 	GMEM_LOWER=4096;
516 	GMEM_SHARE=8192;
517 	GMEM_DDESHARE=8192;
518 
519 	GMEM_LOCKCOUNT=255;
520 
521 // for GlobalFlags()
522 	GMEM_DISCARDED      = 16384;
523 	GMEM_INVALID_HANDLE = 32768;
524 
525 	GMEM_NOTIFY         = 16384;
526 +/
527 
528 const UINT
529 	LMEM_FIXED          = 0,
530 	LMEM_MOVEABLE       = 0x0002,
531 	LMEM_NONZEROLPTR    = 0,
532 	NONZEROLPTR         = 0,
533 	LMEM_NONZEROLHND    = 0x0002,
534 	NONZEROLHND         = 0x0002,
535 	LMEM_DISCARDABLE    = 0x0F00,
536 	LMEM_NOCOMPACT      = 0x0010,
537 	LMEM_NODISCARD      = 0x0020,
538 	LMEM_ZEROINIT       = 0x0040,
539 	LPTR                = 0x0040,
540 	LHND                = 0x0042,
541 	LMEM_MODIFY         = 0x0080,
542 	LMEM_LOCKCOUNT      = 0x00FF,
543 	LMEM_DISCARDED      = 0x4000,
544 	LMEM_INVALID_HANDLE = 0x8000;
545 
546 
547 
548 // used in EXCEPTION_RECORD
549 enum : DWORD {
550 	STATUS_WAIT_0                      = 0,
551 	STATUS_ABANDONED_WAIT_0            = 0x00000080,
552 	STATUS_USER_APC                    = 0x000000C0,
553 	STATUS_TIMEOUT                     = 0x00000102,
554 	STATUS_PENDING                     = 0x00000103,
555 
556 	STATUS_SEGMENT_NOTIFICATION        = 0x40000005,
557 	STATUS_GUARD_PAGE_VIOLATION        = 0x80000001,
558 	STATUS_DATATYPE_MISALIGNMENT       = 0x80000002,
559 	STATUS_BREAKPOINT                  = 0x80000003,
560 	STATUS_SINGLE_STEP                 = 0x80000004,
561 
562 	STATUS_ACCESS_VIOLATION            = 0xC0000005,
563 	STATUS_IN_PAGE_ERROR               = 0xC0000006,
564 	STATUS_INVALID_HANDLE              = 0xC0000008,
565 
566 	STATUS_NO_MEMORY                   = 0xC0000017,
567 	STATUS_ILLEGAL_INSTRUCTION         = 0xC000001D,
568 	STATUS_NONCONTINUABLE_EXCEPTION    = 0xC0000025,
569 	STATUS_INVALID_DISPOSITION         = 0xC0000026,
570 	STATUS_ARRAY_BOUNDS_EXCEEDED       = 0xC000008C,
571 	STATUS_FLOAT_DENORMAL_OPERAND      = 0xC000008D,
572 	STATUS_FLOAT_DIVIDE_BY_ZERO        = 0xC000008E,
573 	STATUS_FLOAT_INEXACT_RESULT        = 0xC000008F,
574 	STATUS_FLOAT_INVALID_OPERATION     = 0xC0000090,
575 	STATUS_FLOAT_OVERFLOW              = 0xC0000091,
576 	STATUS_FLOAT_STACK_CHECK           = 0xC0000092,
577 	STATUS_FLOAT_UNDERFLOW             = 0xC0000093,
578 	STATUS_INTEGER_DIVIDE_BY_ZERO      = 0xC0000094,
579 	STATUS_INTEGER_OVERFLOW            = 0xC0000095,
580 	STATUS_PRIVILEGED_INSTRUCTION      = 0xC0000096,
581 	STATUS_STACK_OVERFLOW              = 0xC00000FD,
582 	STATUS_CONTROL_C_EXIT              = 0xC000013A,
583 	STATUS_DLL_INIT_FAILED             = 0xC0000142,
584 	STATUS_DLL_INIT_FAILED_LOGOFF      = 0xC000026B,
585 
586 	CONTROL_C_EXIT                     = STATUS_CONTROL_C_EXIT,
587 
588 	EXCEPTION_ACCESS_VIOLATION         = STATUS_ACCESS_VIOLATION,
589 	EXCEPTION_DATATYPE_MISALIGNMENT    = STATUS_DATATYPE_MISALIGNMENT,
590 	EXCEPTION_BREAKPOINT               = STATUS_BREAKPOINT,
591 	EXCEPTION_SINGLE_STEP              = STATUS_SINGLE_STEP,
592 	EXCEPTION_ARRAY_BOUNDS_EXCEEDED    = STATUS_ARRAY_BOUNDS_EXCEEDED,
593 	EXCEPTION_FLT_DENORMAL_OPERAND     = STATUS_FLOAT_DENORMAL_OPERAND,
594 	EXCEPTION_FLT_DIVIDE_BY_ZERO       = STATUS_FLOAT_DIVIDE_BY_ZERO,
595 	EXCEPTION_FLT_INEXACT_RESULT       = STATUS_FLOAT_INEXACT_RESULT,
596 	EXCEPTION_FLT_INVALID_OPERATION    = STATUS_FLOAT_INVALID_OPERATION,
597 	EXCEPTION_FLT_OVERFLOW             = STATUS_FLOAT_OVERFLOW,
598 	EXCEPTION_FLT_STACK_CHECK          = STATUS_FLOAT_STACK_CHECK,
599 	EXCEPTION_FLT_UNDERFLOW            = STATUS_FLOAT_UNDERFLOW,
600 	EXCEPTION_INT_DIVIDE_BY_ZERO       = STATUS_INTEGER_DIVIDE_BY_ZERO,
601 	EXCEPTION_INT_OVERFLOW             = STATUS_INTEGER_OVERFLOW,
602 	EXCEPTION_PRIV_INSTRUCTION         = STATUS_PRIVILEGED_INSTRUCTION,
603 	EXCEPTION_IN_PAGE_ERROR            = STATUS_IN_PAGE_ERROR,
604 	EXCEPTION_ILLEGAL_INSTRUCTION      = STATUS_ILLEGAL_INSTRUCTION,
605 	EXCEPTION_NONCONTINUABLE_EXCEPTION = STATUS_NONCONTINUABLE_EXCEPTION,
606 	EXCEPTION_STACK_OVERFLOW           = STATUS_STACK_OVERFLOW,
607 	EXCEPTION_INVALID_DISPOSITION      = STATUS_INVALID_DISPOSITION,
608 	EXCEPTION_GUARD_PAGE               = STATUS_GUARD_PAGE_VIOLATION,
609 	EXCEPTION_INVALID_HANDLE           = STATUS_INVALID_HANDLE
610 }
611 
612 // for PROCESS_HEAP_ENTRY
613 const WORD
614 	PROCESS_HEAP_REGION            =  1,
615 	PROCESS_HEAP_UNCOMMITTED_RANGE =  2,
616 	PROCESS_HEAP_ENTRY_BUSY        =  4,
617 	PROCESS_HEAP_ENTRY_MOVEABLE    = 16,
618 	PROCESS_HEAP_ENTRY_DDESHARE    = 32;
619 
620 // for LoadLibraryEx()
621 const DWORD
622 	DONT_RESOLVE_DLL_REFERENCES   = 0x01, // not for WinME and earlier
623 	LOAD_LIBRARY_AS_DATAFILE      = 0x02,
624 	LOAD_WITH_ALTERED_SEARCH_PATH = 0x08,
625 	LOAD_IGNORE_CODE_AUTHZ_LEVEL  = 0x10; // only for XP and later
626 
627 // for LockFile()
628 const DWORD
629 	LOCKFILE_FAIL_IMMEDIATELY = 1,
630 	LOCKFILE_EXCLUSIVE_LOCK   = 2;
631 
632 const MAXIMUM_WAIT_OBJECTS  = 64;
633 const MAXIMUM_SUSPEND_COUNT = 0x7F;
634 
635 const WAIT_OBJECT_0    = 0;
636 const WAIT_ABANDONED_0 = 128;
637 
638 //const WAIT_TIMEOUT=258;  // also in winerror.h
639 
640 enum : DWORD {
641 	WAIT_IO_COMPLETION = 0x000000C0,
642 	WAIT_ABANDONED     = 0x00000080,
643 	WAIT_FAILED        = 0xFFFFFFFF
644 }
645 
646 // PurgeComm()
647 const DWORD
648 	PURGE_TXABORT = 1,
649 	PURGE_RXABORT = 2,
650 	PURGE_TXCLEAR = 4,
651 	PURGE_RXCLEAR = 8;
652 
653 // ReadEventLog()
654 const DWORD
655 	EVENTLOG_SEQUENTIAL_READ = 1,
656 	EVENTLOG_SEEK_READ       = 2,
657 	EVENTLOG_FORWARDS_READ   = 4,
658 	EVENTLOG_BACKWARDS_READ  = 8;
659 
660 // ReportEvent()
661 enum : WORD {
662 	EVENTLOG_SUCCESS          = 0,
663 	EVENTLOG_ERROR_TYPE       = 1,
664 	EVENTLOG_WARNING_TYPE     = 2,
665 	EVENTLOG_INFORMATION_TYPE = 4,
666 	EVENTLOG_AUDIT_SUCCESS    = 8,
667 	EVENTLOG_AUDIT_FAILURE    = 16
668 }
669 
670 // FormatMessage()
671 const DWORD
672 	FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x0100,
673 	FORMAT_MESSAGE_IGNORE_INSERTS  = 0x0200,
674 	FORMAT_MESSAGE_FROM_STRING     = 0x0400,
675 	FORMAT_MESSAGE_FROM_HMODULE    = 0x0800,
676 	FORMAT_MESSAGE_FROM_SYSTEM     = 0x1000,
677 	FORMAT_MESSAGE_ARGUMENT_ARRAY  = 0x2000;
678 
679 const DWORD FORMAT_MESSAGE_MAX_WIDTH_MASK = 255;
680 
681 // also in ddk/ntapi.h
682 // To restore default error mode, call SetErrorMode(0)
683 enum {
684 	SEM_FAILCRITICALERRORS     = 0x0001,
685 	SEM_NOGPFAULTERRORBOX      = 0x0002,
686 	SEM_NOALIGNMENTFAULTEXCEPT = 0x0004,
687 	SEM_NOOPENFILEERRORBOX     = 0x8000
688 }
689 // end ntapi.h
690 
691 enum {
692 	SLE_ERROR = 1,
693 	SLE_MINORERROR,
694 	SLE_WARNING
695 }
696 
697 const SHUTDOWN_NORETRY = 1;
698 
699 // Return type for exception filters.
700 enum : LONG {
701 	EXCEPTION_EXECUTE_HANDLER    =  1,
702 	EXCEPTION_CONTINUE_EXECUTION = -1,
703 	EXCEPTION_CONTINUE_SEARCH    =  0
704 }
705 
706 enum  : ATOM {
707 	MAXINTATOM   = 0xC000,
708 	INVALID_ATOM = 0
709 }
710 
711 const IGNORE   = 0;
712 const INFINITE = 0xFFFFFFFF;
713 
714 // EscapeCommFunction()
715 enum {
716 	SETXOFF    = 1,
717 	SETXON,
718 	SETRTS,
719 	CLRRTS,
720 	SETDTR,
721 	CLRDTR, // = 6
722 	SETBREAK   = 8,
723 	CLRBREAK   = 9
724 }
725 
726 
727 // for SetCommMask()
728 const DWORD
729 	EV_RXCHAR   = 0x0001,
730 	EV_RXFLAG   = 0x0002,
731 	EV_TXEMPTY  = 0x0004,
732 	EV_CTS      = 0x0008,
733 	EV_DSR      = 0x0010,
734 	EV_RLSD     = 0x0020,
735 	EV_BREAK    = 0x0040,
736 	EV_ERR      = 0x0080,
737 	EV_RING     = 0x0100,
738 	EV_PERR     = 0x0200,
739 	EV_RX80FULL = 0x0400,
740 	EV_EVENT1   = 0x0800,
741 	EV_EVENT2   = 0x1000;
742 
743 // GetCommModemStatus()
744 const DWORD
745 	MS_CTS_ON  = 0x0010,
746 	MS_DSR_ON  = 0x0020,
747 	MS_RING_ON = 0x0040,
748 	MS_RLSD_ON = 0x0080;
749 
750 
751 // DCB
752 enum : BYTE {
753 	NOPARITY = 0,
754 	ODDPARITY,
755 	EVENPARITY,
756 	MARKPARITY,
757 	SPACEPARITY
758 }
759 // DCB
760 enum : BYTE {
761 	ONESTOPBIT = 0,
762 	ONE5STOPBITS,
763 	TWOSTOPBITS
764 }
765 // DCB
766 enum : DWORD {
767 	CBR_110    =    110,
768 	CBR_300    =    300,
769 	CBR_600    =    600,
770 	CBR_1200   =   1200,
771 	CBR_2400   =   2400,
772 	CBR_4800   =   4800,
773 	CBR_9600   =   9600,
774 	CBR_14400  =  14400,
775 	CBR_19200  =  19200,
776 	CBR_38400  =  38400,
777 	CBR_56000  =  56000,
778 	CBR_57600  =  57600,
779 	CBR_115200 = 115200,
780 	CBR_128000 = 128000,
781 	CBR_256000 = 256000
782 }
783 // DCB, 2-bit bitfield
784 enum {
785 	DTR_CONTROL_DISABLE = 0,
786 	DTR_CONTROL_ENABLE,
787 	DTR_CONTROL_HANDSHAKE
788 }
789 
790 // DCB, 2-bit bitfield
791 enum {
792 	RTS_CONTROL_DISABLE = 0,
793 	RTS_CONTROL_ENABLE,
794 	RTS_CONTROL_HANDSHAKE,
795 	RTS_CONTROL_TOGGLE,
796 }
797 
798 // WIN32_STREAM_ID
799 enum : DWORD {
800 	BACKUP_INVALID = 0,
801 	BACKUP_DATA,
802 	BACKUP_EA_DATA,
803 	BACKUP_SECURITY_DATA,
804 	BACKUP_ALTERNATE_DATA,
805 	BACKUP_LINK,
806 	BACKUP_PROPERTY_DATA,
807 	BACKUP_OBJECT_ID,
808 	BACKUP_REPARSE_DATA,
809 	BACKUP_SPARSE_BLOCK
810 }
811 
812 // WIN32_STREAM_ID
813 enum : DWORD {
814 	STREAM_NORMAL_ATTRIBUTE    = 0,
815 	STREAM_MODIFIED_WHEN_READ  = 1,
816 	STREAM_CONTAINS_SECURITY   = 2,
817 	STREAM_CONTAINS_PROPERTIES = 4
818 }
819 
820 // STARTUPINFO
821 const DWORD
822 	STARTF_USESHOWWINDOW    = 0x0001,
823 	STARTF_USESIZE          = 0x0002,
824 	STARTF_USEPOSITION      = 0x0004,
825 	STARTF_USECOUNTCHARS    = 0x0008,
826 	STARTF_USEFILLATTRIBUTE = 0x0010,
827 	STARTF_RUNFULLSCREEN    = 0x0020,
828 	STARTF_FORCEONFEEDBACK  = 0x0040,
829 	STARTF_FORCEOFFFEEDBACK = 0x0080,
830 	STARTF_USESTDHANDLES    = 0x0100,
831 	STARTF_USEHOTKEY        = 0x0200;
832 
833 // ???
834 enum {
835 	TC_NORMAL  = 0,
836 	TC_HARDERR = 1,
837 	TC_GP_TRAP = 2,
838 	TC_SIGNAL  = 3
839 }
840 
841 /+ These seem to be Windows CE-specific
842 enum {
843 	AC_LINE_OFFLINE      = 0,
844 	AC_LINE_ONLINE       = 1,
845 	AC_LINE_BACKUP_POWER = 2,
846 	AC_LINE_UNKNOWN      = 255
847 }
848 
849 enum {
850 	BATTERY_FLAG_HIGH          = 1,
851 	BATTERY_FLAG_LOW           = 2,
852 	BATTERY_FLAG_CRITICAL      = 4,
853 	BATTERY_FLAG_CHARGING      = 8,
854 	BATTERY_FLAG_NO_BATTERY    = 128,
855 	BATTERY_FLAG_UNKNOWN       = 255,
856 	BATTERY_PERCENTAGE_UNKNOWN = 255,
857 	BATTERY_LIFE_UNKNOWN       = 0xFFFFFFFF
858 }
859 +/
860 
861 // ???
862 const HINSTANCE_ERROR = 32;
863 
864 // returned from GetFileSize()
865 const DWORD INVALID_FILE_SIZE = 0xFFFFFFFF;
866 
867 const DWORD TLS_OUT_OF_INDEXES = 0xFFFFFFFF;
868 
869 // GetWriteWatch()
870 const DWORD WRITE_WATCH_FLAG_RESET = 1;
871 
872 static if (_WIN32_WINNT_ONLY) {
873 	// for LogonUser()
874 	enum : DWORD {
875 		LOGON32_LOGON_INTERACTIVE = 2,
876 		LOGON32_LOGON_NETWORK     = 3,
877 		LOGON32_LOGON_BATCH       = 4,
878 		LOGON32_LOGON_SERVICE     = 5,
879 		LOGON32_LOGON_UNLOCK      = 7
880 	}
881 
882 	// for LogonUser()
883 	enum : DWORD {
884 		LOGON32_PROVIDER_DEFAULT,
885 		LOGON32_PROVIDER_WINNT35,
886 		LOGON32_PROVIDER_WINNT40,
887 		LOGON32_PROVIDER_WINNT50
888 	}
889 
890 	// for MoveFileEx()
891 	const DWORD
892 		MOVEFILE_REPLACE_EXISTING   = 1,
893 		MOVEFILE_COPY_ALLOWED       = 2,
894 		MOVEFILE_DELAY_UNTIL_REBOOT = 4,
895 		MOVEFILE_WRITE_THROUGH      = 8;
896 
897 	// DefineDosDevice()
898 	const DWORD
899 		DDD_RAW_TARGET_PATH       = 1,
900 		DDD_REMOVE_DEFINITION     = 2,
901 		DDD_EXACT_MATCH_ON_REMOVE = 4;
902 
903 	static if (_WIN32_WINNT >= 0x500) {
904 		enum : DWORD {
905 			LOGON32_LOGON_NETWORK_CLEARTEXT = 8,
906 			LOGON32_LOGON_NEW_CREDENTIALS   = 9
907 		}
908 
909 		// ReplaceFile()
910 		const DWORD
911 			REPLACEFILE_WRITE_THROUGH       = 1,
912 			REPLACEFILE_IGNORE_MERGE_ERRORS = 2;
913 	}
914 
915 	static if (_WIN32_WINNT >= 0x501) {
916 		const DWORD
917 			GET_MODULE_HANDLE_EX_FLAG_PIN                = 1,
918 			GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2,
919 			GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS       = 4;
920 
921 		// for ACTCTX
922 		const DWORD
923 			ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID = 0x01,
924 			ACTCTX_FLAG_LANGID_VALID                 = 0x02,
925 			ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID     = 0x04,
926 			ACTCTX_FLAG_RESOURCE_NAME_VALID          = 0x08,
927 			ACTCTX_FLAG_SET_PROCESS_DEFAULT          = 0x10,
928 			ACTCTX_FLAG_APPLICATION_NAME_VALID       = 0x20,
929 			ACTCTX_FLAG_HMODULE_VALID                = 0x80;
930 
931 		// DeactivateActCtx()
932 		const DWORD DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION = 1;
933 		// FindActCtxSectionString()
934 		const DWORD FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX          = 1;
935 		// QueryActCtxW()
936 		const DWORD
937 			QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX             = 0x04,
938 			QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE             = 0x08,
939 			QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS             = 0x10;
940 
941 		enum {
942 			LOGON_WITH_PROFILE        = 1,
943 			LOGON_NETCREDENTIALS_ONLY
944 		}
945 	}
946 }
947 
948 // ----
949 
950 struct FILETIME {
951 	DWORD dwLowDateTime;
952 	DWORD dwHighDateTime;
953 }
954 alias FILETIME* PFILETIME, LPFILETIME;
955 
956 struct BY_HANDLE_FILE_INFORMATION {
957 	DWORD    dwFileAttributes;
958 	FILETIME ftCreationTime;
959 	FILETIME ftLastAccessTime;
960 	FILETIME ftLastWriteTime;
961 	DWORD    dwVolumeSerialNumber;
962 	DWORD    nFileSizeHigh;
963 	DWORD    nFileSizeLow;
964 	DWORD    nNumberOfLinks;
965 	DWORD    nFileIndexHigh;
966 	DWORD    nFileIndexLow;
967 }
968 alias BY_HANDLE_FILE_INFORMATION* LPBY_HANDLE_FILE_INFORMATION;
969 
970 struct DCB {
971 	DWORD DCBlength = DCB.sizeof;
972 	DWORD BaudRate;
973 /+
974 	DWORD fBinary:1;              // Binary Mode (skip EOF check)
975 	DWORD fParity:1;              // Enable parity checking
976 	DWORD fOutxCtsFlow:1;         // CTS handshaking on output
977 	DWORD fOutxDsrFlow:1;         // DSR handshaking on output
978 	DWORD fDtrControl:2;          // DTR Flow control
979 	DWORD fDsrSensitivity:1;      // DSR Sensitivity
980 	DWORD fTXContinueOnXoff:1;    // Continue TX when Xoff sent
981 	DWORD fOutX:1;                // Enable output X-ON/X-OFF
982 	DWORD fInX:1;                 // Enable input X-ON/X-OFF
983 	DWORD fErrorChar:1;           // Enable Err Replacement
984 	DWORD fNull:1;                // Enable Null stripping
985 	DWORD fRtsControl:2;          // Rts Flow control
986 	DWORD fAbortOnError:1;        // Abort all reads and writes on Error
987 	DWORD fDummy2:17;             // Reserved
988 +/
989 	uint _bf;
990 	bool fBinary(bool f)           { _bf = (_bf & ~0x0001) | f; return f; }
991 	bool fParity(bool f)           { _bf = (_bf & ~0x0002) | (f<<1); return f; }
992 	bool fOutxCtsFlow(bool f)      { _bf = (_bf & ~0x0004) | (f<<2); return f; }
993 	bool fOutxDsrFlow(bool f)      { _bf = (_bf & ~0x0008) | (f<<3); return f; }
994 	byte fDtrControl(byte x)       { _bf = (_bf & ~0x0030) | (x<<4); return cast(byte)(x & 3); }
995 	bool fDsrSensitivity(bool f)   { _bf = (_bf & ~0x0040) | (f<<6); return f; }
996 	bool fTXContinueOnXoff(bool f) { _bf = (_bf & ~0x0080) | (f<<7); return f; }
997 	bool fOutX(bool f)             { _bf = (_bf & ~0x0100) | (f<<8); return f; }
998 	bool fInX(bool f)              { _bf = (_bf & ~0x0200) | (f<<9); return f; }
999 	bool fErrorChar(bool f)        { _bf = (_bf & ~0x0400) | (f<<10); return f; }
1000 	bool fNull(bool f)             { _bf = (_bf & ~0x0800) | (f<<11); return f; }
1001 	byte fRtsControl(byte x)       { _bf = (_bf & ~0x3000) | (x<<12); return cast(byte)(x & 3); }
1002 	bool fAbortOnError(bool f)     { _bf = (_bf & ~0x4000) | (f<<14); return f; }
1003 
1004 	bool fBinary()           { return cast(bool) (_bf & 1); }
1005 	bool fParity()           { return cast(bool) (_bf & 2); }
1006 	bool fOutxCtsFlow()      { return cast(bool) (_bf & 4); }
1007 	bool fOutxDsrFlow()      { return cast(bool) (_bf & 8); }
1008 	byte fDtrControl()       { return cast(byte) ((_bf & (32+16))>>4); }
1009 	bool fDsrSensitivity()   { return cast(bool) (_bf & 64); }
1010 	bool fTXContinueOnXoff() { return cast(bool) (_bf & 128); }
1011 	bool fOutX()             { return cast(bool) (_bf & 256); }
1012 	bool fInX()              { return cast(bool) (_bf & 512); }
1013 	bool fErrorChar()        { return cast(bool) (_bf & 1024); }
1014 	bool fNull()             { return cast(bool) (_bf & 2048); }
1015 	byte fRtsControl()       { return cast(byte) ((_bf & (4096+8192))>>12); }
1016 	bool fAbortOnError()     { return cast(bool) (_bf & 16384); }
1017 
1018 	WORD wReserved;
1019 	WORD XonLim;
1020 	WORD XoffLim;
1021 	BYTE ByteSize;
1022 	BYTE Parity;
1023 	BYTE StopBits;
1024 	char XonChar;
1025 	char XoffChar;
1026 	char ErrorChar;
1027 	char EofChar;
1028 	char EvtChar;
1029 	WORD wReserved1;
1030 }
1031 alias DCB* LPDCB;
1032 
1033 struct COMMCONFIG {
1034 	DWORD dwSize = COMMCONFIG.sizeof;
1035 	WORD  wVersion;
1036 	WORD  wReserved;
1037 	DCB   dcb;
1038 	DWORD dwProviderSubType;
1039 	DWORD dwProviderOffset;
1040 	DWORD dwProviderSize;
1041 	WCHAR _wcProviderData;
1042 
1043 	WCHAR* wcProviderData() { return &_wcProviderData; }
1044 }
1045 alias COMMCONFIG* LPCOMMCONFIG;
1046 
1047 struct COMMTIMEOUTS {
1048 	DWORD ReadIntervalTimeout;
1049 	DWORD ReadTotalTimeoutMultiplier;
1050 	DWORD ReadTotalTimeoutConstant;
1051 	DWORD WriteTotalTimeoutMultiplier;
1052 	DWORD WriteTotalTimeoutConstant;
1053 }
1054 alias COMMTIMEOUTS* LPCOMMTIMEOUTS;
1055 
1056 struct COMSTAT {
1057 /+
1058 	DWORD fCtsHold:1;
1059 	DWORD fDsrHold:1;
1060 	DWORD fRlsdHold:1;
1061 	DWORD fXoffHold:1;
1062 	DWORD fXoffSent:1;
1063 	DWORD fEof:1;
1064 	DWORD fTxim:1;
1065 	DWORD fReserved:25;
1066 +/
1067 	DWORD _bf;
1068     bool fCtsHold(bool f)  { _bf = (_bf & ~1) | f; return f; }
1069 	bool fDsrHold(bool f)  { _bf = (_bf & ~2) | (f<<1); return f; }
1070 	bool fRlsdHold(bool f) { _bf = (_bf & ~4) | (f<<2); return f; }
1071 	bool fXoffHold(bool f) { _bf = (_bf & ~8) | (f<<3); return f; }
1072 	bool fXoffSent(bool f) { _bf = (_bf & ~16) | (f<<4); return f; }
1073 	bool fEof(bool f)      { _bf = (_bf & ~32) | (f<<5); return f; }
1074 	bool fTxim(bool f)     { _bf = (_bf & ~64) | (f<<6); return f; }
1075 
1076     bool fCtsHold()  { return cast(bool) (_bf & 1); }
1077 	bool fDsrHold()  { return cast(bool) (_bf & 2); }
1078 	bool fRlsdHold() { return cast(bool) (_bf & 4); }
1079 	bool fXoffHold() { return cast(bool) (_bf & 8); }
1080 	bool fXoffSent() { return cast(bool) (_bf & 16); }
1081 	bool fEof()      { return cast(bool) (_bf & 32); }
1082 	bool fTxim()     { return cast(bool) (_bf & 64); }
1083 
1084 	DWORD cbInQue;
1085 	DWORD cbOutQue;
1086 }
1087 alias COMSTAT* LPCOMSTAT;
1088 
1089 struct CREATE_PROCESS_DEBUG_INFO {
1090 	HANDLE hFile;
1091 	HANDLE hProcess;
1092 	HANDLE hThread;
1093 	LPVOID lpBaseOfImage;
1094 	DWORD  dwDebugInfoFileOffset;
1095 	DWORD  nDebugInfoSize;
1096 	LPVOID lpThreadLocalBase;
1097 	LPTHREAD_START_ROUTINE lpStartAddress;
1098 	LPVOID lpImageName;
1099 	WORD   fUnicode;
1100 }
1101 alias CREATE_PROCESS_DEBUG_INFO* LPCREATE_PROCESS_DEBUG_INFO;
1102 
1103 struct CREATE_THREAD_DEBUG_INFO {
1104 	HANDLE hThread;
1105 	LPVOID lpThreadLocalBase;
1106 	LPTHREAD_START_ROUTINE lpStartAddress;
1107 }
1108 alias CREATE_THREAD_DEBUG_INFO* LPCREATE_THREAD_DEBUG_INFO;
1109 
1110 struct EXCEPTION_DEBUG_INFO {
1111 	EXCEPTION_RECORD ExceptionRecord;
1112 	DWORD            dwFirstChance;
1113 }
1114 alias EXCEPTION_DEBUG_INFO* LPEXCEPTION_DEBUG_INFO;
1115 
1116 struct EXIT_THREAD_DEBUG_INFO {
1117 	DWORD dwExitCode;
1118 }
1119 alias EXIT_THREAD_DEBUG_INFO* LPEXIT_THREAD_DEBUG_INFO;
1120 
1121 struct EXIT_PROCESS_DEBUG_INFO {
1122 	DWORD dwExitCode;
1123 }
1124 alias EXIT_PROCESS_DEBUG_INFO* LPEXIT_PROCESS_DEBUG_INFO;
1125 
1126 struct LOAD_DLL_DEBUG_INFO {
1127 	HANDLE hFile;
1128 	LPVOID lpBaseOfDll;
1129 	DWORD  dwDebugInfoFileOffset;
1130 	DWORD  nDebugInfoSize;
1131 	LPVOID lpImageName;
1132 	WORD   fUnicode;
1133 }
1134 alias LOAD_DLL_DEBUG_INFO* LPLOAD_DLL_DEBUG_INFO;
1135 
1136 struct UNLOAD_DLL_DEBUG_INFO {
1137 	LPVOID lpBaseOfDll;
1138 }
1139 alias UNLOAD_DLL_DEBUG_INFO* LPUNLOAD_DLL_DEBUG_INFO;
1140 
1141 struct OUTPUT_DEBUG_STRING_INFO {
1142 	LPSTR lpDebugStringData;
1143 	WORD  fUnicode;
1144 	WORD  nDebugStringLength;
1145 }
1146 alias OUTPUT_DEBUG_STRING_INFO* LPOUTPUT_DEBUG_STRING_INFO;
1147 
1148 struct RIP_INFO {
1149 	DWORD dwError;
1150 	DWORD dwType;
1151 }
1152 alias RIP_INFO* LPRIP_INFO;
1153 
1154 struct DEBUG_EVENT {
1155 	DWORD dwDebugEventCode;
1156 	DWORD dwProcessId;
1157 	DWORD dwThreadId;
1158 	union {
1159 		EXCEPTION_DEBUG_INFO      Exception;
1160 		CREATE_THREAD_DEBUG_INFO  CreateThread;
1161 		CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
1162 		EXIT_THREAD_DEBUG_INFO    ExitThread;
1163 		EXIT_PROCESS_DEBUG_INFO   ExitProcess;
1164 		LOAD_DLL_DEBUG_INFO       LoadDll;
1165 		UNLOAD_DLL_DEBUG_INFO     UnloadDll;
1166 		OUTPUT_DEBUG_STRING_INFO  DebugString;
1167 		RIP_INFO                  RipInfo;
1168 	}
1169 }
1170 alias DEBUG_EVENT* LPDEBUG_EVENT;
1171 
1172 struct OVERLAPPED {
1173 	ULONG_PTR Internal;
1174 	ULONG_PTR InternalHigh;
1175 	union {
1176 		struct {
1177 			DWORD     Offset;
1178 			DWORD     OffsetHigh;
1179 		}
1180 		PVOID     Pointer;
1181 	}
1182 	HANDLE    hEvent;
1183 }
1184 alias OVERLAPPED* POVERLAPPED, LPOVERLAPPED;
1185 
1186 struct STARTUPINFOA {
1187 	DWORD  cb = STARTUPINFOA.sizeof;
1188 	LPSTR  lpReserved;
1189 	LPSTR  lpDesktop;
1190 	LPSTR  lpTitle;
1191 	DWORD  dwX;
1192 	DWORD  dwY;
1193 	DWORD  dwXSize;
1194 	DWORD  dwYSize;
1195 	DWORD  dwXCountChars;
1196 	DWORD  dwYCountChars;
1197 	DWORD  dwFillAttribute;
1198 	DWORD  dwFlags;
1199 	WORD   wShowWindow;
1200 	WORD   cbReserved2;
1201 	PBYTE  lpReserved2;
1202 	HANDLE hStdInput;
1203 	HANDLE hStdOutput;
1204 	HANDLE hStdError;
1205 }
1206 alias STARTUPINFOA* LPSTARTUPINFOA;
1207 
1208 struct STARTUPINFOW {
1209 	DWORD  cb = STARTUPINFOW.sizeof;
1210 	LPWSTR lpReserved;
1211 	LPWSTR lpDesktop;
1212 	LPWSTR lpTitle;
1213 	DWORD  dwX;
1214 	DWORD  dwY;
1215 	DWORD  dwXSize;
1216 	DWORD  dwYSize;
1217 	DWORD  dwXCountChars;
1218 	DWORD  dwYCountChars;
1219 	DWORD  dwFillAttribute;
1220 	DWORD  dwFlags;
1221 	WORD   wShowWindow;
1222 	WORD   cbReserved2;
1223 	PBYTE  lpReserved2;
1224 	HANDLE hStdInput;
1225 	HANDLE hStdOutput;
1226 	HANDLE hStdError;
1227 }
1228 alias STARTUPINFOW* LPSTARTUPINFOW;
1229 
1230 struct PROCESS_INFORMATION {
1231 	HANDLE hProcess;
1232 	HANDLE hThread;
1233 	DWORD  dwProcessId;
1234 	DWORD  dwThreadId;
1235 }
1236 alias PROCESS_INFORMATION* PPROCESS_INFORMATION, LPPROCESS_INFORMATION;
1237 
1238 struct CRITICAL_SECTION_DEBUG {
1239 	WORD              Type;
1240 	WORD              CreatorBackTraceIndex;
1241 	CRITICAL_SECTION* CriticalSection;
1242 	LIST_ENTRY        ProcessLocksList;
1243 	DWORD             EntryCount;
1244 	DWORD             ContentionCount;
1245 	DWORD[2]          Spare;
1246 }
1247 alias CRITICAL_SECTION_DEBUG* PCRITICAL_SECTION_DEBUG;
1248 
1249 struct CRITICAL_SECTION {
1250 	PCRITICAL_SECTION_DEBUG DebugInfo;
1251 	LONG   LockCount;
1252 	LONG   RecursionCount;
1253 	HANDLE OwningThread;
1254 	HANDLE LockSemaphore;
1255 	DWORD  SpinCount;
1256 }
1257 alias CRITICAL_SECTION* PCRITICAL_SECTION, LPCRITICAL_SECTION;
1258 
1259 struct SYSTEMTIME {
1260 	WORD wYear;
1261 	WORD wMonth;
1262 	WORD wDayOfWeek;
1263 	WORD wDay;
1264 	WORD wHour;
1265 	WORD wMinute;
1266 	WORD wSecond;
1267 	WORD wMilliseconds;
1268 }
1269 alias SYSTEMTIME* LPSYSTEMTIME;
1270 
1271 static if (_WIN32_WINDOWS >= 0x410) {
1272 	struct WIN32_FILE_ATTRIBUTE_DATA {
1273 		DWORD    dwFileAttributes;
1274 		FILETIME ftCreationTime;
1275 		FILETIME ftLastAccessTime;
1276 		FILETIME ftLastWriteTime;
1277 		DWORD    nFileSizeHigh;
1278 		DWORD    nFileSizeLow;
1279 	}
1280 	alias WIN32_FILE_ATTRIBUTE_DATA* LPWIN32_FILE_ATTRIBUTE_DATA;
1281 }
1282 
1283 struct WIN32_FIND_DATAA {
1284 	DWORD          dwFileAttributes;
1285 	FILETIME       ftCreationTime;
1286 	FILETIME       ftLastAccessTime;
1287 	FILETIME       ftLastWriteTime;
1288 	DWORD          nFileSizeHigh;
1289 	DWORD          nFileSizeLow;
1290 // #ifdef _WIN32_WCE
1291 //	DWORD dwOID;
1292 // #else
1293 	DWORD          dwReserved0;
1294 	DWORD          dwReserved1;
1295 // #endif
1296 	CHAR[MAX_PATH] cFileName;
1297 // #ifndef _WIN32_WCE
1298 	CHAR[14]       cAlternateFileName;
1299 // #endif
1300 }
1301 alias WIN32_FIND_DATAA* PWIN32_FIND_DATAA, LPWIN32_FIND_DATAA;
1302 
1303 struct WIN32_FIND_DATAW {
1304 	DWORD           dwFileAttributes;
1305 	FILETIME        ftCreationTime;
1306 	FILETIME        ftLastAccessTime;
1307 	FILETIME        ftLastWriteTime;
1308 	DWORD           nFileSizeHigh;
1309 	DWORD           nFileSizeLow;
1310 // #ifdef _WIN32_WCE
1311 // 	DWORD dwOID;
1312 // #else
1313 	DWORD           dwReserved0;
1314 	DWORD           dwReserved1;
1315 // #endif
1316 	WCHAR[MAX_PATH] cFileName;
1317 // #ifndef _WIN32_WCE
1318 	WCHAR[14]       cAlternateFileName;
1319 // #endif
1320 }
1321 alias WIN32_FIND_DATAW* PWIN32_FIND_DATAW, LPWIN32_FIND_DATAW;
1322 
1323 static if (_WIN32_WINNT_ONLY) {
1324 	struct WIN32_STREAM_ID {
1325 		DWORD         dwStreamId;
1326 		DWORD         dwStreamAttributes;
1327 		LARGE_INTEGER Size;
1328 		DWORD         dwStreamNameSize;
1329 		WCHAR         _cStreamName;
1330 
1331 		WCHAR* cStreamName() { return &_cStreamName; }
1332 	}
1333 	alias WIN32_STREAM_ID* LPWIN32_STREAM_ID;
1334 
1335 	enum FINDEX_INFO_LEVELS {
1336 		FindExInfoStandard,
1337 		FindExInfoMaxInfoLevel
1338 	}
1339 
1340 	enum FINDEX_SEARCH_OPS {
1341 		FindExSearchNameMatch,
1342 		FindExSearchLimitToDirectories,
1343 		FindExSearchLimitToDevices,
1344 		FindExSearchMaxSearchOp
1345 	}
1346 
1347 	enum ACL_INFORMATION_CLASS {
1348 		AclRevisionInformation = 1,
1349 		AclSizeInformation
1350 	}
1351 
1352 	struct HW_PROFILE_INFOA {
1353 		DWORD dwDockInfo;
1354 		CHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid;
1355 		CHAR[MAX_PROFILE_LEN]    szHwProfileName;
1356 	}
1357 	alias HW_PROFILE_INFOA* LPHW_PROFILE_INFOA;
1358 
1359 	struct HW_PROFILE_INFOW {
1360 		DWORD dwDockInfo;
1361 		WCHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid;
1362 		WCHAR[MAX_PROFILE_LEN]    szHwProfileName;
1363 	}
1364 	alias HW_PROFILE_INFOW* LPHW_PROFILE_INFOW;
1365 }
1366 
1367 /*	??? MSDN documents this only for Windows CE/Mobile, but it's used by
1368  *	GetFileAttributesEx, which is in desktop Windows.
1369  */
1370 enum GET_FILEEX_INFO_LEVELS {
1371 	GetFileExInfoStandard,
1372 	GetFileExMaxInfoLevel
1373 }
1374 
1375 struct SYSTEM_INFO {
1376 	union {
1377 		DWORD dwOemId;
1378 		struct {
1379 			WORD wProcessorArchitecture;
1380 			WORD wReserved;
1381 		}
1382 	}
1383 	DWORD dwPageSize;
1384 	PVOID lpMinimumApplicationAddress;
1385 	PVOID lpMaximumApplicationAddress;
1386 	DWORD dwActiveProcessorMask;
1387 	DWORD dwNumberOfProcessors;
1388 	DWORD dwProcessorType;
1389 	DWORD dwAllocationGranularity;
1390 	WORD  wProcessorLevel;
1391 	WORD  wProcessorRevision;
1392 }
1393 alias SYSTEM_INFO* LPSYSTEM_INFO;
1394 
1395 static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
1396 	struct SYSTEM_POWER_STATUS {
1397 		BYTE ACLineStatus;
1398 		BYTE BatteryFlag;
1399 		BYTE BatteryLifePercent;
1400 		BYTE Reserved1;
1401 		DWORD BatteryLifeTime;
1402 		DWORD BatteryFullLifeTime;
1403 	}
1404 	alias SYSTEM_POWER_STATUS* LPSYSTEM_POWER_STATUS;
1405 }
1406 
1407 struct TIME_ZONE_INFORMATION {
1408 	LONG       Bias;
1409 	WCHAR[32]  StandardName;
1410 	SYSTEMTIME StandardDate;
1411 	LONG       StandardBias;
1412 	WCHAR[32]  DaylightName;
1413 	SYSTEMTIME DaylightDate;
1414 	LONG       DaylightBias;
1415 }
1416 alias TIME_ZONE_INFORMATION* LPTIME_ZONE_INFORMATION;
1417 
1418 // MSDN documents this, possibly erroneously, as Win2000+.
1419 struct MEMORYSTATUS {
1420 	DWORD dwLength;
1421 	DWORD dwMemoryLoad;
1422 	DWORD dwTotalPhys;
1423 	DWORD dwAvailPhys;
1424 	DWORD dwTotalPageFile;
1425 	DWORD dwAvailPageFile;
1426 	DWORD dwTotalVirtual;
1427 	DWORD dwAvailVirtual;
1428 }
1429 alias MEMORYSTATUS* LPMEMORYSTATUS;
1430 
1431 static if (_WIN32_WINNT >= 0x500) {
1432 	struct MEMORYSTATUSEX {
1433 		DWORD     dwLength;
1434 		DWORD     dwMemoryLoad;
1435 		DWORDLONG ullTotalPhys;
1436 		DWORDLONG ullAvailPhys;
1437 		DWORDLONG ullTotalPageFile;
1438 		DWORDLONG ullAvailPageFile;
1439 		DWORDLONG ullTotalVirtual;
1440 		DWORDLONG ullAvailVirtual;
1441 		DWORDLONG ullAvailExtendedVirtual;
1442 	}
1443 	alias MEMORYSTATUSEX* LPMEMORYSTATUSEX;
1444 }
1445 
1446 struct LDT_ENTRY {
1447 	WORD LimitLow;
1448 	WORD BaseLow;
1449 	struct {
1450 		BYTE BaseMid;
1451 		BYTE Flags1;
1452 		BYTE Flags2;
1453 		BYTE BaseHi;
1454 
1455 		byte Type(byte f)        { Flags1 = cast(BYTE) ((Flags1 & 0xE0) | f); return cast(byte)(f & 0x1F); }
1456 		byte Dpl(byte f)         { Flags1 = cast(BYTE) ((Flags1 & 0x9F) | (f<<5)); return cast(byte)(f & 3); }
1457 		bool Pres(bool f)        { Flags1 = cast(BYTE) ((Flags1 & 0x7F) | (f<<7)); return f; }
1458 
1459 		byte LimitHi(byte f)     { Flags2 = cast(BYTE) ((Flags2 & 0xF0) | (f&0x0F)); return cast(byte)(f & 0x0F); }
1460 		bool Sys(bool f)         { Flags2 = cast(BYTE) ((Flags2 & 0xEF) | (f<<4)); return f; }
1461 		// Next bit is reserved
1462 		bool Default_Big(bool f) { Flags2 = cast(BYTE) ((Flags2 & 0xBF) | (f<<6)); return f; }
1463 		bool Granularity(bool f) { Flags2 = cast(BYTE) ((Flags2 & 0x7F) | (f<<7)); return f; }
1464 
1465 		byte Type()        { return cast(byte) (Flags1 & 0x1F); }
1466 		byte Dpl()         { return cast(byte) ((Flags1 & 0x60)>>5); }
1467 		bool Pres()        { return cast(bool) (Flags1 & 0x80); }
1468 
1469 		byte LimitHi()     { return cast(byte) (Flags2 & 0x0F); }
1470 		bool Sys()         { return cast(bool) (Flags2 & 0x10); }
1471 		bool Default_Big() { return cast(bool) (Flags2 & 0x40); }
1472 		bool Granularity() { return cast(bool) (Flags2 & 0x80); }
1473 	}
1474 /+
1475 	union  HighWord {
1476 		struct Bytes {
1477 			BYTE BaseMid;
1478 			BYTE Flags1;
1479 			BYTE Flags2;
1480 			BYTE BaseHi;
1481 		}
1482 	struct Bits {
1483 		DWORD BaseMid:8;
1484 		DWORD Type:5;
1485 		DWORD Dpl:2;
1486 		DWORD Pres:1;
1487 		DWORD LimitHi:4;
1488 		DWORD Sys:1;
1489 		DWORD Reserved_0:1;
1490 		DWORD Default_Big:1;
1491 		DWORD Granularity:1;
1492 		DWORD BaseHi:8;
1493 	}
1494 	}
1495 +/
1496 }
1497 alias LDT_ENTRY* PLDT_ENTRY, LPLDT_ENTRY;
1498 
1499 /*	As with the other memory management functions and structures, MSDN's
1500  *	Windows version info shall be taken with a cup of salt.
1501  */
1502 struct PROCESS_HEAP_ENTRY {
1503 	PVOID lpData;
1504 	DWORD cbData;
1505 	BYTE  cbOverhead;
1506 	BYTE  iRegionIndex;
1507 	WORD  wFlags;
1508 	union {
1509 		struct Block {
1510 			HANDLE   hMem;
1511 			DWORD[3] dwReserved;
1512 		}
1513 		struct Region {
1514 			DWORD    dwCommittedSize;
1515 			DWORD    dwUnCommittedSize;
1516 			LPVOID   lpFirstBlock;
1517 			LPVOID   lpLastBlock;
1518 		}
1519 	}
1520 }
1521 alias PROCESS_HEAP_ENTRY* LPPROCESS_HEAP_ENTRY;
1522 
1523 struct OFSTRUCT {
1524 	BYTE      cBytes = OFSTRUCT.sizeof;
1525 	BYTE      fFixedDisk;
1526 	WORD      nErrCode;
1527 	WORD      Reserved1;
1528 	WORD      Reserved2;
1529 	CHAR[128] szPathName; // const OFS_MAXPATHNAME = 128;
1530 }
1531 alias OFSTRUCT* LPOFSTRUCT, POFSTRUCT;
1532 
1533 /*	??? MSDN documents this only for Windows CE, but it's used by
1534  *	ImageGetCertificateData, which is in desktop Windows.
1535  */
1536 struct WIN_CERTIFICATE {
1537 	DWORD dwLength;
1538 	WORD  wRevision;
1539 	WORD  wCertificateType;
1540 	BYTE  _bCertificate;
1541 
1542 	BYTE* bCertificate() { return &_bCertificate; }
1543 }
1544 alias WIN_CERTIFICATE* LPWIN_CERTIFICATE;
1545 
1546 static if (_WIN32_WINNT >= 0x500) {
1547 	enum COMPUTER_NAME_FORMAT {
1548 		ComputerNameNetBIOS,
1549 		ComputerNameDnsHostname,
1550 		ComputerNameDnsDomain,
1551 		ComputerNameDnsFullyQualified,
1552 		ComputerNamePhysicalNetBIOS,
1553 		ComputerNamePhysicalDnsHostname,
1554 		ComputerNamePhysicalDnsDomain,
1555 		ComputerNamePhysicalDnsFullyQualified,
1556 		ComputerNameMax
1557 	}
1558 }
1559 
1560 static if (_WIN32_WINNT >= 0x501) {
1561 	struct ACTCTXA {
1562 		ULONG cbSize = this.sizeof;
1563 		DWORD dwFlags;
1564 		LPCSTR lpSource;
1565 		USHORT wProcessorArchitecture;
1566 		LANGID wLangId;
1567 		LPCSTR lpAssemblyDirectory;
1568 		LPCSTR lpResourceName;
1569 		LPCSTR lpApplicationName;
1570 		HMODULE hModule;
1571 	}
1572 	alias ACTCTXA*       PACTCTXA;
1573 	alias CPtr!(ACTCTXA) PCACTCTXA;
1574 
1575 	struct ACTCTXW {
1576 		ULONG cbSize = this.sizeof;
1577 		DWORD dwFlags;
1578 		LPCWSTR lpSource;
1579 		USHORT wProcessorArchitecture;
1580 		LANGID wLangId;
1581 		LPCWSTR lpAssemblyDirectory;
1582 		LPCWSTR lpResourceName;
1583 		LPCWSTR lpApplicationName;
1584 		HMODULE hModule;
1585 	}
1586 	alias ACTCTXW*       PACTCTXW;
1587 	alias CPtr!(ACTCTXW) PCACTCTXW;
1588 
1589 	struct ACTCTX_SECTION_KEYED_DATA {
1590 		ULONG cbSize = this.sizeof;
1591 		ULONG ulDataFormatVersion;
1592 		PVOID lpData;
1593 		ULONG ulLength;
1594 		PVOID lpSectionGlobalData;
1595 		ULONG ulSectionGlobalDataLength;
1596 		PVOID lpSectionBase;
1597 		ULONG ulSectionTotalLength;
1598 		HANDLE hActCtx;
1599 		HANDLE ulAssemblyRosterIndex;
1600 	}
1601 	alias ACTCTX_SECTION_KEYED_DATA*       PACTCTX_SECTION_KEYED_DATA;
1602 	alias CPtr!(ACTCTX_SECTION_KEYED_DATA) PCACTCTX_SECTION_KEYED_DATA;
1603 
1604 	enum MEMORY_RESOURCE_NOTIFICATION_TYPE {
1605 		LowMemoryResourceNotification,
1606 		HighMemoryResourceNotification
1607 	}
1608 
1609 } // (_WIN32_WINNT >= 0x0501)
1610 
1611 static if (WINVER >= 0x410) {
1612 	/*	apparently used only by SetThreadExecutionState (Win2000+)
1613 	 *	and DDK functions (version compatibility not established)
1614 	 */
1615 	alias DWORD EXECUTION_STATE;
1616 }
1617 
1618 // Callbacks
1619 extern (Windows) {
1620 	alias DWORD function(LPVOID) LPTHREAD_START_ROUTINE;
1621 	alias DWORD function(LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER,
1622 		DWORD, DWORD, HANDLE, HANDLE, LPVOID)  LPPROGRESS_ROUTINE;
1623 	alias void function(PVOID) LPFIBER_START_ROUTINE;
1624 
1625 	alias BOOL function(HMODULE, LPCSTR, LPCSTR, WORD, LONG) ENUMRESLANGPROCA;
1626 	alias BOOL function(HMODULE, LPCWSTR, LPCWSTR, WORD, LONG) ENUMRESLANGPROCW;
1627 	alias BOOL function(HMODULE, LPCSTR, LPSTR, LONG) ENUMRESNAMEPROCA;
1628 	alias BOOL function(HMODULE, LPCWSTR, LPWSTR, LONG) ENUMRESNAMEPROCW;
1629 	alias BOOL function(HMODULE, LPSTR, LONG) ENUMRESTYPEPROCA;
1630 	alias BOOL function(HMODULE, LPWSTR, LONG) ENUMRESTYPEPROCW;
1631 	alias void function(DWORD, DWORD, LPOVERLAPPED) LPOVERLAPPED_COMPLETION_ROUTINE;
1632 	alias LONG function(LPEXCEPTION_POINTERS) PTOP_LEVEL_EXCEPTION_FILTER;
1633 	alias PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1634 
1635 	alias void function(ULONG_PTR) PAPCFUNC;
1636 	alias void function(PVOID, DWORD, DWORD) PTIMERAPCROUTINE;
1637 
1638 	static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
1639 		alias void function(PVOID, BOOLEAN) WAITORTIMERCALLBACK;
1640 	}
1641 }
1642 
1643 LPTSTR MAKEINTATOM(short i) {
1644 	return cast(LPTSTR) i;
1645 }
1646 
1647 extern (Windows) {
1648 	ATOM AddAtomA(LPCSTR);
1649 	ATOM AddAtomW(LPCWSTR);
1650 	BOOL AreFileApisANSI();
1651 	BOOL Beep(DWORD, DWORD);
1652 	HANDLE BeginUpdateResourceA(LPCSTR, BOOL);
1653 	HANDLE BeginUpdateResourceW(LPCWSTR, BOOL);
1654 	BOOL BuildCommDCBA(LPCSTR, LPDCB);
1655 	BOOL BuildCommDCBW(LPCWSTR, LPDCB);
1656 	BOOL BuildCommDCBAndTimeoutsA(LPCSTR, LPDCB, LPCOMMTIMEOUTS);
1657 	BOOL BuildCommDCBAndTimeoutsW(LPCWSTR, LPDCB, LPCOMMTIMEOUTS);
1658 	BOOL CallNamedPipeA(LPCSTR, PVOID, DWORD, PVOID, DWORD, PDWORD, DWORD);
1659 	BOOL CallNamedPipeW(LPCWSTR, PVOID, DWORD, PVOID, DWORD, PDWORD, DWORD);
1660 	BOOL CancelDeviceWakeupRequest(HANDLE);
1661 	BOOL CheckTokenMembership(HANDLE, PSID, PBOOL);
1662 	BOOL ClearCommBreak(HANDLE);
1663 	BOOL ClearCommError(HANDLE, PDWORD, LPCOMSTAT);
1664 	BOOL CloseHandle(HANDLE);
1665 	BOOL CommConfigDialogA(LPCSTR, HWND, LPCOMMCONFIG);
1666 	BOOL CommConfigDialogW(LPCWSTR, HWND, LPCOMMCONFIG);
1667 	LONG CompareFileTime(CPtr!(FILETIME), CPtr!(FILETIME));
1668 	BOOL ContinueDebugEvent(DWORD, DWORD, DWORD);
1669 	BOOL CopyFileA(LPCSTR, LPCSTR, BOOL);
1670 	BOOL CopyFileW(LPCWSTR, LPCWSTR, BOOL);
1671 	BOOL CopyFileExA(LPCSTR, LPCSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
1672 	BOOL CopyFileExW(LPCWSTR, LPCWSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
1673 
1674 	/+ FIXME
1675 	alias memmove RtlMoveMemory;
1676 	alias memcpy RtlCopyMemory;
1677 
1678 	void RtlFillMemory(PVOID dest, SIZE_T len, BYTE fill) {
1679 		memset(dest, fill, len);
1680 	}
1681 
1682 	void RtlZeroMemory(PVOID dest, SIZE_T len) {
1683 		RtlFillMemory(dest, len , 0);
1684 	}
1685 
1686 	alias RtlMoveMemory MoveMemory;
1687 	alias RtlCopyMemory CopyMemory;
1688 	alias RtlFillMemory FillMemory;
1689 	alias RtlZeroMemory ZeroMemory;
1690 	+/
1691 	BOOL CreateDirectoryA(LPCSTR, LPSECURITY_ATTRIBUTES);
1692 	BOOL CreateDirectoryW(LPCWSTR, LPSECURITY_ATTRIBUTES);
1693 	BOOL CreateDirectoryExA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
1694 	BOOL CreateDirectoryExW(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
1695 	HANDLE CreateEventA(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCSTR);
1696 	HANDLE CreateEventW(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCWSTR);
1697 	HANDLE CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
1698 	HANDLE CreateFileW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
1699 	HANDLE CreateIoCompletionPort(HANDLE, HANDLE, ULONG_PTR, DWORD);
1700 	HANDLE CreateMailslotA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
1701 	HANDLE CreateMailslotW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
1702 	HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
1703 	HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
1704 	BOOL CreatePipe(PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD);
1705 	BOOL CreateProcessA(LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
1706 	BOOL CreateProcessW(LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
1707 	HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCSTR);
1708 	HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCWSTR);
1709 	HANDLE CreateThread(LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, PVOID, DWORD, PDWORD);
1710 	BOOL DebugActiveProcess(DWORD);
1711 	void DebugBreak();
1712 	ATOM DeleteAtom(ATOM);
1713 	void DeleteCriticalSection(PCRITICAL_SECTION);
1714 	BOOL DeleteFileA(LPCSTR);
1715 	BOOL DeleteFileW(LPCWSTR);
1716 	BOOL DisableThreadLibraryCalls(HMODULE);
1717 	BOOL DosDateTimeToFileTime(WORD, WORD, LPFILETIME);
1718 	BOOL DuplicateHandle(HANDLE, HANDLE, HANDLE, PHANDLE, DWORD, BOOL, DWORD);
1719 	BOOL EndUpdateResourceA(HANDLE, BOOL);
1720 	BOOL EndUpdateResourceW(HANDLE, BOOL);
1721 	void EnterCriticalSection(LPCRITICAL_SECTION);
1722 	BOOL EnumResourceLanguagesA(HMODULE, LPCSTR, LPCSTR, ENUMRESLANGPROC, LONG_PTR);
1723 	BOOL EnumResourceLanguagesW(HMODULE, LPCWSTR, LPCWSTR, ENUMRESLANGPROC, LONG_PTR);
1724 	BOOL EnumResourceNamesA(HMODULE, LPCSTR, ENUMRESNAMEPROC, LONG_PTR);
1725 	BOOL EnumResourceNamesW(HMODULE, LPCWSTR, ENUMRESNAMEPROC, LONG_PTR);
1726 	BOOL EnumResourceTypesA(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
1727 	BOOL EnumResourceTypesW(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
1728 	BOOL EscapeCommFunction(HANDLE, DWORD);
1729 	void ExitProcess(UINT); // Never returns
1730 	void ExitThread(DWORD); // Never returns
1731 	DWORD ExpandEnvironmentStringsA(LPCSTR, LPSTR, DWORD);
1732 	DWORD ExpandEnvironmentStringsW(LPCWSTR, LPWSTR, DWORD);
1733 	void FatalAppExitA(UINT, LPCSTR);
1734 	void FatalAppExitW(UINT, LPCWSTR);
1735 	void FatalExit(int);
1736 	BOOL FileTimeToDosDateTime(CPtr!(FILETIME) , LPWORD, LPWORD);
1737 	BOOL FileTimeToLocalFileTime(CPtr!(FILETIME) , LPFILETIME);
1738 	BOOL FileTimeToSystemTime(CPtr!(FILETIME) , LPSYSTEMTIME);
1739 	ATOM FindAtomA(LPCSTR);
1740 	ATOM FindAtomW(LPCWSTR);
1741 	BOOL FindClose(HANDLE);
1742 	BOOL FindCloseChangeNotification(HANDLE);
1743 	HANDLE FindFirstChangeNotificationA(LPCSTR, BOOL, DWORD);
1744 	HANDLE FindFirstChangeNotificationW(LPCWSTR, BOOL, DWORD);
1745 	HANDLE FindFirstFileA(LPCSTR, LPWIN32_FIND_DATAA);
1746 	HANDLE FindFirstFileW(LPCWSTR, LPWIN32_FIND_DATAW);
1747 	BOOL FindNextChangeNotification(HANDLE);
1748 	BOOL FindNextFileA(HANDLE, LPWIN32_FIND_DATAA);
1749 	BOOL FindNextFileW(HANDLE, LPWIN32_FIND_DATAW);
1750 	HRSRC FindResourceA(HMODULE, LPCSTR, LPCSTR);
1751 	HRSRC FindResourceW(HINSTANCE, LPCWSTR, LPCWSTR);
1752 	HRSRC FindResourceExA(HINSTANCE, LPCSTR, LPCSTR, WORD);
1753 	HRSRC FindResourceExW(HINSTANCE, LPCWSTR, LPCWSTR, WORD);
1754 	BOOL FlushFileBuffers(HANDLE);
1755 	BOOL FlushInstructionCache(HANDLE, PCVOID, DWORD);
1756 	DWORD FormatMessageA(DWORD, PCVOID, DWORD, DWORD, LPSTR, DWORD, va_list*);
1757 	DWORD FormatMessageW(DWORD, PCVOID, DWORD, DWORD, LPWSTR, DWORD, va_list*);
1758 	BOOL FreeEnvironmentStringsA(LPSTR);
1759 	BOOL FreeEnvironmentStringsW(LPWSTR);
1760 	BOOL FreeLibrary(HMODULE);
1761 	void FreeLibraryAndExitThread(HMODULE, DWORD); // never returns
1762 	BOOL FreeResource(HGLOBAL);
1763 	UINT GetAtomNameA(ATOM, LPSTR, int);
1764 	UINT GetAtomNameW(ATOM, LPWSTR, int);
1765 	LPSTR GetCommandLineA();
1766 	LPWSTR GetCommandLineW();
1767 	BOOL GetCommConfig(HANDLE, LPCOMMCONFIG, PDWORD);
1768 	BOOL GetCommMask(HANDLE, PDWORD);
1769 	BOOL GetCommModemStatus(HANDLE, PDWORD);
1770 	BOOL GetCommProperties(HANDLE, LPCOMMPROP);
1771 	BOOL GetCommState(HANDLE, LPDCB);
1772 	BOOL GetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
1773 	BOOL GetComputerNameA(LPSTR, PDWORD);
1774 	BOOL GetComputerNameW(LPWSTR, PDWORD);
1775 	DWORD GetCurrentDirectoryA(DWORD, LPSTR);
1776 	DWORD GetCurrentDirectoryW(DWORD, LPWSTR);
1777 	HANDLE GetCurrentProcess();
1778 	DWORD GetCurrentProcessId();
1779 	HANDLE GetCurrentThread();
1780 /* In MinGW:
1781 #ifdef _WIN32_WCE
1782 extern DWORD GetCurrentThreadId(void);
1783 #else
1784 WINBASEAPI DWORD WINAPI GetCurrentThreadId(void);
1785 #endif
1786 */
1787 	DWORD GetCurrentThreadId();
1788 
1789 	alias GetTickCount GetCurrentTime;
1790 
1791 	BOOL GetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, PDWORD);
1792 	BOOL GetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, PDWORD);
1793 	BOOL GetDiskFreeSpaceA(LPCSTR, PDWORD, PDWORD, PDWORD, PDWORD);
1794 	BOOL GetDiskFreeSpaceW(LPCWSTR, PDWORD, PDWORD, PDWORD, PDWORD);
1795 	BOOL GetDiskFreeSpaceExA(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
1796 	BOOL GetDiskFreeSpaceExW(LPCWSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
1797 	UINT GetDriveTypeA(LPCSTR);
1798 	UINT GetDriveTypeW(LPCWSTR);
1799 	LPSTR GetEnvironmentStrings(); // ???
1800 	LPSTR GetEnvironmentStringsA();
1801 	LPWSTR GetEnvironmentStringsW();
1802 	DWORD GetEnvironmentVariableA(LPCSTR, LPSTR, DWORD);
1803 	DWORD GetEnvironmentVariableW(LPCWSTR, LPWSTR, DWORD);
1804 	BOOL GetExitCodeProcess(HANDLE, PDWORD);
1805 	BOOL GetExitCodeThread(HANDLE, PDWORD);
1806 	DWORD GetFileAttributesA(LPCSTR);
1807 	DWORD GetFileAttributesW(LPCWSTR);
1808 	BOOL GetFileInformationByHandle(HANDLE, LPBY_HANDLE_FILE_INFORMATION);
1809 	DWORD GetFileSize(HANDLE, PDWORD);
1810 	BOOL GetFileTime(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME);
1811 	DWORD GetFileType(HANDLE);
1812 	DWORD GetFullPathNameA(LPCSTR, DWORD, LPSTR, LPSTR*);
1813 	DWORD GetFullPathNameW(LPCWSTR, DWORD, LPWSTR, LPWSTR*);
1814 	DWORD GetLastError();
1815 	void GetLocalTime(LPSYSTEMTIME);
1816 	DWORD GetLogicalDrives();
1817 	DWORD GetLogicalDriveStringsA(DWORD, LPSTR);
1818 	DWORD GetLogicalDriveStringsW(DWORD, LPWSTR);
1819 	BOOL GetMailslotInfo(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD);
1820 	DWORD GetModuleFileNameA(HINSTANCE, LPSTR, DWORD);
1821 	DWORD GetModuleFileNameW(HINSTANCE, LPWSTR, DWORD);
1822 	HMODULE GetModuleHandleA(LPCSTR);
1823 	HMODULE GetModuleHandleW(LPCWSTR);
1824 	BOOL GetNamedPipeHandleStateA(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD, LPSTR, DWORD);
1825 	BOOL GetNamedPipeHandleStateW(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD, LPWSTR, DWORD);
1826 	BOOL GetNamedPipeInfo(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD);
1827 	BOOL GetOverlappedResult(HANDLE, LPOVERLAPPED, PDWORD, BOOL);
1828 	DWORD GetPriorityClass(HANDLE);
1829 	UINT GetPrivateProfileIntA(LPCSTR, LPCSTR, INT, LPCSTR);
1830 	UINT GetPrivateProfileIntW(LPCWSTR, LPCWSTR, INT, LPCWSTR);
1831 	DWORD GetPrivateProfileSectionA(LPCSTR, LPSTR, DWORD, LPCSTR);
1832 	DWORD GetPrivateProfileSectionW(LPCWSTR, LPWSTR, DWORD, LPCWSTR);
1833 	DWORD GetPrivateProfileSectionNamesA(LPSTR, DWORD, LPCSTR);
1834 	DWORD GetPrivateProfileSectionNamesW(LPWSTR, DWORD, LPCWSTR);
1835 	DWORD GetPrivateProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPSTR, DWORD, LPCSTR);
1836 	DWORD GetPrivateProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD, LPCWSTR);
1837 	BOOL GetPrivateProfileStructA(LPCSTR, LPCSTR, LPVOID, UINT, LPCSTR);
1838 	BOOL GetPrivateProfileStructW(LPCWSTR, LPCWSTR, LPVOID, UINT, LPCWSTR);
1839 	FARPROC GetProcAddress(HINSTANCE, LPCSTR);
1840 	BOOL GetProcessAffinityMask(HANDLE, PDWORD, PDWORD);
1841 	DWORD GetProcessVersion(DWORD);
1842 	UINT GetProfileIntA(LPCSTR, LPCSTR, INT);
1843 	UINT GetProfileIntW(LPCWSTR, LPCWSTR, INT);
1844 	DWORD GetProfileSectionA(LPCSTR, LPSTR, DWORD);
1845 	DWORD GetProfileSectionW(LPCWSTR, LPWSTR, DWORD);
1846 	DWORD GetProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPSTR, DWORD);
1847 	DWORD GetProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD);
1848 	DWORD GetShortPathNameA(LPCSTR, LPSTR, DWORD);
1849 	DWORD GetShortPathNameW(LPCWSTR, LPWSTR, DWORD);
1850 	VOID GetStartupInfoA(LPSTARTUPINFOA);
1851 	VOID GetStartupInfoW(LPSTARTUPINFOW);
1852 	HANDLE GetStdHandle(DWORD);
1853 	UINT GetSystemDirectoryA(LPSTR, UINT);
1854 	UINT GetSystemDirectoryW(LPWSTR, UINT);
1855 	VOID GetSystemInfo(LPSYSTEM_INFO);
1856 	VOID GetSystemTime(LPSYSTEMTIME);
1857 	BOOL GetSystemTimeAdjustment(PDWORD, PDWORD, PBOOL);
1858 	void GetSystemTimeAsFileTime(LPFILETIME);
1859 	UINT GetTempFileNameA(LPCSTR, LPCSTR, UINT, LPSTR);
1860 	UINT GetTempFileNameW(LPCWSTR, LPCWSTR, UINT, LPWSTR);
1861 	DWORD GetTempPathA(DWORD, LPSTR);
1862 	DWORD GetTempPathW(DWORD, LPWSTR);
1863 	BOOL GetThreadContext(HANDLE, LPCONTEXT);
1864 	int GetThreadPriority(HANDLE);
1865 	BOOL GetThreadSelectorEntry(HANDLE, DWORD, LPLDT_ENTRY);
1866 	DWORD GetTickCount();
1867 	DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION);
1868 	BOOL GetUserNameA (LPSTR, PDWORD);
1869 	BOOL GetUserNameW(LPWSTR, PDWORD);
1870 	DWORD GetVersion();
1871 	BOOL GetVersionExA(LPOSVERSIONINFOA);
1872 	BOOL GetVersionExW(LPOSVERSIONINFOW);
1873 	BOOL GetVolumeInformationA(LPCSTR, LPSTR, DWORD, PDWORD, PDWORD, PDWORD, LPSTR, DWORD);
1874 	BOOL GetVolumeInformationW(LPCWSTR, LPWSTR, DWORD, PDWORD, PDWORD, PDWORD, LPWSTR, DWORD);
1875 	UINT GetWindowsDirectoryA(LPSTR, UINT);
1876 	UINT GetWindowsDirectoryW(LPWSTR, UINT);
1877 	DWORD GetWindowThreadProcessId(HWND, PDWORD);
1878 	ATOM GlobalAddAtomA(LPCSTR);
1879 	ATOM GlobalAddAtomW(LPCWSTR);
1880 	ATOM GlobalDeleteAtom(ATOM);
1881 	ATOM GlobalFindAtomA(LPCSTR);
1882 	ATOM GlobalFindAtomW(LPCWSTR);
1883 	UINT GlobalGetAtomNameA(ATOM, LPSTR, int);
1884 	UINT GlobalGetAtomNameW(ATOM, LPWSTR, int);
1885 
1886 	bool HasOverlappedIoCompleted(LPOVERLAPPED lpOverlapped) {
1887 		return lpOverlapped.Internal != STATUS_PENDING;
1888 	}
1889 
1890 	BOOL InitAtomTable(DWORD);
1891 	VOID InitializeCriticalSection(LPCRITICAL_SECTION);
1892 	/*	??? The next two are allegedly obsolete and "supported only for
1893 	 *	backward compatibility with the 16-bit Windows API".  Yet the
1894 	 *	replacements IsBadReadPtr and IsBadWritePtr are apparently Win2000+
1895 	 *	only.  Where's the mistake?
1896 	 */
1897 	BOOL IsBadHugeReadPtr(PCVOID, UINT);
1898 	BOOL IsBadHugeWritePtr(PVOID, UINT);
1899 	BOOL IsBadReadPtr(PCVOID, UINT);
1900 	BOOL IsBadStringPtrA(LPCSTR, UINT);
1901 	BOOL IsBadStringPtrW(LPCWSTR, UINT);
1902 	BOOL IsBadWritePtr(PVOID, UINT);
1903 	void LeaveCriticalSection(LPCRITICAL_SECTION);
1904 	HINSTANCE LoadLibraryA(LPCSTR);
1905 	HINSTANCE LoadLibraryW(LPCWSTR);
1906 	HINSTANCE LoadLibraryExA(LPCSTR, HANDLE, DWORD);
1907 	HINSTANCE LoadLibraryExW(LPCWSTR, HANDLE, DWORD);
1908 	DWORD LoadModule(LPCSTR, PVOID);
1909 	HGLOBAL LoadResource(HINSTANCE, HRSRC);
1910 	BOOL LocalFileTimeToFileTime(CPtr!(FILETIME) , LPFILETIME);
1911 	BOOL LockFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
1912 	PVOID LockResource(HGLOBAL);
1913 
1914 	LPSTR lstrcatA(LPSTR, LPCSTR);
1915 	LPWSTR lstrcatW(LPWSTR, LPCWSTR);
1916 	int lstrcmpA(LPCSTR, LPCSTR);
1917 	int lstrcmpiA(LPCSTR, LPCSTR);
1918 	int lstrcmpiW(LPCWSTR, LPCWSTR);
1919 	int lstrcmpW(LPCWSTR, LPCWSTR);
1920 	LPSTR lstrcpyA(LPSTR, LPCSTR);
1921 	LPSTR lstrcpynA(LPSTR, LPCSTR, int);
1922 	LPWSTR lstrcpynW(LPWSTR, LPCWSTR, int);
1923 	LPWSTR lstrcpyW(LPWSTR, LPCWSTR);
1924 	int lstrlenA(LPCSTR);
1925 	int lstrlenW(LPCWSTR);
1926 
1927 	BOOL MoveFileA(LPCSTR, LPCSTR);
1928 	BOOL MoveFileW(LPCWSTR, LPCWSTR);
1929 	int MulDiv(int, int, int);
1930 	HANDLE OpenEventA(DWORD, BOOL, LPCSTR);
1931 	HANDLE OpenEventW(DWORD, BOOL, LPCWSTR);
1932 	deprecated HFILE OpenFile(LPCSTR, LPOFSTRUCT, UINT);
1933 	HANDLE OpenMutexA(DWORD, BOOL, LPCSTR);
1934 	HANDLE OpenMutexW(DWORD, BOOL, LPCWSTR);
1935 	HANDLE OpenProcess(DWORD, BOOL, DWORD);
1936 	HANDLE OpenSemaphoreA(DWORD, BOOL, LPCSTR);
1937 	HANDLE OpenSemaphoreW(DWORD, BOOL, LPCWSTR);
1938 	void OutputDebugStringA(LPCSTR);
1939 	void OutputDebugStringW(LPCWSTR);
1940 	BOOL PeekNamedPipe(HANDLE, PVOID, DWORD, PDWORD, PDWORD, PDWORD);
1941 	BOOL PulseEvent(HANDLE);
1942 	BOOL PurgeComm(HANDLE, DWORD);
1943 	BOOL QueryPerformanceCounter(PLARGE_INTEGER);
1944 	BOOL QueryPerformanceFrequency(PLARGE_INTEGER);
1945 	DWORD QueueUserAPC(PAPCFUNC, HANDLE, ULONG_PTR);
1946 	void RaiseException(DWORD, DWORD, DWORD, CPtr!(DWORD));
1947 	BOOL ReadFile(HANDLE, PVOID, DWORD, PDWORD, LPOVERLAPPED);
1948 	BOOL ReadFileEx(HANDLE, PVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
1949 	BOOL ReadProcessMemory(HANDLE, PCVOID, PVOID, DWORD, PDWORD);
1950 	BOOL ReleaseMutex(HANDLE);
1951 	BOOL ReleaseSemaphore(HANDLE, LONG, LPLONG);
1952 	BOOL RemoveDirectoryA(LPCSTR);
1953 	BOOL RemoveDirectoryW(LPCWSTR);
1954 /* In MinGW:
1955 #ifdef _WIN32_WCE
1956 extern BOOL ResetEvent(HANDLE);
1957 #else
1958 WINBASEAPI BOOL WINAPI ResetEvent(HANDLE);
1959 #endif
1960 */
1961 	BOOL ResetEvent(HANDLE);
1962 	DWORD ResumeThread(HANDLE);
1963 	DWORD SearchPathA(LPCSTR, LPCSTR, LPCSTR, DWORD, LPSTR, LPSTR*);
1964 	DWORD SearchPathW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPWSTR, LPWSTR*);
1965 	BOOL SetCommBreak(HANDLE);
1966 	BOOL SetCommConfig(HANDLE, LPCOMMCONFIG, DWORD);
1967 	BOOL SetCommMask(HANDLE, DWORD);
1968 	BOOL SetCommState(HANDLE, LPDCB);
1969 	BOOL SetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
1970 	BOOL SetComputerNameA(LPCSTR);
1971 	BOOL SetComputerNameW(LPCWSTR);
1972 	BOOL SetCurrentDirectoryA(LPCSTR);
1973 	BOOL SetCurrentDirectoryW(LPCWSTR);
1974 	BOOL SetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, DWORD);
1975 	BOOL SetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, DWORD);
1976 	BOOL SetEndOfFile(HANDLE);
1977 	BOOL SetEnvironmentVariableA(LPCSTR, LPCSTR);
1978 	BOOL SetEnvironmentVariableW(LPCWSTR, LPCWSTR);
1979 	UINT SetErrorMode(UINT);
1980 /* In MinGW:
1981 #ifdef _WIN32_WCE
1982 extern BOOL SetEvent(HANDLE);
1983 #else
1984 WINBASEAPI BOOL WINAPI SetEvent(HANDLE);
1985 #endif
1986 */
1987 	BOOL SetEvent(HANDLE);
1988 	VOID SetFileApisToANSI();
1989 	VOID SetFileApisToOEM();
1990 	BOOL SetFileAttributesA(LPCSTR, DWORD);
1991 	BOOL SetFileAttributesW(LPCWSTR, DWORD);
1992 	DWORD SetFilePointer(HANDLE, LONG, PLONG, DWORD);
1993 	BOOL SetFileTime(HANDLE, CPtr!(FILETIME), CPtr!(FILETIME), CPtr!(FILETIME));
1994 	deprecated UINT SetHandleCount(UINT);
1995 	void SetLastError(DWORD);
1996 	void SetLastErrorEx(DWORD, DWORD);
1997 	BOOL SetLocalTime(CPtr!(SYSTEMTIME));
1998 	BOOL SetMailslotInfo(HANDLE, DWORD);
1999 	BOOL SetNamedPipeHandleState(HANDLE, PDWORD, PDWORD, PDWORD);
2000 	BOOL SetPriorityClass(HANDLE, DWORD);
2001 	BOOL SetStdHandle(DWORD, HANDLE);
2002 	BOOL SetSystemTime(CPtr!(SYSTEMTIME));
2003 	DWORD SetThreadAffinityMask(HANDLE, DWORD);
2004 	BOOL SetThreadContext(HANDLE, CPtr!(CONTEXT));
2005 	BOOL SetThreadPriority(HANDLE, int);
2006 	BOOL SetTimeZoneInformation(CPtr!(TIME_ZONE_INFORMATION));
2007 	LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER);
2008 	BOOL SetupComm(HANDLE, DWORD, DWORD);
2009 	BOOL SetVolumeLabelA(LPCSTR, LPCSTR);
2010 	BOOL SetVolumeLabelW(LPCWSTR, LPCWSTR);
2011 
2012 	DWORD SizeofResource(HINSTANCE, HRSRC);
2013 	void Sleep(DWORD);
2014 	DWORD SleepEx(DWORD, BOOL);
2015 	DWORD SuspendThread(HANDLE);
2016 	BOOL SystemTimeToFileTime(CPtr!(SYSTEMTIME), LPFILETIME);
2017 	BOOL TerminateProcess(HANDLE, UINT);
2018 	BOOL TerminateThread(HANDLE, DWORD);
2019 	DWORD TlsAlloc();
2020 	BOOL TlsFree(DWORD);
2021 	PVOID TlsGetValue(DWORD);
2022 	BOOL TlsSetValue(DWORD, PVOID);
2023 	BOOL TransactNamedPipe(HANDLE, PVOID, DWORD, PVOID, DWORD, PDWORD, LPOVERLAPPED);
2024 	BOOL TransmitCommChar(HANDLE, char);
2025 	LONG UnhandledExceptionFilter(LPEXCEPTION_POINTERS);
2026 	BOOL UnlockFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
2027 	BOOL WaitCommEvent(HANDLE, PDWORD, LPOVERLAPPED);
2028 	BOOL WaitForDebugEvent(LPDEBUG_EVENT, DWORD);
2029 	DWORD WaitForMultipleObjects(DWORD, CPtr!(HANDLE), BOOL, DWORD);
2030 	DWORD WaitForMultipleObjectsEx(DWORD, CPtr!(HANDLE), BOOL, DWORD, BOOL);
2031 	DWORD WaitForSingleObject(HANDLE, DWORD);
2032 	DWORD WaitForSingleObjectEx(HANDLE, DWORD, BOOL);
2033 	BOOL WaitNamedPipeA(LPCSTR, DWORD);
2034 	BOOL WaitNamedPipeW(LPCWSTR, DWORD);
2035 	// undocumented on MSDN
2036 	BOOL WinLoadTrustProvider(GUID*);
2037 	BOOL WriteFile(HANDLE, PCVOID, DWORD, PDWORD, LPOVERLAPPED);
2038 	BOOL WriteFileEx(HANDLE, PCVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
2039 	BOOL WritePrivateProfileSectionA(LPCSTR, LPCSTR, LPCSTR);
2040 	BOOL WritePrivateProfileSectionW(LPCWSTR, LPCWSTR, LPCWSTR);
2041 	BOOL WritePrivateProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPCSTR);
2042 	BOOL WritePrivateProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR);
2043 	BOOL WritePrivateProfileStructA(LPCSTR, LPCSTR, LPVOID, UINT, LPCSTR);
2044 	BOOL WritePrivateProfileStructW(LPCWSTR, LPCWSTR, LPVOID, UINT, LPCWSTR);
2045 	BOOL WriteProcessMemory(HANDLE, LPVOID, LPCVOID, SIZE_T, SIZE_T*);
2046 	BOOL WriteProfileSectionA(LPCSTR, LPCSTR);
2047 	BOOL WriteProfileSectionW(LPCWSTR, LPCWSTR);
2048 	BOOL WriteProfileStringA(LPCSTR, LPCSTR, LPCSTR);
2049 	BOOL WriteProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR);
2050 
2051 	/*	Memory allocation functions.
2052 	 *	MSDN documents these erroneously as Win2000+; thus it is uncertain what
2053 	 *	version compatibility they really have.
2054 	 */
2055 	HGLOBAL GlobalAlloc(UINT, DWORD);
2056 	HGLOBAL GlobalDiscard(HGLOBAL);
2057 	HGLOBAL GlobalFree(HGLOBAL);
2058 	HGLOBAL GlobalHandle(PCVOID);
2059 	LPVOID GlobalLock(HGLOBAL);
2060 	VOID GlobalMemoryStatus(LPMEMORYSTATUS);
2061 	HGLOBAL GlobalReAlloc(HGLOBAL, DWORD, UINT);
2062 	DWORD GlobalSize(HGLOBAL);
2063 	BOOL GlobalUnlock(HGLOBAL);
2064 	PVOID HeapAlloc(HANDLE, DWORD, DWORD);
2065 	SIZE_T HeapCompact(HANDLE, DWORD);
2066 	HANDLE HeapCreate(DWORD, DWORD, DWORD);
2067 	BOOL HeapDestroy(HANDLE);
2068 	BOOL HeapFree(HANDLE, DWORD, PVOID);
2069 	BOOL HeapLock(HANDLE);
2070 	PVOID HeapReAlloc(HANDLE, DWORD, PVOID, DWORD);
2071 	DWORD HeapSize(HANDLE, DWORD, PCVOID);
2072 	BOOL HeapUnlock(HANDLE);
2073 	BOOL HeapValidate(HANDLE, DWORD, PCVOID);
2074 	BOOL HeapWalk(HANDLE, LPPROCESS_HEAP_ENTRY);
2075 	HLOCAL LocalAlloc(UINT, SIZE_T);
2076 	HLOCAL LocalDiscard(HLOCAL);
2077 	HLOCAL LocalFree(HLOCAL);
2078 	HLOCAL LocalHandle(LPCVOID);
2079 	PVOID LocalLock(HLOCAL);
2080 	HLOCAL LocalReAlloc(HLOCAL, SIZE_T, UINT);
2081 	UINT LocalSize(HLOCAL);
2082 	BOOL LocalUnlock(HLOCAL);
2083 	PVOID VirtualAlloc(PVOID, DWORD, DWORD, DWORD);
2084 	PVOID VirtualAllocEx(HANDLE, PVOID, DWORD, DWORD, DWORD);
2085 	BOOL VirtualFree(PVOID, DWORD, DWORD);
2086 	BOOL VirtualFreeEx(HANDLE, PVOID, DWORD, DWORD);
2087 	BOOL VirtualLock(PVOID, DWORD);
2088 	BOOL VirtualProtect(PVOID, DWORD, DWORD, PDWORD);
2089 	BOOL VirtualProtectEx(HANDLE, PVOID, DWORD, DWORD, PDWORD);
2090 	DWORD VirtualQuery(LPCVOID, PMEMORY_BASIC_INFORMATION, DWORD);
2091 	DWORD VirtualQueryEx(HANDLE, LPCVOID, PMEMORY_BASIC_INFORMATION, DWORD);
2092 	BOOL VirtualUnlock(PVOID, DWORD);
2093 
2094 	static if (_WIN32_WINDOWS >= 0x600) {
2095 		BOOL CancelIoEx(HANDLE, LPOVERLAPPED);
2096 	}
2097 
2098 	static if (_WIN32_WINDOWS >= 0x410) {
2099 		BOOL CancelIo(HANDLE);
2100 		BOOL CancelWaitableTimer(HANDLE);
2101 		PVOID ConvertThreadToFiber(PVOID);
2102 		LPVOID CreateFiber(SIZE_T, LPFIBER_START_ROUTINE, LPVOID);
2103 		HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
2104 		HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
2105 		void DeleteFiber(PVOID);
2106 		BOOL GetFileAttributesExA(LPCSTR, GET_FILEEX_INFO_LEVELS, PVOID);
2107 		BOOL GetFileAttributesExW(LPCWSTR, GET_FILEEX_INFO_LEVELS, PVOID);
2108 		DWORD GetLongPathNameA(LPCSTR, LPSTR, DWORD);
2109 		DWORD GetLongPathNameW(LPCWSTR, LPWSTR, DWORD);
2110 		BOOL InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION, DWORD);
2111 		BOOL IsDebuggerPresent();
2112 		HANDLE OpenWaitableTimerA(DWORD, BOOL, LPCSTR);
2113 		HANDLE OpenWaitableTimerW(DWORD, BOOL, LPCWSTR);
2114 		DWORD QueryDosDeviceA(LPCSTR, LPSTR, DWORD);
2115 		DWORD QueryDosDeviceW(LPCWSTR, LPWSTR, DWORD);
2116 		BOOL SetWaitableTimer(HANDLE, CPtr!(LARGE_INTEGER), LONG, PTIMERAPCROUTINE, PVOID, BOOL);
2117 		void SwitchToFiber(PVOID);
2118 	}
2119 
2120 	static if (WINVER >= 0x500) {
2121 		HANDLE OpenThread(DWORD, BOOL, DWORD);
2122 	}
2123 
2124 	static if (_WIN32_WINNT_ONLY) {
2125 		BOOL AccessCheck(PSECURITY_DESCRIPTOR, HANDLE, DWORD, PGENERIC_MAPPING, PPRIVILEGE_SET, PDWORD, PDWORD, PBOOL);
2126 		BOOL AccessCheckAndAuditAlarmA(LPCSTR, LPVOID, LPSTR, LPSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, PDWORD, PBOOL, PBOOL);
2127 		BOOL AccessCheckAndAuditAlarmW(LPCWSTR, LPVOID, LPWSTR, LPWSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, PDWORD, PBOOL, PBOOL);
2128 		BOOL AddAccessAllowedAce(PACL, DWORD, DWORD, PSID);
2129 		BOOL AddAccessDeniedAce(PACL, DWORD, DWORD, PSID);
2130 		BOOL AddAce(PACL, DWORD, DWORD, PVOID, DWORD);
2131 		BOOL AddAuditAccessAce(PACL, DWORD, DWORD, PSID, BOOL, BOOL);
2132 		BOOL AdjustTokenGroups(HANDLE, BOOL, PTOKEN_GROUPS, DWORD, PTOKEN_GROUPS, PDWORD);
2133 		BOOL AdjustTokenPrivileges(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
2134 		BOOL AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
2135 		BOOL AllocateLocallyUniqueId(PLUID);
2136 		BOOL AreAllAccessesGranted(DWORD, DWORD);
2137 		BOOL AreAnyAccessesGranted(DWORD, DWORD);
2138 		BOOL BackupEventLogA(HANDLE, LPCSTR);
2139 		BOOL BackupEventLogW(HANDLE, LPCWSTR);
2140 		BOOL BackupRead(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*);
2141 		BOOL BackupSeek(HANDLE, DWORD, DWORD, LPDWORD, LPDWORD, LPVOID*);
2142 		BOOL BackupWrite(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*);
2143 		BOOL ClearEventLogA(HANDLE, LPCSTR);
2144 		BOOL ClearEventLogW(HANDLE, LPCWSTR);
2145 		BOOL CloseEventLog(HANDLE);
2146 		BOOL ConnectNamedPipe(HANDLE, LPOVERLAPPED);
2147 		BOOL CopySid(DWORD, PSID, PSID);
2148 		HANDLE CreateNamedPipeA(LPCSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
2149 		HANDLE CreateNamedPipeW(LPCWSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
2150 		BOOL CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR*, BOOL, HANDLE, PGENERIC_MAPPING);
2151 		BOOL CreateProcessAsUserA(HANDLE, LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
2152 		BOOL CreateProcessAsUserW(HANDLE, LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
2153 		HANDLE CreateRemoteThread(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD);
2154 		DWORD CreateTapePartition(HANDLE, DWORD, DWORD, DWORD);
2155 		BOOL DefineDosDeviceA(DWORD, LPCSTR, LPCSTR);
2156 		BOOL DefineDosDeviceW(DWORD, LPCWSTR, LPCWSTR);
2157 		BOOL DeleteAce(PACL, DWORD);
2158 		BOOL DeregisterEventSource(HANDLE);
2159 		BOOL DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR*);
2160 		BOOL DeviceIoControl(HANDLE, DWORD, PVOID, DWORD, PVOID, DWORD, PDWORD, POVERLAPPED);
2161 		BOOL DisconnectNamedPipe(HANDLE);
2162 		BOOL DuplicateToken(HANDLE, SECURITY_IMPERSONATION_LEVEL, PHANDLE);
2163 		BOOL DuplicateTokenEx(HANDLE, DWORD, LPSECURITY_ATTRIBUTES, SECURITY_IMPERSONATION_LEVEL, TOKEN_TYPE, PHANDLE);
2164 		BOOL EqualPrefixSid(PSID, PSID);
2165 		BOOL EqualSid(PSID, PSID);
2166 		DWORD EraseTape(HANDLE, DWORD, BOOL);
2167 		HANDLE FindFirstFileExA(LPCSTR, FINDEX_INFO_LEVELS, PVOID, FINDEX_SEARCH_OPS, PVOID, DWORD);
2168 		HANDLE FindFirstFileExW(LPCWSTR, FINDEX_INFO_LEVELS, PVOID, FINDEX_SEARCH_OPS, PVOID, DWORD);
2169 		BOOL FindFirstFreeAce(PACL, PVOID*);
2170 		PVOID FreeSid(PSID);
2171 		BOOL GetAce(PACL, DWORD, LPVOID*);
2172 		BOOL GetAclInformation(PACL, PVOID, DWORD, ACL_INFORMATION_CLASS);
2173 		BOOL GetBinaryTypeA(LPCSTR, PDWORD);
2174 		BOOL GetBinaryTypeW(LPCWSTR, PDWORD);
2175 		DWORD GetCompressedFileSizeA(LPCSTR, PDWORD);
2176 		DWORD GetCompressedFileSizeW(LPCWSTR, PDWORD);
2177 		BOOL GetCurrentHwProfileA(LPHW_PROFILE_INFOA);
2178 		BOOL GetCurrentHwProfileW(LPHW_PROFILE_INFOW);
2179 		BOOL GetFileSecurityA(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2180 		BOOL GetFileSecurityW(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2181 		BOOL GetHandleInformation(HANDLE, PDWORD);
2182 		BOOL GetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2183 		DWORD GetLengthSid(PSID);
2184 		BOOL GetNumberOfEventLogRecords(HANDLE, PDWORD);
2185 		BOOL GetOldestEventLogRecord(HANDLE, PDWORD);
2186 		BOOL GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2187 		BOOL GetProcessPriorityBoost(HANDLE, PBOOL);
2188 		BOOL GetProcessShutdownParameters(PDWORD, PDWORD);
2189 		BOOL GetProcessTimes(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
2190 		HWINSTA GetProcessWindowStation();
2191 		BOOL GetProcessWorkingSetSize(HANDLE, PSIZE_T, PSIZE_T);
2192 		BOOL GetQueuedCompletionStatus(HANDLE, PDWORD, PULONG_PTR, LPOVERLAPPED*, DWORD);
2193 		BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR_CONTROL, PDWORD);
2194 		BOOL GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, LPBOOL, PACL*, LPBOOL);
2195 		BOOL GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID*, LPBOOL);
2196 		DWORD GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR);
2197 		BOOL GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID*, LPBOOL);
2198 		BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, LPBOOL, PACL*, LPBOOL);
2199 		PSID_IDENTIFIER_AUTHORITY GetSidIdentifierAuthority(PSID);
2200 		DWORD GetSidLengthRequired(UCHAR);
2201 		PDWORD GetSidSubAuthority(PSID, DWORD);
2202 		PUCHAR GetSidSubAuthorityCount(PSID);
2203 		DWORD GetTapeParameters(HANDLE, DWORD, PDWORD, PVOID);
2204 		DWORD GetTapePosition(HANDLE, DWORD, PDWORD, PDWORD, PDWORD);
2205 		DWORD GetTapeStatus(HANDLE);
2206 		BOOL GetThreadPriorityBoost(HANDLE, PBOOL);
2207 		BOOL GetThreadTimes(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
2208 		BOOL GetTokenInformation(HANDLE, TOKEN_INFORMATION_CLASS, PVOID, DWORD, PDWORD);
2209 		BOOL ImpersonateLoggedOnUser(HANDLE);
2210 		BOOL ImpersonateNamedPipeClient(HANDLE);
2211 		BOOL ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL);
2212 		BOOL InitializeAcl(PACL, DWORD, DWORD);
2213 		DWORD SetCriticalSectionSpinCount(LPCRITICAL_SECTION, DWORD);
2214 		BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR, DWORD);
2215 		BOOL InitializeSid(PSID, PSID_IDENTIFIER_AUTHORITY, BYTE);
2216 		BOOL IsProcessorFeaturePresent(DWORD);
2217 		BOOL IsTextUnicode(PCVOID, int, LPINT);
2218 		BOOL IsValidAcl(PACL);
2219 		BOOL IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR);
2220 		BOOL IsValidSid(PSID);
2221 		BOOL LockFileEx(HANDLE, DWORD, DWORD, DWORD, DWORD, LPOVERLAPPED);
2222 		BOOL LogonUserA(LPSTR, LPSTR, LPSTR, DWORD, DWORD, PHANDLE);
2223 		BOOL LogonUserW(LPWSTR, LPWSTR, LPWSTR, DWORD, DWORD, PHANDLE);
2224 		BOOL LookupAccountNameA(LPCSTR, LPCSTR, PSID, PDWORD, LPSTR, PDWORD, PSID_NAME_USE);
2225 		BOOL LookupAccountNameW(LPCWSTR, LPCWSTR, PSID, PDWORD, LPWSTR, PDWORD, PSID_NAME_USE);
2226 		BOOL LookupAccountSidA(LPCSTR, PSID, LPSTR, PDWORD, LPSTR, PDWORD, PSID_NAME_USE);
2227 		BOOL LookupAccountSidW(LPCWSTR, PSID, LPWSTR, PDWORD, LPWSTR, PDWORD, PSID_NAME_USE);
2228 		BOOL LookupPrivilegeDisplayNameA(LPCSTR, LPCSTR, LPSTR, PDWORD, PDWORD);
2229 		BOOL LookupPrivilegeDisplayNameW(LPCWSTR, LPCWSTR, LPWSTR, PDWORD, PDWORD);
2230 		BOOL LookupPrivilegeNameA(LPCSTR, PLUID, LPSTR, PDWORD);
2231 		BOOL LookupPrivilegeNameW(LPCWSTR, PLUID, LPWSTR, PDWORD);
2232 		BOOL LookupPrivilegeValueA(LPCSTR, LPCSTR, PLUID);
2233 		BOOL LookupPrivilegeValueW(LPCWSTR, LPCWSTR, PLUID);
2234 		BOOL MakeAbsoluteSD(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PDWORD, PACL, PDWORD, PACL, PDWORD, PSID, PDWORD, PSID, PDWORD);
2235 		BOOL MakeSelfRelativeSD(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PDWORD);
2236 		VOID MapGenericMask(PDWORD, PGENERIC_MAPPING);
2237 		BOOL MoveFileExA(LPCSTR, LPCSTR, DWORD);
2238 		BOOL MoveFileExW(LPCWSTR, LPCWSTR, DWORD);
2239 		BOOL NotifyChangeEventLog(HANDLE, HANDLE);
2240 		BOOL ObjectCloseAuditAlarmA(LPCSTR, PVOID, BOOL);
2241 		BOOL ObjectCloseAuditAlarmW(LPCWSTR, PVOID, BOOL);
2242 		BOOL ObjectDeleteAuditAlarmA(LPCSTR, PVOID, BOOL);
2243 		BOOL ObjectDeleteAuditAlarmW(LPCWSTR, PVOID, BOOL);
2244 		BOOL ObjectOpenAuditAlarmA(LPCSTR, PVOID, LPSTR, LPSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, PBOOL);
2245 		BOOL ObjectOpenAuditAlarmW(LPCWSTR, PVOID, LPWSTR, LPWSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, PBOOL);
2246 		BOOL ObjectPrivilegeAuditAlarmA(LPCSTR, PVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
2247 		BOOL ObjectPrivilegeAuditAlarmW(LPCWSTR, PVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
2248 		HANDLE OpenBackupEventLogA(LPCSTR, LPCSTR);
2249 		HANDLE OpenBackupEventLogW(LPCWSTR, LPCWSTR);
2250 		HANDLE OpenEventLogA(LPCSTR, LPCSTR);
2251 		HANDLE OpenEventLogW(LPCWSTR, LPCWSTR);
2252 		BOOL OpenProcessToken(HANDLE, DWORD, PHANDLE);
2253 		BOOL OpenThreadToken(HANDLE, DWORD, BOOL, PHANDLE);
2254 		BOOL PostQueuedCompletionStatus(HANDLE, DWORD, ULONG_PTR, LPOVERLAPPED);
2255 		DWORD PrepareTape(HANDLE, DWORD, BOOL);
2256 		BOOL PrivilegeCheck(HANDLE, PPRIVILEGE_SET, PBOOL);
2257 		BOOL PrivilegedServiceAuditAlarmA(LPCSTR, LPCSTR, HANDLE, PPRIVILEGE_SET, BOOL);
2258 		BOOL PrivilegedServiceAuditAlarmW(LPCWSTR, LPCWSTR, HANDLE, PPRIVILEGE_SET, BOOL);
2259 		BOOL ReadDirectoryChangesW(HANDLE, PVOID, DWORD, BOOL, DWORD, PDWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
2260 		BOOL ReadEventLogA(HANDLE, DWORD, DWORD, PVOID, DWORD, DWORD*, DWORD*);
2261 		BOOL ReadEventLogW(HANDLE, DWORD, DWORD, PVOID, DWORD, DWORD*, DWORD*);
2262 		BOOL ReadFileScatter(HANDLE, FILE_SEGMENT_ELEMENT*, DWORD, LPDWORD, LPOVERLAPPED);
2263 		HANDLE RegisterEventSourceA (LPCSTR, LPCSTR);
2264 		HANDLE RegisterEventSourceW(LPCWSTR, LPCWSTR);
2265 		BOOL ReportEventA(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCSTR*, PVOID);
2266 		BOOL ReportEventW(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCWSTR*, PVOID);
2267 		BOOL RevertToSelf();
2268 		BOOL SetAclInformation(PACL, PVOID, DWORD, ACL_INFORMATION_CLASS);
2269 		BOOL SetFileSecurityA(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2270 		BOOL SetFileSecurityW(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2271 		BOOL SetHandleInformation(HANDLE, DWORD, DWORD);
2272 		BOOL SetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2273 		BOOL SetPrivateObjectSecurity(SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR* , PGENERIC_MAPPING, HANDLE);
2274 		BOOL SetProcessAffinityMask(HANDLE, DWORD);
2275 		BOOL SetProcessPriorityBoost(HANDLE, BOOL);
2276 		BOOL SetProcessShutdownParameters(DWORD, DWORD);
2277 		BOOL SetProcessWorkingSetSize(HANDLE, SIZE_T, SIZE_T);
2278 		BOOL SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
2279 		BOOL SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID, BOOL);
2280 		BOOL SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID, BOOL);
2281 		BOOL SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
2282 		BOOL SetSystemTimeAdjustment(DWORD, BOOL);
2283 		DWORD SetTapeParameters(HANDLE, DWORD, PVOID);
2284 		DWORD SetTapePosition(HANDLE, DWORD, DWORD, DWORD, DWORD, BOOL);
2285 		BOOL SetThreadPriorityBoost(HANDLE, BOOL);
2286 		BOOL SetThreadToken(PHANDLE, HANDLE);
2287 		BOOL SetTokenInformation(HANDLE, TOKEN_INFORMATION_CLASS, PVOID, DWORD);
2288 		DWORD SignalObjectAndWait(HANDLE, HANDLE, DWORD, BOOL);
2289 		BOOL SwitchToThread();
2290 		BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
2291 		BOOL TryEnterCriticalSection(LPCRITICAL_SECTION);
2292 		BOOL UnlockFileEx(HANDLE, DWORD, DWORD, DWORD, LPOVERLAPPED);
2293 		BOOL UpdateResourceA(HANDLE, LPCSTR, LPCSTR, WORD, PVOID, DWORD);
2294 		BOOL UpdateResourceW(HANDLE, LPCWSTR, LPCWSTR, WORD, PVOID, DWORD);
2295 		BOOL WriteFileGather(HANDLE, FILE_SEGMENT_ELEMENT*, DWORD, LPDWORD, LPOVERLAPPED);
2296 		DWORD WriteTapemark(HANDLE, DWORD, DWORD, BOOL);
2297 
2298 		static if (_WIN32_WINNT >= 0x500) {
2299 			BOOL AddAccessAllowedAceEx(PACL, DWORD, DWORD, DWORD, PSID);
2300 			BOOL AddAccessDeniedAceEx(PACL, DWORD, DWORD, DWORD, PSID);
2301 			PVOID AddVectoredExceptionHandler(ULONG, PVECTORED_EXCEPTION_HANDLER);
2302 			BOOL AllocateUserPhysicalPages(HANDLE, PULONG_PTR, PULONG_PTR);
2303 			BOOL AssignProcessToJobObject(HANDLE, HANDLE);
2304 			BOOL ChangeTimerQueueTimer(HANDLE,HANDLE,ULONG,ULONG);
2305 			LPVOID CreateFiberEx(SIZE_T, SIZE_T, DWORD, LPFIBER_START_ROUTINE, LPVOID);
2306 			HANDLE CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCSTR);
2307 			HANDLE CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCWSTR);
2308 			BOOL CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
2309 			BOOL CreateHardLinkW(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
2310 			HANDLE CreateJobObjectA(LPSECURITY_ATTRIBUTES, LPCSTR);
2311 			HANDLE CreateJobObjectW(LPSECURITY_ATTRIBUTES, LPCWSTR);
2312 			BOOL CreateProcessWithLogonW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPCWSTR, LPWSTR, DWORD, LPVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
2313 			HANDLE CreateTimerQueue();
2314 			BOOL CreateTimerQueueTimer(PHANDLE, HANDLE, WAITORTIMERCALLBACK, PVOID, DWORD, DWORD, ULONG);
2315 			BOOL DeleteTimerQueue(HANDLE);
2316 			BOOL DeleteTimerQueueEx(HANDLE, HANDLE);
2317 			BOOL DeleteTimerQueueTimer(HANDLE, HANDLE, HANDLE);
2318 			BOOL DeleteVolumeMountPointA(LPCSTR);
2319 			BOOL DeleteVolumeMountPointW(LPCWSTR);
2320 			BOOL DnsHostnameToComputerNameA(LPCSTR, LPSTR, LPDWORD);
2321 			BOOL DnsHostnameToComputerNameW(LPCWSTR, LPWSTR, LPDWORD);
2322 			BOOL EncryptFileA(LPCSTR);
2323 			BOOL EncryptFileW(LPCWSTR);
2324 			BOOL FileEncryptionStatusA(LPCSTR, LPDWORD);
2325 			BOOL FileEncryptionStatusW(LPCWSTR, LPDWORD);
2326 			HANDLE FindFirstVolumeA(LPCSTR, DWORD);
2327 			HANDLE FindFirstVolumeMountPointA(LPSTR, LPSTR, DWORD);
2328 			HANDLE FindFirstVolumeMountPointW(LPWSTR, LPWSTR, DWORD);
2329 			HANDLE FindFirstVolumeW(LPCWSTR, DWORD);
2330 			BOOL FindNextVolumeA(HANDLE, LPCSTR, DWORD);
2331 			BOOL FindNextVolumeW(HANDLE, LPWSTR, DWORD);
2332 			BOOL FindNextVolumeMountPointA(HANDLE, LPSTR, DWORD);
2333 			BOOL FindNextVolumeMountPointW(HANDLE, LPWSTR, DWORD);
2334 			BOOL FindVolumeClose(HANDLE);
2335 			BOOL FindVolumeMountPointClose(HANDLE);
2336 			BOOL FlushViewOfFile(PCVOID, DWORD);
2337 			BOOL FreeUserPhysicalPages(HANDLE, PULONG_PTR, PULONG_PTR);
2338 			BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD);
2339 			BOOL GetComputerNameExW(COMPUTER_NAME_FORMAT, LPWSTR, LPDWORD);
2340 			BOOL GetFileSizeEx(HANDLE, PLARGE_INTEGER);
2341 			BOOL GetModuleHandleExA(DWORD, LPCSTR, HMODULE*);
2342 			BOOL GetModuleHandleExW(DWORD, LPCWSTR, HMODULE*);
2343 			HANDLE GetProcessHeap();
2344 			DWORD GetProcessHeaps(DWORD, PHANDLE);
2345 			BOOL GetProcessIoCounters(HANDLE, PIO_COUNTERS);
2346 			BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS);
2347 			UINT GetSystemWindowsDirectoryA(LPSTR, UINT);
2348 			UINT GetSystemWindowsDirectoryW(LPWSTR, UINT);
2349 			BOOL GetVolumeNameForVolumeMountPointA(LPCSTR, LPSTR, DWORD);
2350 			BOOL GetVolumeNameForVolumeMountPointW(LPCWSTR, LPWSTR, DWORD);
2351 			BOOL GetVolumePathNameA(LPCSTR, LPSTR, DWORD);
2352 			BOOL GetVolumePathNameW(LPCWSTR, LPWSTR, DWORD);
2353 			BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX);
2354 			BOOL IsBadCodePtr(FARPROC);
2355 			BOOL IsSystemResumeAutomatic();
2356 			BOOL MapUserPhysicalPages(PVOID, ULONG_PTR, PULONG_PTR);
2357 			BOOL MapUserPhysicalPagesScatter(PVOID*, ULONG_PTR, PULONG_PTR);
2358 			PVOID MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
2359 			PVOID MapViewOfFileEx(HANDLE, DWORD, DWORD, DWORD, DWORD, PVOID);
2360 			HANDLE OpenFileMappingA(DWORD, BOOL, LPCSTR);
2361 			HANDLE OpenFileMappingW(DWORD, BOOL, LPCWSTR);
2362 			BOOL ProcessIdToSessionId(DWORD, DWORD*);
2363 			BOOL QueryInformationJobObject(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
2364 			ULONG RemoveVectoredExceptionHandler(PVOID);
2365 			BOOL ReplaceFileA(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID);
2366 			BOOL ReplaceFileW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID);
2367 			BOOL SetComputerNameExA(COMPUTER_NAME_FORMAT, LPCSTR);
2368 			BOOL SetComputerNameExW(COMPUTER_NAME_FORMAT, LPCWSTR);
2369 			BOOL SetFilePointerEx(HANDLE, LARGE_INTEGER, PLARGE_INTEGER, DWORD);
2370 			BOOL SetInformationJobObject(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD);
2371 			BOOL SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL);
2372 			BOOL SetSystemPowerState(BOOL, BOOL);
2373 			EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE);
2374 			DWORD SetThreadIdealProcessor(HANDLE, DWORD);
2375 			BOOL SetVolumeMountPointA(LPCSTR, LPCSTR);
2376 			BOOL SetVolumeMountPointW(LPCWSTR, LPCWSTR);
2377 			BOOL TerminateJobObject(HANDLE, UINT);
2378 			BOOL UnmapViewOfFile(PVOID);
2379 			BOOL UnregisterWait(HANDLE);
2380 			BOOL UnregisterWaitEx(HANDLE, HANDLE);
2381 			BOOL VerifyVersionInfoA(LPOSVERSIONINFOEXA, DWORD, DWORDLONG);
2382 			BOOL VerifyVersionInfoW(LPOSVERSIONINFOEXW, DWORD, DWORDLONG);
2383 		}
2384 
2385 		static if (_WIN32_WINNT >= 0x501) {
2386 			BOOL ActivateActCtx(HANDLE, ULONG_PTR*);
2387 			void AddRefActCtx(HANDLE);
2388 			BOOL CheckNameLegalDOS8Dot3A(LPCSTR, LPSTR, DWORD, PBOOL, PBOOL);
2389 			BOOL CheckNameLegalDOS8Dot3W(LPCWSTR, LPSTR, DWORD, PBOOL, PBOOL);
2390 			BOOL CheckRemoteDebuggerPresent(HANDLE, PBOOL);
2391 			BOOL ConvertFiberToThread();
2392 			HANDLE CreateActCtxA(PCACTCTXA);
2393 			HANDLE CreateActCtxW(PCACTCTXW);
2394 			HANDLE CreateMemoryResourceNotification(MEMORY_RESOURCE_NOTIFICATION_TYPE);
2395 			BOOL DeactivateActCtx(DWORD, ULONG_PTR);
2396 			BOOL DebugActiveProcessStop(DWORD);
2397 			BOOL DebugBreakProcess(HANDLE);
2398 			BOOL DebugSetProcessKillOnExit(BOOL);
2399 			BOOL FindActCtxSectionGuid(DWORD, CPtr!(GUID), ULONG, CPtr!(GUID),
2400 			  PACTCTX_SECTION_KEYED_DATA);
2401 			BOOL FindActCtxSectionStringA(DWORD, CPtr!(GUID), ULONG, LPCSTR,
2402 			  PACTCTX_SECTION_KEYED_DATA);
2403 			BOOL FindActCtxSectionStringW(DWORD, CPtr!(GUID), ULONG, LPCWSTR,
2404 			  PACTCTX_SECTION_KEYED_DATA);
2405 			BOOL GetCurrentActCtx(HANDLE*);
2406 			VOID GetNativeSystemInfo(LPSYSTEM_INFO);
2407 			BOOL GetProcessHandleCount(HANDLE, PDWORD);
2408 			BOOL GetSystemRegistryQuota(PDWORD, PDWORD);
2409 			BOOL GetSystemTimes(LPFILETIME, LPFILETIME, LPFILETIME);
2410 			UINT GetSystemWow64DirectoryA(LPSTR, UINT);
2411 			UINT GetSystemWow64DirectoryW(LPWSTR, UINT);
2412 			BOOL GetThreadIOPendingFlag(HANDLE, PBOOL);
2413 			BOOL GetVolumePathNamesForVolumeNameA(LPCSTR, LPSTR, DWORD, PDWORD);
2414 			BOOL GetVolumePathNamesForVolumeNameW(LPCWSTR, LPWSTR, DWORD, PDWORD);
2415 			UINT GetWriteWatch(DWORD, PVOID, SIZE_T, PVOID*, PULONG_PTR, PULONG);
2416 			BOOL HeapQueryInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T);
2417 			BOOL HeapSetInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
2418 			BOOL IsProcessInJob(HANDLE, HANDLE, PBOOL);
2419 			BOOL IsWow64Process(HANDLE, PBOOL);
2420 			BOOL QueryActCtxW(DWORD, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T*);
2421 			BOOL QueryMemoryResourceNotification(HANDLE, PBOOL);
2422 			void ReleaseActCtx(HANDLE);
2423 			UINT ResetWriteWatch(LPVOID, SIZE_T);
2424 			BOOL SetFileShortNameA(HANDLE, LPCSTR);
2425 			BOOL SetFileShortNameW(HANDLE, LPCWSTR);
2426 			BOOL SetFileValidData(HANDLE, LONGLONG);
2427 			BOOL ZombifyActCtx(HANDLE);
2428 		}
2429 
2430 		static if (_WIN32_WINNT >= 0x502) {
2431 			DWORD GetFirmwareEnvironmentVariableA(LPCSTR, LPCSTR, PVOID, DWORD);
2432 			DWORD GetFirmwareEnvironmentVariableW(LPCWSTR, LPCWSTR, PVOID, DWORD);
2433 			DWORD GetDllDirectoryA(DWORD, LPSTR);
2434 			DWORD GetDllDirectoryW(DWORD, LPWSTR);
2435 			DWORD GetProcessId(HANDLE);
2436 			HANDLE ReOpenFile(HANDLE, DWORD, DWORD, DWORD);
2437 			BOOL SetDllDirectoryA(LPCSTR);
2438 			BOOL SetDllDirectoryW(LPCWSTR);
2439 			BOOL SetFirmwareEnvironmentVariableA(LPCSTR, LPCSTR, PVOID, DWORD);
2440 			BOOL SetFirmwareEnvironmentVariableW(LPCWSTR, LPCWSTR, PVOID, DWORD);
2441 		}
2442 	}
2443 
2444 	// ???
2445 	static if (_WIN32_WINNT >= 0x510) {
2446 		VOID RestoreLastError(DWORD);
2447 	}
2448 }
2449 
2450 
2451 version (Unicode) {
2452 	alias STARTUPINFOW STARTUPINFO;
2453 	alias WIN32_FIND_DATAW WIN32_FIND_DATA;
2454 	alias ENUMRESLANGPROCW ENUMRESLANGPROC;
2455 	alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
2456 	alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
2457 	alias AddAtomW AddAtom;
2458 	alias BeginUpdateResourceW BeginUpdateResource;
2459 	alias BuildCommDCBW BuildCommDCB;
2460 	alias BuildCommDCBAndTimeoutsW BuildCommDCBAndTimeouts;
2461 	alias CallNamedPipeW CallNamedPipe;
2462 	alias CommConfigDialogW CommConfigDialog;
2463 	alias CopyFileW CopyFile;
2464 	alias CopyFileExW CopyFileEx;
2465 	alias CreateDirectoryW CreateDirectory;
2466 	alias CreateDirectoryExW CreateDirectoryEx;
2467 	alias CreateEventW CreateEvent;
2468 	alias CreateFileW CreateFile;
2469 	alias CreateMailslotW CreateMailslot;
2470 	alias CreateMutexW CreateMutex;
2471 	alias CreateProcessW CreateProcess;
2472 	alias CreateSemaphoreW CreateSemaphore;
2473 	alias DeleteFileW DeleteFile;
2474 	alias EndUpdateResourceW EndUpdateResource;
2475 	alias EnumResourceLanguagesW EnumResourceLanguages;
2476 	alias EnumResourceNamesW EnumResourceNames;
2477 	alias EnumResourceTypesW EnumResourceTypes;
2478 	alias ExpandEnvironmentStringsW ExpandEnvironmentStrings;
2479 	alias FatalAppExitW FatalAppExit;
2480 	alias FindAtomW FindAtom;
2481 	alias FindFirstChangeNotificationW FindFirstChangeNotification;
2482 	alias FindFirstFileW FindFirstFile;
2483 	alias FindNextFileW FindNextFile;
2484 	alias FindResourceW FindResource;
2485 	alias FindResourceExW FindResourceEx;
2486 	alias FormatMessageW FormatMessage;
2487 	alias FreeEnvironmentStringsW FreeEnvironmentStrings;
2488 	alias GetAtomNameW GetAtomName;
2489 	alias GetCommandLineW GetCommandLine;
2490 	alias GetComputerNameW GetComputerName;
2491 	alias GetCurrentDirectoryW GetCurrentDirectory;
2492 	alias GetDefaultCommConfigW GetDefaultCommConfig;
2493 	alias GetDiskFreeSpaceW GetDiskFreeSpace;
2494 	alias GetDiskFreeSpaceExW GetDiskFreeSpaceEx;
2495 	alias GetDriveTypeW GetDriveType;
2496 	alias GetEnvironmentStringsW GetEnvironmentStrings;
2497 	alias GetEnvironmentVariableW GetEnvironmentVariable;
2498 	alias GetFileAttributesW GetFileAttributes;
2499 	alias GetFullPathNameW GetFullPathName;
2500 	alias GetLogicalDriveStringsW GetLogicalDriveStrings;
2501 	alias GetModuleFileNameW GetModuleFileName;
2502 	alias GetModuleHandleW GetModuleHandle;
2503 	alias GetNamedPipeHandleStateW GetNamedPipeHandleState;
2504 	alias GetPrivateProfileIntW GetPrivateProfileInt;
2505 	alias GetPrivateProfileSectionW GetPrivateProfileSection;
2506 	alias GetPrivateProfileSectionNamesW GetPrivateProfileSectionNames;
2507 	alias GetPrivateProfileStringW GetPrivateProfileString;
2508 	alias GetPrivateProfileStructW GetPrivateProfileStruct;
2509 	alias GetProfileIntW GetProfileInt;
2510 	alias GetProfileSectionW GetProfileSection;
2511 	alias GetProfileStringW GetProfileString;
2512 	alias GetShortPathNameW GetShortPathName;
2513 	alias GetStartupInfoW GetStartupInfo;
2514 	alias GetSystemDirectoryW GetSystemDirectory;
2515 	alias GetTempFileNameW GetTempFileName;
2516 	alias GetTempPathW GetTempPath;
2517 	alias GetUserNameW GetUserName;
2518 	alias GetVersionExW GetVersionEx;
2519 	alias GetVolumeInformationW GetVolumeInformation;
2520 	alias GetWindowsDirectoryW GetWindowsDirectory;
2521 	alias GlobalAddAtomW GlobalAddAtom;
2522 	alias GlobalFindAtomW GlobalFindAtom;
2523 	alias GlobalGetAtomNameW GlobalGetAtomName;
2524 	alias IsBadStringPtrW IsBadStringPtr;
2525 	alias LoadLibraryW LoadLibrary;
2526 	alias LoadLibraryExW LoadLibraryEx;
2527 	alias lstrcatW lstrcat;
2528 	alias lstrcmpW lstrcmp;
2529 	alias lstrcmpiW lstrcmpi;
2530 	alias lstrcpyW lstrcpy;
2531 	alias lstrcpynW lstrcpyn;
2532 	alias lstrlenW lstrlen;
2533 	alias MoveFileW MoveFile;
2534 	alias OpenEventW OpenEvent;
2535 	alias OpenMutexW OpenMutex;
2536 	alias OpenSemaphoreW OpenSemaphore;
2537 	alias OutputDebugStringW OutputDebugString;
2538 	alias RemoveDirectoryW RemoveDirectory;
2539 	alias SearchPathW SearchPath;
2540 	alias SetComputerNameW SetComputerName;
2541 	alias SetCurrentDirectoryW SetCurrentDirectory;
2542 	alias SetDefaultCommConfigW SetDefaultCommConfig;
2543 	alias SetEnvironmentVariableW SetEnvironmentVariable;
2544 	alias SetFileAttributesW SetFileAttributes;
2545 	alias SetVolumeLabelW SetVolumeLabel;
2546 	alias WaitNamedPipeW WaitNamedPipe;
2547 	alias WritePrivateProfileSectionW WritePrivateProfileSection;
2548 	alias WritePrivateProfileStringW WritePrivateProfileString;
2549 	alias WritePrivateProfileStructW WritePrivateProfileStruct;
2550 	alias WriteProfileSectionW WriteProfileSection;
2551 	alias WriteProfileStringW WriteProfileString;
2552 
2553 	static if (_WIN32_WINDOWS >= 0x410) {
2554 		alias CreateWaitableTimerW CreateWaitableTimer;
2555 		alias GetFileAttributesExW GetFileAttributesEx;
2556 		alias GetLongPathNameW GetLongPathName;
2557 		alias QueryDosDeviceW QueryDosDevice;
2558 	}
2559 
2560 	static if (_WIN32_WINNT_ONLY) {
2561 		alias HW_PROFILE_INFOW HW_PROFILE_INFO;
2562 		alias AccessCheckAndAuditAlarmW AccessCheckAndAuditAlarm;
2563 		alias BackupEventLogW BackupEventLog;
2564 		alias ClearEventLogW ClearEventLog;
2565 		alias CreateNamedPipeW CreateNamedPipe;
2566 		alias CreateProcessAsUserW CreateProcessAsUser;
2567 		alias DefineDosDeviceW DefineDosDevice;
2568 		alias FindFirstFileExW FindFirstFileEx;
2569 		alias GetBinaryTypeW GetBinaryType;
2570 		alias GetCompressedFileSizeW GetCompressedFileSize;
2571 		alias GetFileSecurityW GetFileSecurity;
2572 		alias LogonUserW LogonUser;
2573 		alias LookupAccountNameW LookupAccountName;
2574 		alias LookupAccountSidW LookupAccountSid;
2575 		alias LookupPrivilegeDisplayNameW LookupPrivilegeDisplayName;
2576 		alias LookupPrivilegeNameW LookupPrivilegeName;
2577 		alias LookupPrivilegeValueW LookupPrivilegeValue;
2578 		alias MoveFileExW MoveFileEx;
2579 		alias ObjectCloseAuditAlarmW ObjectCloseAuditAlarm;
2580 		alias ObjectDeleteAuditAlarmW ObjectDeleteAuditAlarm;
2581 		alias ObjectOpenAuditAlarmW ObjectOpenAuditAlarm;
2582 		alias ObjectPrivilegeAuditAlarmW ObjectPrivilegeAuditAlarm;
2583 		alias OpenBackupEventLogW OpenBackupEventLog;
2584 		alias OpenEventLogW OpenEventLog;
2585 		alias PrivilegedServiceAuditAlarmW PrivilegedServiceAuditAlarm;
2586 		alias ReadEventLogW ReadEventLog;
2587 		alias RegisterEventSourceW RegisterEventSource;
2588 		alias ReportEventW ReportEvent;
2589 		alias SetFileSecurityW SetFileSecurity;
2590 		alias UpdateResourceW UpdateResource;
2591 
2592 		static if (_WIN32_WINNT >= 0x500) {
2593 			alias CreateFileMappingW CreateFileMapping;
2594 			alias CreateHardLinkW CreateHardLink;
2595 			alias CreateJobObjectW CreateJobObject;
2596 			alias DeleteVolumeMountPointW DeleteVolumeMountPoint;
2597 			alias DnsHostnameToComputerNameW DnsHostnameToComputerName;
2598 			alias EncryptFileW EncryptFile;
2599 			alias FileEncryptionStatusW FileEncryptionStatus;
2600 			alias FindFirstVolumeW FindFirstVolume;
2601 			alias FindFirstVolumeMountPointW FindFirstVolumeMountPoint;
2602 			alias FindNextVolumeW FindNextVolume;
2603 			alias FindNextVolumeMountPointW FindNextVolumeMountPoint;
2604 			alias GetModuleHandleExW GetModuleHandleEx;
2605 			alias GetSystemWindowsDirectoryW GetSystemWindowsDirectory;
2606 			alias GetVolumeNameForVolumeMountPointW GetVolumeNameForVolumeMountPoint;
2607 			alias GetVolumePathNameW GetVolumePathName;
2608 			alias OpenFileMappingW OpenFileMapping;
2609 			alias ReplaceFileW ReplaceFile;
2610 			alias SetVolumeMountPointW SetVolumeMountPoint;
2611 			alias VerifyVersionInfoW VerifyVersionInfo;
2612 		}
2613 
2614 		static if (_WIN32_WINNT >= 0x501) {
2615 			alias ACTCTXW ACTCTX;
2616 			alias CheckNameLegalDOS8Dot3W CheckNameLegalDOS8Dot3;
2617 			alias CreateActCtxW CreateActCtx;
2618 			alias FindActCtxSectionStringW FindActCtxSectionString;
2619 			alias GetSystemWow64DirectoryW GetSystemWow64Directory;
2620 			alias GetVolumePathNamesForVolumeNameW GetVolumePathNamesForVolumeName;
2621 			alias SetFileShortNameW SetFileShortName;
2622 		}
2623 
2624 		static if (_WIN32_WINNT >= 0x502) {
2625 			alias SetFirmwareEnvironmentVariableW SetFirmwareEnvironmentVariable;
2626 			alias SetDllDirectoryW SetDllDirectory;
2627 			alias GetDllDirectoryW GetDllDirectory;
2628 		}
2629 	}
2630 
2631 } else {
2632 	alias STARTUPINFOA STARTUPINFO;
2633 	alias WIN32_FIND_DATAA WIN32_FIND_DATA;
2634 	alias ENUMRESLANGPROCW ENUMRESLANGPROC;
2635 	alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
2636 	alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
2637 	alias AddAtomA AddAtom;
2638 	alias BeginUpdateResourceA BeginUpdateResource;
2639 	alias BuildCommDCBA BuildCommDCB;
2640 	alias BuildCommDCBAndTimeoutsA BuildCommDCBAndTimeouts;
2641 	alias CallNamedPipeA CallNamedPipe;
2642 	alias CommConfigDialogA CommConfigDialog;
2643 	alias CopyFileA CopyFile;
2644 	alias CopyFileExA CopyFileEx;
2645 	alias CreateDirectoryA CreateDirectory;
2646 	alias CreateDirectoryExA CreateDirectoryEx;
2647 	alias CreateEventA CreateEvent;
2648 	alias CreateFileA CreateFile;
2649 	alias CreateMailslotA CreateMailslot;
2650 	alias CreateMutexA CreateMutex;
2651 	alias CreateProcessA CreateProcess;
2652 	alias CreateSemaphoreA CreateSemaphore;
2653 	alias DeleteFileA DeleteFile;
2654 	alias EndUpdateResourceA EndUpdateResource;
2655 	alias EnumResourceLanguagesA EnumResourceLanguages;
2656 	alias EnumResourceNamesA EnumResourceNames;
2657 	alias EnumResourceTypesA EnumResourceTypes;
2658 	alias ExpandEnvironmentStringsA ExpandEnvironmentStrings;
2659 	alias FatalAppExitA FatalAppExit;
2660 	alias FindAtomA FindAtom;
2661 	alias FindFirstChangeNotificationA FindFirstChangeNotification;
2662 	alias FindFirstFileA FindFirstFile;
2663 	alias FindNextFileA FindNextFile;
2664 	alias FindResourceA FindResource;
2665 	alias FindResourceExA FindResourceEx;
2666 	alias FormatMessageA FormatMessage;
2667 	alias FreeEnvironmentStringsA FreeEnvironmentStrings;
2668 	alias GetAtomNameA GetAtomName;
2669 	alias GetCommandLineA GetCommandLine;
2670 	alias GetComputerNameA GetComputerName;
2671 	alias GetCurrentDirectoryA GetCurrentDirectory;
2672 	alias GetDefaultCommConfigA GetDefaultCommConfig;
2673 	alias GetDiskFreeSpaceA GetDiskFreeSpace;
2674 	alias GetDiskFreeSpaceExA GetDiskFreeSpaceEx;
2675 	alias GetDriveTypeA GetDriveType;
2676 	alias GetEnvironmentVariableA GetEnvironmentVariable;
2677 	alias GetFileAttributesA GetFileAttributes;
2678 	alias GetFullPathNameA GetFullPathName;
2679 	alias GetLogicalDriveStringsA GetLogicalDriveStrings;
2680 	alias GetNamedPipeHandleStateA GetNamedPipeHandleState;
2681 	alias GetModuleHandleA GetModuleHandle;
2682 	alias GetModuleFileNameA GetModuleFileName;
2683 	alias GetPrivateProfileIntA GetPrivateProfileInt;
2684 	alias GetPrivateProfileSectionA GetPrivateProfileSection;
2685 	alias GetPrivateProfileSectionNamesA GetPrivateProfileSectionNames;
2686 	alias GetPrivateProfileStringA GetPrivateProfileString;
2687 	alias GetPrivateProfileStructA GetPrivateProfileStruct;
2688 	alias GetProfileIntA GetProfileInt;
2689 	alias GetProfileSectionA GetProfileSection;
2690 	alias GetProfileStringA GetProfileString;
2691 	alias GetShortPathNameA GetShortPathName;
2692 	alias GetStartupInfoA GetStartupInfo;
2693 	alias GetSystemDirectoryA GetSystemDirectory;
2694 	alias GetTempFileNameA GetTempFileName;
2695 	alias GetTempPathA GetTempPath;
2696 	alias GetUserNameA GetUserName;
2697 	alias GetVersionExA GetVersionEx;
2698 	alias GetVolumeInformationA GetVolumeInformation;
2699 	alias GetWindowsDirectoryA GetWindowsDirectory;
2700 	alias GlobalAddAtomA GlobalAddAtom;
2701 	alias GlobalFindAtomA GlobalFindAtom;
2702 	alias GlobalGetAtomNameA GlobalGetAtomName;
2703 	alias IsBadStringPtrA IsBadStringPtr;
2704 	alias LoadLibraryA LoadLibrary;
2705 	alias LoadLibraryExA LoadLibraryEx;
2706 	alias lstrcatA lstrcat;
2707 	alias lstrcmpA lstrcmp;
2708 	alias lstrcmpiA lstrcmpi;
2709 	alias lstrcpyA lstrcpy;
2710 	alias lstrcpynA lstrcpyn;
2711 	alias lstrlenA lstrlen;
2712 	alias MoveFileA MoveFile;
2713 	alias OpenEventA OpenEvent;
2714 	alias OpenMutexA OpenMutex;
2715 	alias OpenSemaphoreA OpenSemaphore;
2716 	alias OutputDebugStringA OutputDebugString;
2717 	alias RemoveDirectoryA RemoveDirectory;
2718 	alias SearchPathA SearchPath;
2719 	alias SetComputerNameA SetComputerName;
2720 	alias SetCurrentDirectoryA SetCurrentDirectory;
2721 	alias SetDefaultCommConfigA SetDefaultCommConfig;
2722 	alias SetEnvironmentVariableA SetEnvironmentVariable;
2723 	alias SetFileAttributesA SetFileAttributes;
2724 	alias SetVolumeLabelA SetVolumeLabel;
2725 	alias WaitNamedPipeA WaitNamedPipe;
2726 	alias WritePrivateProfileSectionA WritePrivateProfileSection;
2727 	alias WritePrivateProfileStringA WritePrivateProfileString;
2728 	alias WritePrivateProfileStructA WritePrivateProfileStruct;
2729 	alias WriteProfileSectionA WriteProfileSection;
2730 	alias WriteProfileStringA WriteProfileString;
2731 
2732 	static if (_WIN32_WINDOWS >= 0x410) {
2733 		alias CreateWaitableTimerA CreateWaitableTimer;
2734 		alias GetFileAttributesExA GetFileAttributesEx;
2735 		alias GetLongPathNameA GetLongPathName;
2736 		alias QueryDosDeviceA QueryDosDevice;
2737 	}
2738 
2739 	static if (_WIN32_WINNT_ONLY) {
2740 		alias HW_PROFILE_INFOA HW_PROFILE_INFO;
2741 		alias AccessCheckAndAuditAlarmA AccessCheckAndAuditAlarm;
2742 		alias BackupEventLogA BackupEventLog;
2743 		alias ClearEventLogA ClearEventLog;
2744 		alias CreateNamedPipeA CreateNamedPipe;
2745 		alias CreateProcessAsUserA CreateProcessAsUser;
2746 		alias DefineDosDeviceA DefineDosDevice;
2747 		alias FindFirstFileExA FindFirstFileEx;
2748 		alias GetBinaryTypeA GetBinaryType;
2749 		alias GetCompressedFileSizeA GetCompressedFileSize;
2750 		alias GetFileSecurityA GetFileSecurity;
2751 		alias LogonUserA LogonUser;
2752 		alias LookupAccountNameA LookupAccountName;
2753 		alias LookupAccountSidA LookupAccountSid;
2754 		alias LookupPrivilegeDisplayNameA LookupPrivilegeDisplayName;
2755 		alias LookupPrivilegeNameA LookupPrivilegeName;
2756 		alias LookupPrivilegeValueA LookupPrivilegeValue;
2757 		alias MoveFileExA MoveFileEx;
2758 		alias ObjectCloseAuditAlarmA ObjectCloseAuditAlarm;
2759 		alias ObjectDeleteAuditAlarmA ObjectDeleteAuditAlarm;
2760 		alias ObjectOpenAuditAlarmA ObjectOpenAuditAlarm;
2761 		alias ObjectPrivilegeAuditAlarmA ObjectPrivilegeAuditAlarm;
2762 		alias OpenBackupEventLogA OpenBackupEventLog;
2763 		alias OpenEventLogA OpenEventLog;
2764 		alias PrivilegedServiceAuditAlarmA PrivilegedServiceAuditAlarm;
2765 		alias ReadEventLogA ReadEventLog;
2766 		alias RegisterEventSourceA RegisterEventSource;
2767 		alias ReportEventA ReportEvent;
2768 		alias SetFileSecurityA SetFileSecurity;
2769 		alias UpdateResourceA UpdateResource;
2770 
2771 		static if (_WIN32_WINNT >= 0x500) {
2772 			alias CreateFileMappingA CreateFileMapping;
2773 			alias CreateHardLinkA CreateHardLink;
2774 			alias CreateJobObjectA CreateJobObject;
2775 			alias DeleteVolumeMountPointA DeleteVolumeMountPoint;
2776 			alias DnsHostnameToComputerNameA DnsHostnameToComputerName;
2777 			alias EncryptFileA EncryptFile;
2778 			alias FileEncryptionStatusA FileEncryptionStatus;
2779 			alias FindFirstVolumeA FindFirstVolume;
2780 			alias FindFirstVolumeMountPointA FindFirstVolumeMountPoint;
2781 			alias FindNextVolumeA FindNextVolume;
2782 			alias FindNextVolumeMountPointA FindNextVolumeMountPoint;
2783 			alias GetModuleHandleExA GetModuleHandleEx;
2784 			alias GetSystemWindowsDirectoryA GetSystemWindowsDirectory;
2785 			alias GetVolumeNameForVolumeMountPointA GetVolumeNameForVolumeMountPoint;
2786 			alias GetVolumePathNameA GetVolumePathName;
2787 			alias OpenFileMappingA OpenFileMapping;
2788 			alias ReplaceFileA ReplaceFile;
2789 			alias SetVolumeMountPointA SetVolumeMountPoint;
2790 			alias VerifyVersionInfoA VerifyVersionInfo;
2791 		}
2792 
2793 		static if (_WIN32_WINNT >= 0x501) {
2794 			alias ACTCTXA ACTCTX;
2795 			alias CheckNameLegalDOS8Dot3A CheckNameLegalDOS8Dot3;
2796 			alias CreateActCtxA CreateActCtx;
2797 			alias FindActCtxSectionStringA FindActCtxSectionString;
2798 			alias GetSystemWow64DirectoryA GetSystemWow64Directory;
2799 			alias GetVolumePathNamesForVolumeNameA GetVolumePathNamesForVolumeName;
2800 			alias SetFileShortNameA SetFileShortName;
2801 		}
2802 
2803 		static if (_WIN32_WINNT >= 0x502) {
2804 			alias GetDllDirectoryA GetDllDirectory;
2805 			alias SetDllDirectoryA SetDllDirectory;
2806 			alias SetFirmwareEnvironmentVariableA SetFirmwareEnvironmentVariable;
2807 		}
2808 	}
2809 }
2810 
2811 alias STARTUPINFO* LPSTARTUPINFO;
2812 alias WIN32_FIND_DATA* LPWIN32_FIND_DATA;
2813 
2814 static if (_WIN32_WINNT_ONLY) {
2815 	alias HW_PROFILE_INFO* LPHW_PROFILE_INFO;
2816 
2817 	static if (_WIN32_WINNT >= 0x501) {
2818 		alias ACTCTX* PACTCTX, PCACTCTX;
2819 	}
2820 }