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 windows.winbase;
11 pragma(lib, "kernel32");
12 nothrow:
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 windows.
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 windows.windef, windows.winver;
57 private import windows.basetyps, windows.w32api, windows.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 >= 0x501) {
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 >= 0x501) {
83 	PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER);
84 	}
85 	LONG InterlockedIncrement(LPLONG);
86 	static if (_WIN32_WINNT >= 0x501) {
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 enum 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 >= 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 enum 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 // for LogonUser()
873 enum : DWORD {
874 	LOGON32_LOGON_INTERACTIVE = 2,
875 	LOGON32_LOGON_NETWORK     = 3,
876 	LOGON32_LOGON_BATCH       = 4,
877 	LOGON32_LOGON_SERVICE     = 5,
878 	LOGON32_LOGON_UNLOCK      = 7
879 }
880 
881 // for LogonUser()
882 enum : DWORD {
883 	LOGON32_PROVIDER_DEFAULT,
884 	LOGON32_PROVIDER_WINNT35,
885 	LOGON32_PROVIDER_WINNT40,
886 	LOGON32_PROVIDER_WINNT50
887 }
888 
889 // for MoveFileEx()
890 const DWORD
891 	MOVEFILE_REPLACE_EXISTING   = 1,
892 	MOVEFILE_COPY_ALLOWED       = 2,
893 	MOVEFILE_DELAY_UNTIL_REBOOT = 4,
894 	MOVEFILE_WRITE_THROUGH      = 8;
895 
896 // DefineDosDevice()
897 const DWORD
898 	DDD_RAW_TARGET_PATH       = 1,
899 	DDD_REMOVE_DEFINITION     = 2,
900 	DDD_EXACT_MATCH_ON_REMOVE = 4;
901 
902 static if (_WIN32_WINNT >= 0x500) {
903 	enum : DWORD {
904 		LOGON32_LOGON_NETWORK_CLEARTEXT = 8,
905 		LOGON32_LOGON_NEW_CREDENTIALS   = 9
906 	}
907 
908 	// ReplaceFile()
909 	const DWORD
910 		REPLACEFILE_WRITE_THROUGH       = 1,
911 		REPLACEFILE_IGNORE_MERGE_ERRORS = 2;
912 }
913 
914 static if (_WIN32_WINNT >= 0x501) {
915 	const DWORD
916 		GET_MODULE_HANDLE_EX_FLAG_PIN                = 1,
917 		GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2,
918 		GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS       = 4;
919 
920 	// for ACTCTX
921 	const DWORD
922 		ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID = 0x01,
923 		ACTCTX_FLAG_LANGID_VALID                 = 0x02,
924 		ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID     = 0x04,
925 		ACTCTX_FLAG_RESOURCE_NAME_VALID          = 0x08,
926 		ACTCTX_FLAG_SET_PROCESS_DEFAULT          = 0x10,
927 		ACTCTX_FLAG_APPLICATION_NAME_VALID       = 0x20,
928 		ACTCTX_FLAG_HMODULE_VALID                = 0x80;
929 
930 	// DeactivateActCtx()
931 	const DWORD DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION = 1;
932 	// FindActCtxSectionString()
933 	const DWORD FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX          = 1;
934 	// QueryActCtxW()
935 	const DWORD
936 		QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX             = 0x04,
937 		QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE             = 0x08,
938 		QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS             = 0x10;
939 
940 	enum {
941 		LOGON_WITH_PROFILE        = 1,
942 		LOGON_NETCREDENTIALS_ONLY
943 	}
944 }
945 
946 // ----
947 
948 struct FILETIME {
949 	DWORD dwLowDateTime;
950 	DWORD dwHighDateTime;
951 }
952 alias FILETIME* PFILETIME, LPFILETIME;
953 
954 struct BY_HANDLE_FILE_INFORMATION {
955 	DWORD    dwFileAttributes;
956 	FILETIME ftCreationTime;
957 	FILETIME ftLastAccessTime;
958 	FILETIME ftLastWriteTime;
959 	DWORD    dwVolumeSerialNumber;
960 	DWORD    nFileSizeHigh;
961 	DWORD    nFileSizeLow;
962 	DWORD    nNumberOfLinks;
963 	DWORD    nFileIndexHigh;
964 	DWORD    nFileIndexLow;
965 }
966 alias BY_HANDLE_FILE_INFORMATION* LPBY_HANDLE_FILE_INFORMATION;
967 
968 struct DCB {
969 	DWORD DCBlength = DCB.sizeof;
970 	DWORD BaudRate;
971 /+
972 	DWORD fBinary:1;              // Binary Mode (skip EOF check)
973 	DWORD fParity:1;              // Enable parity checking
974 	DWORD fOutxCtsFlow:1;         // CTS handshaking on output
975 	DWORD fOutxDsrFlow:1;         // DSR handshaking on output
976 	DWORD fDtrControl:2;          // DTR Flow control
977 	DWORD fDsrSensitivity:1;      // DSR Sensitivity
978 	DWORD fTXContinueOnXoff:1;    // Continue TX when Xoff sent
979 	DWORD fOutX:1;                // Enable output X-ON/X-OFF
980 	DWORD fInX:1;                 // Enable input X-ON/X-OFF
981 	DWORD fErrorChar:1;           // Enable Err Replacement
982 	DWORD fNull:1;                // Enable Null stripping
983 	DWORD fRtsControl:2;          // Rts Flow control
984 	DWORD fAbortOnError:1;        // Abort all reads and writes on Error
985 	DWORD fDummy2:17;             // Reserved
986 +/
987 	uint _bf;
988 	bool fBinary(bool f)           { _bf = (_bf & ~0x0001) | f; return f; }
989 	bool fParity(bool f)           { _bf = (_bf & ~0x0002) | (f<<1); return f; }
990 	bool fOutxCtsFlow(bool f)      { _bf = (_bf & ~0x0004) | (f<<2); return f; }
991 	bool fOutxDsrFlow(bool f)      { _bf = (_bf & ~0x0008) | (f<<3); return f; }
992 	byte fDtrControl(byte x)       { _bf = (_bf & ~0x0030) | (x<<4); return cast(byte)(x & 3); }
993 	bool fDsrSensitivity(bool f)   { _bf = (_bf & ~0x0040) | (f<<6); return f; }
994 	bool fTXContinueOnXoff(bool f) { _bf = (_bf & ~0x0080) | (f<<7); return f; }
995 	bool fOutX(bool f)             { _bf = (_bf & ~0x0100) | (f<<8); return f; }
996 	bool fInX(bool f)              { _bf = (_bf & ~0x0200) | (f<<9); return f; }
997 	bool fErrorChar(bool f)        { _bf = (_bf & ~0x0400) | (f<<10); return f; }
998 	bool fNull(bool f)             { _bf = (_bf & ~0x0800) | (f<<11); return f; }
999 	byte fRtsControl(byte x)       { _bf = (_bf & ~0x3000) | (x<<12); return cast(byte)(x & 3); }
1000 	bool fAbortOnError(bool f)     { _bf = (_bf & ~0x4000) | (f<<14); return f; }
1001 
1002 	bool fBinary()           { return cast(bool) (_bf & 1); }
1003 	bool fParity()           { return cast(bool) (_bf & 2); }
1004 	bool fOutxCtsFlow()      { return cast(bool) (_bf & 4); }
1005 	bool fOutxDsrFlow()      { return cast(bool) (_bf & 8); }
1006 	byte fDtrControl()       { return cast(byte) ((_bf & (32+16))>>4); }
1007 	bool fDsrSensitivity()   { return cast(bool) (_bf & 64); }
1008 	bool fTXContinueOnXoff() { return cast(bool) (_bf & 128); }
1009 	bool fOutX()             { return cast(bool) (_bf & 256); }
1010 	bool fInX()              { return cast(bool) (_bf & 512); }
1011 	bool fErrorChar()        { return cast(bool) (_bf & 1024); }
1012 	bool fNull()             { return cast(bool) (_bf & 2048); }
1013 	byte fRtsControl()       { return cast(byte) ((_bf & (4096+8192))>>12); }
1014 	bool fAbortOnError()     { return cast(bool) (_bf & 16384); }
1015 
1016 	WORD wReserved;
1017 	WORD XonLim;
1018 	WORD XoffLim;
1019 	BYTE ByteSize;
1020 	BYTE Parity;
1021 	BYTE StopBits;
1022 	char XonChar;
1023 	char XoffChar;
1024 	char ErrorChar;
1025 	char EofChar;
1026 	char EvtChar;
1027 	WORD wReserved1;
1028 }
1029 alias DCB* LPDCB;
1030 
1031 struct COMMCONFIG {
1032 	DWORD dwSize = COMMCONFIG.sizeof;
1033 	WORD  wVersion;
1034 	WORD  wReserved;
1035 	DCB   dcb;
1036 	DWORD dwProviderSubType;
1037 	DWORD dwProviderOffset;
1038 	DWORD dwProviderSize;
1039 	WCHAR _wcProviderData;
1040 
1041 	WCHAR* wcProviderData() { return &_wcProviderData; }
1042 }
1043 alias COMMCONFIG* LPCOMMCONFIG;
1044 
1045 struct COMMTIMEOUTS {
1046 	DWORD ReadIntervalTimeout;
1047 	DWORD ReadTotalTimeoutMultiplier;
1048 	DWORD ReadTotalTimeoutConstant;
1049 	DWORD WriteTotalTimeoutMultiplier;
1050 	DWORD WriteTotalTimeoutConstant;
1051 }
1052 alias COMMTIMEOUTS* LPCOMMTIMEOUTS;
1053 
1054 struct COMSTAT {
1055 /+
1056 	DWORD fCtsHold:1;
1057 	DWORD fDsrHold:1;
1058 	DWORD fRlsdHold:1;
1059 	DWORD fXoffHold:1;
1060 	DWORD fXoffSent:1;
1061 	DWORD fEof:1;
1062 	DWORD fTxim:1;
1063 	DWORD fReserved:25;
1064 +/
1065 	DWORD _bf;
1066     bool fCtsHold(bool f)  { _bf = (_bf & ~1) | f; return f; }
1067 	bool fDsrHold(bool f)  { _bf = (_bf & ~2) | (f<<1); return f; }
1068 	bool fRlsdHold(bool f) { _bf = (_bf & ~4) | (f<<2); return f; }
1069 	bool fXoffHold(bool f) { _bf = (_bf & ~8) | (f<<3); return f; }
1070 	bool fXoffSent(bool f) { _bf = (_bf & ~16) | (f<<4); return f; }
1071 	bool fEof(bool f)      { _bf = (_bf & ~32) | (f<<5); return f; }
1072 	bool fTxim(bool f)     { _bf = (_bf & ~64) | (f<<6); return f; }
1073 
1074     bool fCtsHold()  { return cast(bool) (_bf & 1); }
1075 	bool fDsrHold()  { return cast(bool) (_bf & 2); }
1076 	bool fRlsdHold() { return cast(bool) (_bf & 4); }
1077 	bool fXoffHold() { return cast(bool) (_bf & 8); }
1078 	bool fXoffSent() { return cast(bool) (_bf & 16); }
1079 	bool fEof()      { return cast(bool) (_bf & 32); }
1080 	bool fTxim()     { return cast(bool) (_bf & 64); }
1081 
1082 	DWORD cbInQue;
1083 	DWORD cbOutQue;
1084 }
1085 alias COMSTAT* LPCOMSTAT;
1086 
1087 struct CREATE_PROCESS_DEBUG_INFO {
1088 	HANDLE hFile;
1089 	HANDLE hProcess;
1090 	HANDLE hThread;
1091 	LPVOID lpBaseOfImage;
1092 	DWORD  dwDebugInfoFileOffset;
1093 	DWORD  nDebugInfoSize;
1094 	LPVOID lpThreadLocalBase;
1095 	LPTHREAD_START_ROUTINE lpStartAddress;
1096 	LPVOID lpImageName;
1097 	WORD   fUnicode;
1098 }
1099 alias CREATE_PROCESS_DEBUG_INFO* LPCREATE_PROCESS_DEBUG_INFO;
1100 
1101 struct CREATE_THREAD_DEBUG_INFO {
1102 	HANDLE hThread;
1103 	LPVOID lpThreadLocalBase;
1104 	LPTHREAD_START_ROUTINE lpStartAddress;
1105 }
1106 alias CREATE_THREAD_DEBUG_INFO* LPCREATE_THREAD_DEBUG_INFO;
1107 
1108 struct EXCEPTION_DEBUG_INFO {
1109 	EXCEPTION_RECORD ExceptionRecord;
1110 	DWORD            dwFirstChance;
1111 }
1112 alias EXCEPTION_DEBUG_INFO* LPEXCEPTION_DEBUG_INFO;
1113 
1114 struct EXIT_THREAD_DEBUG_INFO {
1115 	DWORD dwExitCode;
1116 }
1117 alias EXIT_THREAD_DEBUG_INFO* LPEXIT_THREAD_DEBUG_INFO;
1118 
1119 struct EXIT_PROCESS_DEBUG_INFO {
1120 	DWORD dwExitCode;
1121 }
1122 alias EXIT_PROCESS_DEBUG_INFO* LPEXIT_PROCESS_DEBUG_INFO;
1123 
1124 struct LOAD_DLL_DEBUG_INFO {
1125 	HANDLE hFile;
1126 	LPVOID lpBaseOfDll;
1127 	DWORD  dwDebugInfoFileOffset;
1128 	DWORD  nDebugInfoSize;
1129 	LPVOID lpImageName;
1130 	WORD   fUnicode;
1131 }
1132 alias LOAD_DLL_DEBUG_INFO* LPLOAD_DLL_DEBUG_INFO;
1133 
1134 struct UNLOAD_DLL_DEBUG_INFO {
1135 	LPVOID lpBaseOfDll;
1136 }
1137 alias UNLOAD_DLL_DEBUG_INFO* LPUNLOAD_DLL_DEBUG_INFO;
1138 
1139 struct OUTPUT_DEBUG_STRING_INFO {
1140 	LPSTR lpDebugStringData;
1141 	WORD  fUnicode;
1142 	WORD  nDebugStringLength;
1143 }
1144 alias OUTPUT_DEBUG_STRING_INFO* LPOUTPUT_DEBUG_STRING_INFO;
1145 
1146 struct RIP_INFO {
1147 	DWORD dwError;
1148 	DWORD dwType;
1149 }
1150 alias RIP_INFO* LPRIP_INFO;
1151 
1152 struct DEBUG_EVENT {
1153 	DWORD dwDebugEventCode;
1154 	DWORD dwProcessId;
1155 	DWORD dwThreadId;
1156 	union {
1157 		EXCEPTION_DEBUG_INFO      Exception;
1158 		CREATE_THREAD_DEBUG_INFO  CreateThread;
1159 		CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
1160 		EXIT_THREAD_DEBUG_INFO    ExitThread;
1161 		EXIT_PROCESS_DEBUG_INFO   ExitProcess;
1162 		LOAD_DLL_DEBUG_INFO       LoadDll;
1163 		UNLOAD_DLL_DEBUG_INFO     UnloadDll;
1164 		OUTPUT_DEBUG_STRING_INFO  DebugString;
1165 		RIP_INFO                  RipInfo;
1166 	}
1167 }
1168 alias DEBUG_EVENT* LPDEBUG_EVENT;
1169 
1170 struct OVERLAPPED {
1171 	ULONG_PTR Internal;
1172 	ULONG_PTR InternalHigh;
1173 	union {
1174 		struct {
1175 			DWORD     Offset;
1176 			DWORD     OffsetHigh;
1177 		}
1178 		PVOID     Pointer;
1179 	}
1180 	HANDLE    hEvent;
1181 }
1182 alias OVERLAPPED* POVERLAPPED, LPOVERLAPPED;
1183 
1184 struct STARTUPINFOA {
1185 	DWORD  cb = STARTUPINFOA.sizeof;
1186 	LPSTR  lpReserved;
1187 	LPSTR  lpDesktop;
1188 	LPSTR  lpTitle;
1189 	DWORD  dwX;
1190 	DWORD  dwY;
1191 	DWORD  dwXSize;
1192 	DWORD  dwYSize;
1193 	DWORD  dwXCountChars;
1194 	DWORD  dwYCountChars;
1195 	DWORD  dwFillAttribute;
1196 	DWORD  dwFlags;
1197 	WORD   wShowWindow;
1198 	WORD   cbReserved2;
1199 	PBYTE  lpReserved2;
1200 	HANDLE hStdInput;
1201 	HANDLE hStdOutput;
1202 	HANDLE hStdError;
1203 }
1204 alias STARTUPINFOA* LPSTARTUPINFOA;
1205 
1206 struct STARTUPINFOW {
1207 	DWORD  cb = STARTUPINFOW.sizeof;
1208 	LPWSTR lpReserved;
1209 	LPWSTR lpDesktop;
1210 	LPWSTR lpTitle;
1211 	DWORD  dwX;
1212 	DWORD  dwY;
1213 	DWORD  dwXSize;
1214 	DWORD  dwYSize;
1215 	DWORD  dwXCountChars;
1216 	DWORD  dwYCountChars;
1217 	DWORD  dwFillAttribute;
1218 	DWORD  dwFlags;
1219 	WORD   wShowWindow;
1220 	WORD   cbReserved2;
1221 	PBYTE  lpReserved2;
1222 	HANDLE hStdInput;
1223 	HANDLE hStdOutput;
1224 	HANDLE hStdError;
1225 }
1226 alias STARTUPINFOW* LPSTARTUPINFOW;
1227 
1228 struct PROCESS_INFORMATION {
1229 	HANDLE hProcess;
1230 	HANDLE hThread;
1231 	DWORD  dwProcessId;
1232 	DWORD  dwThreadId;
1233 }
1234 alias PROCESS_INFORMATION* PPROCESS_INFORMATION, LPPROCESS_INFORMATION;
1235 
1236 struct CRITICAL_SECTION_DEBUG {
1237 	WORD              Type;
1238 	WORD              CreatorBackTraceIndex;
1239 	CRITICAL_SECTION* CriticalSection;
1240 	LIST_ENTRY        ProcessLocksList;
1241 	DWORD             EntryCount;
1242 	DWORD             ContentionCount;
1243 	DWORD[2]          Spare;
1244 }
1245 alias CRITICAL_SECTION_DEBUG* PCRITICAL_SECTION_DEBUG;
1246 
1247 struct CRITICAL_SECTION {
1248 	PCRITICAL_SECTION_DEBUG DebugInfo;
1249 	LONG   LockCount;
1250 	LONG   RecursionCount;
1251 	HANDLE OwningThread;
1252 	HANDLE LockSemaphore;
1253 	DWORD  SpinCount;
1254 }
1255 alias CRITICAL_SECTION* PCRITICAL_SECTION, LPCRITICAL_SECTION;
1256 
1257 struct SYSTEMTIME {
1258 	WORD wYear;
1259 	WORD wMonth;
1260 	WORD wDayOfWeek;
1261 	WORD wDay;
1262 	WORD wHour;
1263 	WORD wMinute;
1264 	WORD wSecond;
1265 	WORD wMilliseconds;
1266 }
1267 alias SYSTEMTIME* LPSYSTEMTIME;
1268 
1269 struct WIN32_FILE_ATTRIBUTE_DATA {
1270 	DWORD    dwFileAttributes;
1271 	FILETIME ftCreationTime;
1272 	FILETIME ftLastAccessTime;
1273 	FILETIME ftLastWriteTime;
1274 	DWORD    nFileSizeHigh;
1275 	DWORD    nFileSizeLow;
1276 }
1277 alias WIN32_FILE_ATTRIBUTE_DATA* LPWIN32_FILE_ATTRIBUTE_DATA;
1278 
1279 struct WIN32_FIND_DATAA {
1280 	DWORD          dwFileAttributes;
1281 	FILETIME       ftCreationTime;
1282 	FILETIME       ftLastAccessTime;
1283 	FILETIME       ftLastWriteTime;
1284 	DWORD          nFileSizeHigh;
1285 	DWORD          nFileSizeLow;
1286 // #ifdef _WIN32_WCE
1287 //	DWORD dwOID;
1288 // #else
1289 	DWORD          dwReserved0;
1290 	DWORD          dwReserved1;
1291 // #endif
1292 	CHAR[MAX_PATH] cFileName;
1293 // #ifndef _WIN32_WCE
1294 	CHAR[14]       cAlternateFileName;
1295 // #endif
1296 }
1297 alias WIN32_FIND_DATAA* PWIN32_FIND_DATAA, LPWIN32_FIND_DATAA;
1298 
1299 struct WIN32_FIND_DATAW {
1300 	DWORD           dwFileAttributes;
1301 	FILETIME        ftCreationTime;
1302 	FILETIME        ftLastAccessTime;
1303 	FILETIME        ftLastWriteTime;
1304 	DWORD           nFileSizeHigh;
1305 	DWORD           nFileSizeLow;
1306 // #ifdef _WIN32_WCE
1307 // 	DWORD dwOID;
1308 // #else
1309 	DWORD           dwReserved0;
1310 	DWORD           dwReserved1;
1311 // #endif
1312 	WCHAR[MAX_PATH] cFileName;
1313 // #ifndef _WIN32_WCE
1314 	WCHAR[14]       cAlternateFileName;
1315 // #endif
1316 }
1317 alias WIN32_FIND_DATAW* PWIN32_FIND_DATAW, LPWIN32_FIND_DATAW;
1318 
1319 struct WIN32_STREAM_ID {
1320 	DWORD         dwStreamId;
1321 	DWORD         dwStreamAttributes;
1322 	LARGE_INTEGER Size;
1323 	DWORD         dwStreamNameSize;
1324 	WCHAR         _cStreamName;
1325 
1326 	WCHAR* cStreamName() { return &_cStreamName; }
1327 }
1328 alias WIN32_STREAM_ID* LPWIN32_STREAM_ID;
1329 
1330 enum FINDEX_INFO_LEVELS {
1331 	FindExInfoStandard,
1332 	FindExInfoMaxInfoLevel
1333 }
1334 
1335 enum FINDEX_SEARCH_OPS {
1336 	FindExSearchNameMatch,
1337 	FindExSearchLimitToDirectories,
1338 	FindExSearchLimitToDevices,
1339 	FindExSearchMaxSearchOp
1340 }
1341 
1342 enum ACL_INFORMATION_CLASS {
1343 	AclRevisionInformation = 1,
1344 	AclSizeInformation
1345 }
1346 
1347 struct HW_PROFILE_INFOA {
1348 	DWORD dwDockInfo;
1349 	CHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid;
1350 	CHAR[MAX_PROFILE_LEN]    szHwProfileName;
1351 }
1352 alias HW_PROFILE_INFOA* LPHW_PROFILE_INFOA;
1353 
1354 struct HW_PROFILE_INFOW {
1355 	DWORD dwDockInfo;
1356 	WCHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid;
1357 	WCHAR[MAX_PROFILE_LEN]    szHwProfileName;
1358 }
1359 alias HW_PROFILE_INFOW* LPHW_PROFILE_INFOW;
1360 
1361 /*	??? MSDN documents this only for Windows CE/Mobile, but it's used by
1362  *	GetFileAttributesEx, which is in desktop Windows.
1363  */
1364 enum GET_FILEEX_INFO_LEVELS {
1365 	GetFileExInfoStandard,
1366 	GetFileExMaxInfoLevel
1367 }
1368 
1369 struct SYSTEM_INFO {
1370 	union {
1371 		DWORD dwOemId;
1372 		struct {
1373 			WORD wProcessorArchitecture;
1374 			WORD wReserved;
1375 		}
1376 	}
1377 	DWORD dwPageSize;
1378 	PVOID lpMinimumApplicationAddress;
1379 	PVOID lpMaximumApplicationAddress;
1380 	DWORD_PTR dwActiveProcessorMask;
1381 	DWORD dwNumberOfProcessors;
1382 	DWORD dwProcessorType;
1383 	DWORD dwAllocationGranularity;
1384 	WORD  wProcessorLevel;
1385 	WORD  wProcessorRevision;
1386 }
1387 alias SYSTEM_INFO* LPSYSTEM_INFO;
1388 
1389 static if (_WIN32_WINNT >= 0x500) {
1390 	struct SYSTEM_POWER_STATUS {
1391 		BYTE ACLineStatus;
1392 		BYTE BatteryFlag;
1393 		BYTE BatteryLifePercent;
1394 		BYTE Reserved1;
1395 		DWORD BatteryLifeTime;
1396 		DWORD BatteryFullLifeTime;
1397 	}
1398 	alias SYSTEM_POWER_STATUS* LPSYSTEM_POWER_STATUS;
1399 }
1400 
1401 struct TIME_ZONE_INFORMATION {
1402 	LONG       Bias;
1403 	WCHAR[32]  StandardName;
1404 	SYSTEMTIME StandardDate;
1405 	LONG       StandardBias;
1406 	WCHAR[32]  DaylightName;
1407 	SYSTEMTIME DaylightDate;
1408 	LONG       DaylightBias;
1409 }
1410 alias TIME_ZONE_INFORMATION* LPTIME_ZONE_INFORMATION;
1411 
1412 // MSDN documents this, possibly erroneously, as Win2000+.
1413 struct MEMORYSTATUS {
1414 	DWORD dwLength;
1415 	DWORD dwMemoryLoad;
1416 	DWORD dwTotalPhys;
1417 	DWORD dwAvailPhys;
1418 	DWORD dwTotalPageFile;
1419 	DWORD dwAvailPageFile;
1420 	DWORD dwTotalVirtual;
1421 	DWORD dwAvailVirtual;
1422 }
1423 alias MEMORYSTATUS* LPMEMORYSTATUS;
1424 
1425 static if (_WIN32_WINNT >= 0x500) {
1426 	struct MEMORYSTATUSEX {
1427 		DWORD     dwLength = MEMORYSTATUSEX.sizeof;
1428 		DWORD     dwMemoryLoad;
1429 		DWORDLONG ullTotalPhys;
1430 		DWORDLONG ullAvailPhys;
1431 		DWORDLONG ullTotalPageFile;
1432 		DWORDLONG ullAvailPageFile;
1433 		DWORDLONG ullTotalVirtual;
1434 		DWORDLONG ullAvailVirtual;
1435 		DWORDLONG ullAvailExtendedVirtual;
1436 	}
1437 	alias MEMORYSTATUSEX* LPMEMORYSTATUSEX;
1438 }
1439 
1440 struct LDT_ENTRY {
1441 	WORD LimitLow;
1442 	WORD BaseLow;
1443 	struct {
1444 		BYTE BaseMid;
1445 		BYTE Flags1;
1446 		BYTE Flags2;
1447 		BYTE BaseHi;
1448 
1449 		byte Type(byte f)        { Flags1 = cast(BYTE) ((Flags1 & 0xE0) | f); return cast(byte)(f & 0x1F); }
1450 		byte Dpl(byte f)         { Flags1 = cast(BYTE) ((Flags1 & 0x9F) | (f<<5)); return cast(byte)(f & 3); }
1451 		bool Pres(bool f)        { Flags1 = cast(BYTE) ((Flags1 & 0x7F) | (f<<7)); return f; }
1452 
1453 		byte LimitHi(byte f)     { Flags2 = cast(BYTE) ((Flags2 & 0xF0) | (f&0x0F)); return cast(byte)(f & 0x0F); }
1454 		bool Sys(bool f)         { Flags2 = cast(BYTE) ((Flags2 & 0xEF) | (f<<4)); return f; }
1455 		// Next bit is reserved
1456 		bool Default_Big(bool f) { Flags2 = cast(BYTE) ((Flags2 & 0xBF) | (f<<6)); return f; }
1457 		bool Granularity(bool f) { Flags2 = cast(BYTE) ((Flags2 & 0x7F) | (f<<7)); return f; }
1458 
1459 		byte Type()        { return cast(byte) (Flags1 & 0x1F); }
1460 		byte Dpl()         { return cast(byte) ((Flags1 & 0x60)>>5); }
1461 		bool Pres()        { return cast(bool) (Flags1 & 0x80); }
1462 
1463 		byte LimitHi()     { return cast(byte) (Flags2 & 0x0F); }
1464 		bool Sys()         { return cast(bool) (Flags2 & 0x10); }
1465 		bool Default_Big() { return cast(bool) (Flags2 & 0x40); }
1466 		bool Granularity() { return cast(bool) (Flags2 & 0x80); }
1467 	}
1468 /+
1469 	union  HighWord {
1470 		struct Bytes {
1471 			BYTE BaseMid;
1472 			BYTE Flags1;
1473 			BYTE Flags2;
1474 			BYTE BaseHi;
1475 		}
1476 	struct Bits {
1477 		DWORD BaseMid:8;
1478 		DWORD Type:5;
1479 		DWORD Dpl:2;
1480 		DWORD Pres:1;
1481 		DWORD LimitHi:4;
1482 		DWORD Sys:1;
1483 		DWORD Reserved_0:1;
1484 		DWORD Default_Big:1;
1485 		DWORD Granularity:1;
1486 		DWORD BaseHi:8;
1487 	}
1488 	}
1489 +/
1490 }
1491 alias LDT_ENTRY* PLDT_ENTRY, LPLDT_ENTRY;
1492 
1493 /*	As with the other memory management functions and structures, MSDN's
1494  *	Windows version info shall be taken with a cup of salt.
1495  */
1496 struct PROCESS_HEAP_ENTRY {
1497 	PVOID lpData;
1498 	DWORD cbData;
1499 	BYTE  cbOverhead;
1500 	BYTE  iRegionIndex;
1501 	WORD  wFlags;
1502 	union {
1503 		struct Block {
1504 			HANDLE   hMem;
1505 			DWORD[3] dwReserved;
1506 		}
1507 		struct Region {
1508 			DWORD    dwCommittedSize;
1509 			DWORD    dwUnCommittedSize;
1510 			LPVOID   lpFirstBlock;
1511 			LPVOID   lpLastBlock;
1512 		}
1513 	}
1514 }
1515 alias PROCESS_HEAP_ENTRY* LPPROCESS_HEAP_ENTRY;
1516 
1517 struct OFSTRUCT {
1518 	BYTE      cBytes = OFSTRUCT.sizeof;
1519 	BYTE      fFixedDisk;
1520 	WORD      nErrCode;
1521 	WORD      Reserved1;
1522 	WORD      Reserved2;
1523 	CHAR[128] szPathName; // const OFS_MAXPATHNAME = 128;
1524 }
1525 alias OFSTRUCT* LPOFSTRUCT, POFSTRUCT;
1526 
1527 /*	??? MSDN documents this only for Windows CE, but it's used by
1528  *	ImageGetCertificateData, which is in desktop Windows.
1529  */
1530 struct WIN_CERTIFICATE {
1531 	DWORD dwLength;
1532 	WORD  wRevision;
1533 	WORD  wCertificateType;
1534 	BYTE  _bCertificate;
1535 
1536 	BYTE* bCertificate() { return &_bCertificate; }
1537 }
1538 alias WIN_CERTIFICATE* LPWIN_CERTIFICATE;
1539 
1540 static if (_WIN32_WINNT >= 0x500) {
1541 	enum COMPUTER_NAME_FORMAT {
1542 		ComputerNameNetBIOS,
1543 		ComputerNameDnsHostname,
1544 		ComputerNameDnsDomain,
1545 		ComputerNameDnsFullyQualified,
1546 		ComputerNamePhysicalNetBIOS,
1547 		ComputerNamePhysicalDnsHostname,
1548 		ComputerNamePhysicalDnsDomain,
1549 		ComputerNamePhysicalDnsFullyQualified,
1550 		ComputerNameMax
1551 	}
1552 }
1553 
1554 static if (_WIN32_WINNT >= 0x501) {
1555 	struct ACTCTXA {
1556 		ULONG cbSize = this.sizeof;
1557 		DWORD dwFlags;
1558 		LPCSTR lpSource;
1559 		USHORT wProcessorArchitecture;
1560 		LANGID wLangId;
1561 		LPCSTR lpAssemblyDirectory;
1562 		LPCSTR lpResourceName;
1563 		LPCSTR lpApplicationName;
1564 		HMODULE hModule;
1565 	}
1566 	alias ACTCTXA*        PACTCTXA;
1567 	alias const(ACTCTXA)* PCACTCTXA;
1568 
1569 	struct ACTCTXW {
1570 		ULONG cbSize = this.sizeof;
1571 		DWORD dwFlags;
1572 		LPCWSTR lpSource;
1573 		USHORT wProcessorArchitecture;
1574 		LANGID wLangId;
1575 		LPCWSTR lpAssemblyDirectory;
1576 		LPCWSTR lpResourceName;
1577 		LPCWSTR lpApplicationName;
1578 		HMODULE hModule;
1579 	}
1580 	alias ACTCTXW*        PACTCTXW;
1581 	alias const(ACTCTXW)* PCACTCTXW;
1582 
1583 	struct ACTCTX_SECTION_KEYED_DATA {
1584 		ULONG cbSize = this.sizeof;
1585 		ULONG ulDataFormatVersion;
1586 		PVOID lpData;
1587 		ULONG ulLength;
1588 		PVOID lpSectionGlobalData;
1589 		ULONG ulSectionGlobalDataLength;
1590 		PVOID lpSectionBase;
1591 		ULONG ulSectionTotalLength;
1592 		HANDLE hActCtx;
1593 		HANDLE ulAssemblyRosterIndex;
1594 	}
1595 	alias ACTCTX_SECTION_KEYED_DATA*        PACTCTX_SECTION_KEYED_DATA;
1596 	alias const(ACTCTX_SECTION_KEYED_DATA)* PCACTCTX_SECTION_KEYED_DATA;
1597 
1598 	enum MEMORY_RESOURCE_NOTIFICATION_TYPE {
1599 		LowMemoryResourceNotification,
1600 		HighMemoryResourceNotification
1601 	}
1602 
1603 } // (_WIN32_WINNT >= 0x501)
1604 
1605 static if (_WIN32_WINNT >= 0x410) {
1606 	/*	apparently used only by SetThreadExecutionState (Win2000+)
1607 	 *	and DDK functions (version compatibility not established)
1608 	 */
1609 	alias DWORD EXECUTION_STATE;
1610 }
1611 
1612 // Callbacks
1613 extern (Windows) {
1614 	alias DWORD function(LPVOID) LPTHREAD_START_ROUTINE;
1615 	alias DWORD function(LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER,
1616 		DWORD, DWORD, HANDLE, HANDLE, LPVOID)  LPPROGRESS_ROUTINE;
1617 	alias void function(PVOID) LPFIBER_START_ROUTINE;
1618 
1619 	alias BOOL function(HMODULE, LPCSTR, LPCSTR, WORD, LONG) ENUMRESLANGPROCA;
1620 	alias BOOL function(HMODULE, LPCWSTR, LPCWSTR, WORD, LONG) ENUMRESLANGPROCW;
1621 	alias BOOL function(HMODULE, LPCSTR, LPSTR, LONG) ENUMRESNAMEPROCA;
1622 	alias BOOL function(HMODULE, LPCWSTR, LPWSTR, LONG) ENUMRESNAMEPROCW;
1623 	alias BOOL function(HMODULE, LPSTR, LONG) ENUMRESTYPEPROCA;
1624 	alias BOOL function(HMODULE, LPWSTR, LONG) ENUMRESTYPEPROCW;
1625 	alias void function(DWORD, DWORD, LPOVERLAPPED) LPOVERLAPPED_COMPLETION_ROUTINE;
1626 	alias LONG function(LPEXCEPTION_POINTERS) PTOP_LEVEL_EXCEPTION_FILTER;
1627 	alias PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1628 
1629 	alias void function(ULONG_PTR) PAPCFUNC;
1630 	alias void function(PVOID, DWORD, DWORD) PTIMERAPCROUTINE;
1631 
1632 	static if (_WIN32_WINNT >= 0x500) {
1633 		alias void function(PVOID, BOOLEAN) WAITORTIMERCALLBACK;
1634 	}
1635 }
1636 
1637 LPTSTR MAKEINTATOM()(ushort i) {
1638 	return cast(LPTSTR) cast(size_t) i;
1639 }
1640 
1641 extern (Windows) {
1642 	HRESULT StringCchPrintf(LPWSTR, size_t, LPCWSTR, LPCWSTR, ...);
1643 	ATOM AddAtomA(LPCSTR);
1644 	ATOM AddAtomW(LPCWSTR);
1645 	BOOL AreFileApisANSI();
1646 	BOOL Beep(DWORD, DWORD);
1647 	HANDLE BeginUpdateResourceA(LPCSTR, BOOL);
1648 	HANDLE BeginUpdateResourceW(LPCWSTR, BOOL);
1649 	BOOL BuildCommDCBA(LPCSTR, LPDCB);
1650 	BOOL BuildCommDCBW(LPCWSTR, LPDCB);
1651 	BOOL BuildCommDCBAndTimeoutsA(LPCSTR, LPDCB, LPCOMMTIMEOUTS);
1652 	BOOL BuildCommDCBAndTimeoutsW(LPCWSTR, LPDCB, LPCOMMTIMEOUTS);
1653 	BOOL CallNamedPipeA(LPCSTR, PVOID, DWORD, PVOID, DWORD, PDWORD, DWORD);
1654 	BOOL CallNamedPipeW(LPCWSTR, PVOID, DWORD, PVOID, DWORD, PDWORD, DWORD);
1655 	BOOL CancelDeviceWakeupRequest(HANDLE);
1656 	BOOL CheckTokenMembership(HANDLE, PSID, PBOOL);
1657 	BOOL ClearCommBreak(HANDLE);
1658 	BOOL ClearCommError(HANDLE, PDWORD, LPCOMSTAT);
1659 	BOOL CloseHandle(HANDLE);
1660 	BOOL CommConfigDialogA(LPCSTR, HWND, LPCOMMCONFIG);
1661 	BOOL CommConfigDialogW(LPCWSTR, HWND, LPCOMMCONFIG);
1662 	LONG CompareFileTime(const(FILETIME)*, const(FILETIME)*);
1663 	BOOL ContinueDebugEvent(DWORD, DWORD, DWORD);
1664 	BOOL CopyFileA(LPCSTR, LPCSTR, BOOL);
1665 	BOOL CopyFileW(LPCWSTR, LPCWSTR, BOOL);
1666 	BOOL CopyFileExA(LPCSTR, LPCSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
1667 	BOOL CopyFileExW(LPCWSTR, LPCWSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
1668 
1669 	/+ FIXME
1670 	alias memmove RtlMoveMemory;
1671 	alias memcpy RtlCopyMemory;
1672 
1673 	void RtlFillMemory(PVOID dest, SIZE_T len, BYTE fill) {
1674 		memset(dest, fill, len);
1675 	}
1676 
1677 	void RtlZeroMemory(PVOID dest, SIZE_T len) {
1678 		RtlFillMemory(dest, len, 0);
1679 	}
1680 
1681 	alias RtlMoveMemory MoveMemory;
1682 	alias RtlCopyMemory CopyMemory;
1683 	alias RtlFillMemory FillMemory;
1684 	alias RtlZeroMemory ZeroMemory;
1685 	+/
1686 	BOOL CreateDirectoryA(LPCSTR, LPSECURITY_ATTRIBUTES);
1687 	BOOL CreateDirectoryW(LPCWSTR, LPSECURITY_ATTRIBUTES);
1688 	BOOL CreateDirectoryExA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
1689 	BOOL CreateDirectoryExW(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
1690 	HANDLE CreateEventA(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCSTR);
1691 	HANDLE CreateEventW(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCWSTR);
1692 	HANDLE CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
1693 	HANDLE CreateFileW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
1694 	HANDLE CreateIoCompletionPort(HANDLE, HANDLE, ULONG_PTR, DWORD);
1695 	HANDLE CreateMailslotA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
1696 	HANDLE CreateMailslotW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
1697 	HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
1698 	HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
1699 	BOOL CreatePipe(PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD);
1700 	BOOL CreateProcessA(LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
1701 	BOOL CreateProcessW(LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
1702 	HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCSTR);
1703 	HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCWSTR);
1704 	HANDLE CreateThread(LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, PVOID, DWORD, PDWORD);
1705 	BOOL DebugActiveProcess(DWORD);
1706 	void DebugBreak();
1707 	ATOM DeleteAtom(ATOM);
1708 	void DeleteCriticalSection(PCRITICAL_SECTION);
1709 	BOOL DeleteFileA(LPCSTR);
1710 	BOOL DeleteFileW(LPCWSTR);
1711 	BOOL DisableThreadLibraryCalls(HMODULE);
1712 	BOOL DosDateTimeToFileTime(WORD, WORD, LPFILETIME);
1713 	BOOL DuplicateHandle(HANDLE, HANDLE, HANDLE, PHANDLE, DWORD, BOOL, DWORD);
1714 	BOOL EndUpdateResourceA(HANDLE, BOOL);
1715 	BOOL EndUpdateResourceW(HANDLE, BOOL);
1716 	void EnterCriticalSection(LPCRITICAL_SECTION);
1717 	BOOL EnumResourceLanguagesA(HMODULE, LPCSTR, LPCSTR, ENUMRESLANGPROC, LONG_PTR);
1718 	BOOL EnumResourceLanguagesW(HMODULE, LPCWSTR, LPCWSTR, ENUMRESLANGPROC, LONG_PTR);
1719 	BOOL EnumResourceNamesA(HMODULE, LPCSTR, ENUMRESNAMEPROC, LONG_PTR);
1720 	BOOL EnumResourceNamesW(HMODULE, LPCWSTR, ENUMRESNAMEPROC, LONG_PTR);
1721 	BOOL EnumResourceTypesA(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
1722 	BOOL EnumResourceTypesW(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
1723 	BOOL EscapeCommFunction(HANDLE, DWORD);
1724 	void ExitProcess(UINT); // Never returns
1725 	void ExitThread(DWORD); // Never returns
1726 	DWORD ExpandEnvironmentStringsA(LPCSTR, LPSTR, DWORD);
1727 	DWORD ExpandEnvironmentStringsW(LPCWSTR, LPWSTR, DWORD);
1728 	void FatalAppExitA(UINT, LPCSTR);
1729 	void FatalAppExitW(UINT, LPCWSTR);
1730 	void FatalExit(int);
1731 	BOOL FileTimeToDosDateTime(const(FILETIME)*, LPWORD, LPWORD);
1732 	BOOL FileTimeToLocalFileTime(const(FILETIME)*, LPFILETIME);
1733 	BOOL FileTimeToSystemTime(const(FILETIME)*, LPSYSTEMTIME);
1734 	ATOM FindAtomA(LPCSTR);
1735 	ATOM FindAtomW(LPCWSTR);
1736 	BOOL FindClose(HANDLE);
1737 	BOOL FindCloseChangeNotification(HANDLE);
1738 	HANDLE FindFirstChangeNotificationA(LPCSTR, BOOL, DWORD);
1739 	HANDLE FindFirstChangeNotificationW(LPCWSTR, BOOL, DWORD);
1740 	HANDLE FindFirstFileA(LPCSTR, LPWIN32_FIND_DATAA);
1741 	HANDLE FindFirstFileW(LPCWSTR, LPWIN32_FIND_DATAW);
1742 	BOOL FindNextChangeNotification(HANDLE);
1743 	BOOL FindNextFileA(HANDLE, LPWIN32_FIND_DATAA);
1744 	BOOL FindNextFileW(HANDLE, LPWIN32_FIND_DATAW);
1745 	HRSRC FindResourceA(HMODULE, LPCSTR, LPCSTR);
1746 	HRSRC FindResourceW(HINSTANCE, LPCWSTR, LPCWSTR);
1747 	HRSRC FindResourceExA(HINSTANCE, LPCSTR, LPCSTR, WORD);
1748 	HRSRC FindResourceExW(HINSTANCE, LPCWSTR, LPCWSTR, WORD);
1749 	BOOL FlushFileBuffers(HANDLE);
1750 	BOOL FlushInstructionCache(HANDLE, PCVOID, DWORD);
1751 	DWORD FormatMessageA(DWORD, PCVOID, DWORD, DWORD, LPSTR, DWORD, va_list*);
1752 	DWORD FormatMessageW(DWORD, PCVOID, DWORD, DWORD, LPWSTR, DWORD, va_list*);
1753 	BOOL FreeEnvironmentStringsA(LPSTR);
1754 	BOOL FreeEnvironmentStringsW(LPWSTR);
1755 	BOOL FreeLibrary(HMODULE);
1756 	void FreeLibraryAndExitThread(HMODULE, DWORD); // never returns
1757 	BOOL FreeResource(HGLOBAL);
1758 	UINT GetAtomNameA(ATOM, LPSTR, int);
1759 	UINT GetAtomNameW(ATOM, LPWSTR, int);
1760 	LPSTR GetCommandLineA();
1761 	LPWSTR GetCommandLineW();
1762 	BOOL GetCommConfig(HANDLE, LPCOMMCONFIG, PDWORD);
1763 	BOOL GetCommMask(HANDLE, PDWORD);
1764 	BOOL GetCommModemStatus(HANDLE, PDWORD);
1765 	BOOL GetCommProperties(HANDLE, LPCOMMPROP);
1766 	BOOL GetCommState(HANDLE, LPDCB);
1767 	BOOL GetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
1768 	BOOL GetComputerNameA(LPSTR, PDWORD);
1769 	BOOL GetComputerNameW(LPWSTR, PDWORD);
1770 	DWORD GetCurrentDirectoryA(DWORD, LPSTR);
1771 	DWORD GetCurrentDirectoryW(DWORD, LPWSTR);
1772 	HANDLE GetCurrentProcess();
1773 	DWORD GetCurrentProcessId();
1774 	HANDLE GetCurrentThread();
1775 /* In MinGW:
1776 #ifdef _WIN32_WCE
1777 extern DWORD GetCurrentThreadId(void);
1778 #else
1779 WINBASEAPI DWORD WINAPI GetCurrentThreadId(void);
1780 #endif
1781 */
1782 	DWORD GetCurrentThreadId();
1783 
1784 	alias GetTickCount GetCurrentTime;
1785 
1786 	BOOL GetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, PDWORD);
1787 	BOOL GetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, PDWORD);
1788 	BOOL GetDiskFreeSpaceA(LPCSTR, PDWORD, PDWORD, PDWORD, PDWORD);
1789 	BOOL GetDiskFreeSpaceW(LPCWSTR, PDWORD, PDWORD, PDWORD, PDWORD);
1790 	BOOL GetDiskFreeSpaceExA(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
1791 	BOOL GetDiskFreeSpaceExW(LPCWSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
1792 	UINT GetDriveTypeA(LPCSTR);
1793 	UINT GetDriveTypeW(LPCWSTR);
1794 	LPSTR GetEnvironmentStrings(); // ???
1795 	LPSTR GetEnvironmentStringsA();
1796 	LPWSTR GetEnvironmentStringsW();
1797 	DWORD GetEnvironmentVariableA(LPCSTR, LPSTR, DWORD);
1798 	DWORD GetEnvironmentVariableW(LPCWSTR, LPWSTR, DWORD);
1799 	BOOL GetExitCodeProcess(HANDLE, PDWORD);
1800 	BOOL GetExitCodeThread(HANDLE, PDWORD);
1801 	DWORD GetFileAttributesA(LPCSTR);
1802 	DWORD GetFileAttributesW(LPCWSTR);
1803 	BOOL GetFileInformationByHandle(HANDLE, LPBY_HANDLE_FILE_INFORMATION);
1804 	DWORD GetFileSize(HANDLE, PDWORD);
1805 	BOOL GetFileTime(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME);
1806 	DWORD GetFileType(HANDLE);
1807 	DWORD GetFullPathNameA(LPCSTR, DWORD, LPSTR, LPSTR*);
1808 	DWORD GetFullPathNameW(LPCWSTR, DWORD, LPWSTR, LPWSTR*);
1809 	DWORD GetLastError();
1810 	void GetLocalTime(LPSYSTEMTIME);
1811 	DWORD GetLogicalDrives();
1812 	DWORD GetLogicalDriveStringsA(DWORD, LPSTR);
1813 	DWORD GetLogicalDriveStringsW(DWORD, LPWSTR);
1814 	BOOL GetMailslotInfo(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD);
1815 	DWORD GetModuleFileNameA(HINSTANCE, LPSTR, DWORD);
1816 	DWORD GetModuleFileNameW(HINSTANCE, LPWSTR, DWORD);
1817 	HMODULE GetModuleHandleA(LPCSTR);
1818 	HMODULE GetModuleHandleW(LPCWSTR);
1819 	BOOL GetNamedPipeHandleStateA(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD, LPSTR, DWORD);
1820 	BOOL GetNamedPipeHandleStateW(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD, LPWSTR, DWORD);
1821 	BOOL GetNamedPipeInfo(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD);
1822 	BOOL GetOverlappedResult(HANDLE, LPOVERLAPPED, PDWORD, BOOL);
1823 	DWORD GetPriorityClass(HANDLE);
1824 	UINT GetPrivateProfileIntA(LPCSTR, LPCSTR, INT, LPCSTR);
1825 	UINT GetPrivateProfileIntW(LPCWSTR, LPCWSTR, INT, LPCWSTR);
1826 	DWORD GetPrivateProfileSectionA(LPCSTR, LPSTR, DWORD, LPCSTR);
1827 	DWORD GetPrivateProfileSectionW(LPCWSTR, LPWSTR, DWORD, LPCWSTR);
1828 	DWORD GetPrivateProfileSectionNamesA(LPSTR, DWORD, LPCSTR);
1829 	DWORD GetPrivateProfileSectionNamesW(LPWSTR, DWORD, LPCWSTR);
1830 	DWORD GetPrivateProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPSTR, DWORD, LPCSTR);
1831 	DWORD GetPrivateProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD, LPCWSTR);
1832 	BOOL GetPrivateProfileStructA(LPCSTR, LPCSTR, LPVOID, UINT, LPCSTR);
1833 	BOOL GetPrivateProfileStructW(LPCWSTR, LPCWSTR, LPVOID, UINT, LPCWSTR);
1834 	FARPROC GetProcAddress(HINSTANCE, LPCSTR);
1835 	BOOL GetProcessAffinityMask(HANDLE, PDWORD, PDWORD);
1836 	DWORD GetProcessVersion(DWORD);
1837 	UINT GetProfileIntA(LPCSTR, LPCSTR, INT);
1838 	UINT GetProfileIntW(LPCWSTR, LPCWSTR, INT);
1839 	DWORD GetProfileSectionA(LPCSTR, LPSTR, DWORD);
1840 	DWORD GetProfileSectionW(LPCWSTR, LPWSTR, DWORD);
1841 	DWORD GetProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPSTR, DWORD);
1842 	DWORD GetProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD);
1843 	DWORD GetShortPathNameA(LPCSTR, LPSTR, DWORD);
1844 	DWORD GetShortPathNameW(LPCWSTR, LPWSTR, DWORD);
1845 	VOID GetStartupInfoA(LPSTARTUPINFOA);
1846 	VOID GetStartupInfoW(LPSTARTUPINFOW);
1847 	HANDLE GetStdHandle(DWORD);
1848 	UINT GetSystemDirectoryA(LPSTR, UINT);
1849 	UINT GetSystemDirectoryW(LPWSTR, UINT);
1850 	VOID GetSystemInfo(LPSYSTEM_INFO);
1851 	VOID GetSystemTime(LPSYSTEMTIME);
1852 	BOOL GetSystemTimeAdjustment(PDWORD, PDWORD, PBOOL);
1853 	void GetSystemTimeAsFileTime(LPFILETIME);
1854 	UINT GetTempFileNameA(LPCSTR, LPCSTR, UINT, LPSTR);
1855 	UINT GetTempFileNameW(LPCWSTR, LPCWSTR, UINT, LPWSTR);
1856 	DWORD GetTempPathA(DWORD, LPSTR);
1857 	DWORD GetTempPathW(DWORD, LPWSTR);
1858 	BOOL GetThreadContext(HANDLE, LPCONTEXT);
1859 	int GetThreadPriority(HANDLE);
1860 	BOOL GetThreadSelectorEntry(HANDLE, DWORD, LPLDT_ENTRY);
1861 	DWORD GetTickCount();
1862 	DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION);
1863 	BOOL GetUserNameA (LPSTR, PDWORD);
1864 	BOOL GetUserNameW(LPWSTR, PDWORD);
1865 	DWORD GetVersion();
1866 	BOOL GetVersionExA(LPOSVERSIONINFOA);
1867 	BOOL GetVersionExW(LPOSVERSIONINFOW);
1868 	BOOL GetVolumeInformationA(LPCSTR, LPSTR, DWORD, PDWORD, PDWORD, PDWORD, LPSTR, DWORD);
1869 	BOOL GetVolumeInformationW(LPCWSTR, LPWSTR, DWORD, PDWORD, PDWORD, PDWORD, LPWSTR, DWORD);
1870 	UINT GetWindowsDirectoryA(LPSTR, UINT);
1871 	UINT GetWindowsDirectoryW(LPWSTR, UINT);
1872 	DWORD GetWindowThreadProcessId(HWND, PDWORD);
1873 	ATOM GlobalAddAtomA(LPCSTR);
1874 	ATOM GlobalAddAtomW(LPCWSTR);
1875 	ATOM GlobalDeleteAtom(ATOM);
1876 	ATOM GlobalFindAtomA(LPCSTR);
1877 	ATOM GlobalFindAtomW(LPCWSTR);
1878 	UINT GlobalGetAtomNameA(ATOM, LPSTR, int);
1879 	UINT GlobalGetAtomNameW(ATOM, LPWSTR, int);
1880 
1881 	bool HasOverlappedIoCompleted(LPOVERLAPPED lpOverlapped) {
1882 		return lpOverlapped.Internal != STATUS_PENDING;
1883 	}
1884 
1885 	BOOL InitAtomTable(DWORD);
1886 	VOID InitializeCriticalSection(LPCRITICAL_SECTION);
1887 	/*	??? The next two are allegedly obsolete and "supported only for
1888 	 *	backward compatibility with the 16-bit Windows API".  Yet the
1889 	 *	replacements IsBadReadPtr and IsBadWritePtr are apparently Win2000+
1890 	 *	only.  Where's the mistake?
1891 	 */
1892 	BOOL IsBadHugeReadPtr(PCVOID, UINT_PTR);
1893 	BOOL IsBadHugeWritePtr(PVOID, UINT_PTR);
1894 	BOOL IsBadReadPtr(PCVOID, UINT_PTR);
1895 	BOOL IsBadStringPtrA(LPCSTR, UINT_PTR);
1896 	BOOL IsBadStringPtrW(LPCWSTR, UINT_PTR);
1897 	BOOL IsBadWritePtr(PVOID, UINT_PTR);
1898 	void LeaveCriticalSection(LPCRITICAL_SECTION);
1899 	HINSTANCE LoadLibraryA(LPCSTR);
1900 	HINSTANCE LoadLibraryW(LPCWSTR);
1901 	HINSTANCE LoadLibraryExA(LPCSTR, HANDLE, DWORD);
1902 	HINSTANCE LoadLibraryExW(LPCWSTR, HANDLE, DWORD);
1903 	DWORD LoadModule(LPCSTR, PVOID);
1904 	HGLOBAL LoadResource(HINSTANCE, HRSRC);
1905 	BOOL LocalFileTimeToFileTime(const(FILETIME)*, LPFILETIME);
1906 	BOOL LockFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
1907 	PVOID LockResource(HGLOBAL);
1908 
1909 	LPSTR lstrcatA(LPSTR, LPCSTR);
1910 	LPWSTR lstrcatW(LPWSTR, LPCWSTR);
1911 	int lstrcmpA(LPCSTR, LPCSTR);
1912 	int lstrcmpiA(LPCSTR, LPCSTR);
1913 	int lstrcmpiW(LPCWSTR, LPCWSTR);
1914 	int lstrcmpW(LPCWSTR, LPCWSTR);
1915 	LPSTR lstrcpyA(LPSTR, LPCSTR);
1916 	LPSTR lstrcpynA(LPSTR, LPCSTR, int);
1917 	LPWSTR lstrcpynW(LPWSTR, LPCWSTR, int);
1918 	LPWSTR lstrcpyW(LPWSTR, LPCWSTR);
1919 	int lstrlenA(LPCSTR);
1920 	int lstrlenW(LPCWSTR);
1921 
1922 	BOOL MoveFileA(LPCSTR, LPCSTR);
1923 	BOOL MoveFileW(LPCWSTR, LPCWSTR);
1924 	int MulDiv(int, int, int);
1925 	HANDLE OpenEventA(DWORD, BOOL, LPCSTR);
1926 	HANDLE OpenEventW(DWORD, BOOL, LPCWSTR);
1927 	deprecated HFILE OpenFile(LPCSTR, LPOFSTRUCT, UINT);
1928 	HANDLE OpenMutexA(DWORD, BOOL, LPCSTR);
1929 	HANDLE OpenMutexW(DWORD, BOOL, LPCWSTR);
1930 	HANDLE OpenProcess(DWORD, BOOL, DWORD);
1931 	HANDLE OpenSemaphoreA(DWORD, BOOL, LPCSTR);
1932 	HANDLE OpenSemaphoreW(DWORD, BOOL, LPCWSTR);
1933 	void OutputDebugStringA(LPCSTR);
1934 	void OutputDebugStringW(LPCWSTR);
1935 	BOOL PeekNamedPipe(HANDLE, PVOID, DWORD, PDWORD, PDWORD, PDWORD);
1936 	BOOL PulseEvent(HANDLE);
1937 	BOOL PurgeComm(HANDLE, DWORD);
1938 	BOOL QueryPerformanceCounter(PLARGE_INTEGER);
1939 	BOOL QueryPerformanceFrequency(PLARGE_INTEGER);
1940 	DWORD QueueUserAPC(PAPCFUNC, HANDLE, ULONG_PTR);
1941 	void RaiseException(DWORD, DWORD, DWORD, const(DWORD)*);
1942 	BOOL ReadFile(HANDLE, PVOID, DWORD, PDWORD, LPOVERLAPPED);
1943 	BOOL ReadFileEx(HANDLE, PVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
1944 	BOOL ReadProcessMemory(HANDLE, PCVOID, PVOID, SIZE_T, SIZE_T*);
1945 	BOOL ReleaseMutex(HANDLE);
1946 	BOOL ReleaseSemaphore(HANDLE, LONG, LPLONG);
1947 	BOOL RemoveDirectoryA(LPCSTR);
1948 	BOOL RemoveDirectoryW(LPCWSTR);
1949 /* In MinGW:
1950 #ifdef _WIN32_WCE
1951 extern BOOL ResetEvent(HANDLE);
1952 #else
1953 WINBASEAPI BOOL WINAPI ResetEvent(HANDLE);
1954 #endif
1955 */
1956 	BOOL ResetEvent(HANDLE);
1957 	DWORD ResumeThread(HANDLE);
1958 	DWORD SearchPathA(LPCSTR, LPCSTR, LPCSTR, DWORD, LPSTR, LPSTR*);
1959 	DWORD SearchPathW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPWSTR, LPWSTR*);
1960 	BOOL SetCommBreak(HANDLE);
1961 	BOOL SetCommConfig(HANDLE, LPCOMMCONFIG, DWORD);
1962 	BOOL SetCommMask(HANDLE, DWORD);
1963 	BOOL SetCommState(HANDLE, LPDCB);
1964 	BOOL SetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
1965 	BOOL SetComputerNameA(LPCSTR);
1966 	BOOL SetComputerNameW(LPCWSTR);
1967 	BOOL SetCurrentDirectoryA(LPCSTR);
1968 	BOOL SetCurrentDirectoryW(LPCWSTR);
1969 	BOOL SetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, DWORD);
1970 	BOOL SetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, DWORD);
1971 	BOOL SetEndOfFile(HANDLE);
1972 	BOOL SetEnvironmentVariableA(LPCSTR, LPCSTR);
1973 	BOOL SetEnvironmentVariableW(LPCWSTR, LPCWSTR);
1974 	UINT SetErrorMode(UINT);
1975 /* In MinGW:
1976 #ifdef _WIN32_WCE
1977 extern BOOL SetEvent(HANDLE);
1978 #else
1979 WINBASEAPI BOOL WINAPI SetEvent(HANDLE);
1980 #endif
1981 */
1982 	BOOL SetEvent(HANDLE);
1983 	VOID SetFileApisToANSI();
1984 	VOID SetFileApisToOEM();
1985 	BOOL SetFileAttributesA(LPCSTR, DWORD);
1986 	BOOL SetFileAttributesW(LPCWSTR, DWORD);
1987 	DWORD SetFilePointer(HANDLE, LONG, PLONG, DWORD);
1988 	BOOL SetFileTime(HANDLE, const(FILETIME)*, const(FILETIME)*, const(FILETIME)*);
1989 	deprecated UINT SetHandleCount(UINT);
1990 	void SetLastError(DWORD);
1991 	void SetLastErrorEx(DWORD, DWORD);
1992 	BOOL SetLocalTime(const(SYSTEMTIME)*);
1993 	BOOL SetMailslotInfo(HANDLE, DWORD);
1994 	BOOL SetNamedPipeHandleState(HANDLE, PDWORD, PDWORD, PDWORD);
1995 	BOOL SetPriorityClass(HANDLE, DWORD);
1996 	BOOL SetStdHandle(DWORD, HANDLE);
1997 	BOOL SetSystemTime(const(SYSTEMTIME)*);
1998 	DWORD SetThreadAffinityMask(HANDLE, DWORD);
1999 	BOOL SetThreadContext(HANDLE, const(CONTEXT)*);
2000 	BOOL SetThreadPriority(HANDLE, int);
2001 	BOOL SetTimeZoneInformation(const(TIME_ZONE_INFORMATION)*);
2002 	LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER);
2003 	BOOL SetupComm(HANDLE, DWORD, DWORD);
2004 	BOOL SetVolumeLabelA(LPCSTR, LPCSTR);
2005 	BOOL SetVolumeLabelW(LPCWSTR, LPCWSTR);
2006 
2007 	DWORD SizeofResource(HINSTANCE, HRSRC);
2008 	void Sleep(DWORD);
2009 	DWORD SleepEx(DWORD, BOOL);
2010 	DWORD SuspendThread(HANDLE);
2011 	BOOL SystemTimeToFileTime(const(SYSTEMTIME)*, LPFILETIME);
2012 	BOOL TerminateProcess(HANDLE, UINT);
2013 	BOOL TerminateThread(HANDLE, DWORD);
2014 	DWORD TlsAlloc();
2015 	BOOL TlsFree(DWORD);
2016 	PVOID TlsGetValue(DWORD);
2017 	BOOL TlsSetValue(DWORD, PVOID);
2018 	BOOL TransactNamedPipe(HANDLE, PVOID, DWORD, PVOID, DWORD, PDWORD, LPOVERLAPPED);
2019 	BOOL TransmitCommChar(HANDLE, char);
2020 	LONG UnhandledExceptionFilter(LPEXCEPTION_POINTERS);
2021 	BOOL UnlockFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
2022 	BOOL WaitCommEvent(HANDLE, PDWORD, LPOVERLAPPED);
2023 	BOOL WaitForDebugEvent(LPDEBUG_EVENT, DWORD);
2024 	DWORD WaitForMultipleObjects(DWORD, const(HANDLE)*, BOOL, DWORD);
2025 	DWORD WaitForMultipleObjectsEx(DWORD, const(HANDLE)*, BOOL, DWORD, BOOL);
2026 	DWORD WaitForSingleObject(HANDLE, DWORD);
2027 	DWORD WaitForSingleObjectEx(HANDLE, DWORD, BOOL);
2028 	BOOL WaitNamedPipeA(LPCSTR, DWORD);
2029 	BOOL WaitNamedPipeW(LPCWSTR, DWORD);
2030 	// undocumented on MSDN
2031 	BOOL WinLoadTrustProvider(GUID*);
2032 	BOOL WriteFile(HANDLE, PCVOID, DWORD, PDWORD, LPOVERLAPPED);
2033 	BOOL WriteFileEx(HANDLE, PCVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
2034 	BOOL WritePrivateProfileSectionA(LPCSTR, LPCSTR, LPCSTR);
2035 	BOOL WritePrivateProfileSectionW(LPCWSTR, LPCWSTR, LPCWSTR);
2036 	BOOL WritePrivateProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPCSTR);
2037 	BOOL WritePrivateProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR);
2038 	BOOL WritePrivateProfileStructA(LPCSTR, LPCSTR, LPVOID, UINT, LPCSTR);
2039 	BOOL WritePrivateProfileStructW(LPCWSTR, LPCWSTR, LPVOID, UINT, LPCWSTR);
2040 	BOOL WriteProcessMemory(HANDLE, LPVOID, LPCVOID, SIZE_T, SIZE_T*);
2041 	BOOL WriteProfileSectionA(LPCSTR, LPCSTR);
2042 	BOOL WriteProfileSectionW(LPCWSTR, LPCWSTR);
2043 	BOOL WriteProfileStringA(LPCSTR, LPCSTR, LPCSTR);
2044 	BOOL WriteProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR);
2045 
2046 	/*	Memory allocation functions.
2047 	 *	MSDN documents these erroneously as Win2000+; thus it is uncertain what
2048 	 *	version compatibility they really have.
2049 	 */
2050 	HGLOBAL GlobalAlloc(UINT, DWORD);
2051 	HGLOBAL GlobalDiscard(HGLOBAL);
2052 	HGLOBAL GlobalFree(HGLOBAL);
2053 	HGLOBAL GlobalHandle(PCVOID);
2054 	LPVOID GlobalLock(HGLOBAL);
2055 	VOID GlobalMemoryStatus(LPMEMORYSTATUS);
2056 	HGLOBAL GlobalReAlloc(HGLOBAL, DWORD, UINT);
2057 	DWORD GlobalSize(HGLOBAL);
2058 	BOOL GlobalUnlock(HGLOBAL);
2059 	PVOID HeapAlloc(HANDLE, DWORD, DWORD);
2060 	SIZE_T HeapCompact(HANDLE, DWORD);
2061 	HANDLE HeapCreate(DWORD, DWORD, DWORD);
2062 	BOOL HeapDestroy(HANDLE);
2063 	BOOL HeapFree(HANDLE, DWORD, PVOID);
2064 	BOOL HeapLock(HANDLE);
2065 	PVOID HeapReAlloc(HANDLE, DWORD, PVOID, DWORD);
2066 	DWORD HeapSize(HANDLE, DWORD, PCVOID);
2067 	BOOL HeapUnlock(HANDLE);
2068 	BOOL HeapValidate(HANDLE, DWORD, PCVOID);
2069 	BOOL HeapWalk(HANDLE, LPPROCESS_HEAP_ENTRY);
2070 	HLOCAL LocalAlloc(UINT, SIZE_T);
2071 	HLOCAL LocalDiscard(HLOCAL);
2072 	HLOCAL LocalFree(HLOCAL);
2073 	HLOCAL LocalHandle(LPCVOID);
2074 	PVOID LocalLock(HLOCAL);
2075 	HLOCAL LocalReAlloc(HLOCAL, SIZE_T, UINT);
2076 	UINT LocalSize(HLOCAL);
2077 	BOOL LocalUnlock(HLOCAL);
2078 	PVOID VirtualAlloc(PVOID, DWORD, DWORD, DWORD);
2079 	PVOID VirtualAllocEx(HANDLE, PVOID, DWORD, DWORD, DWORD);
2080 	BOOL VirtualFree(PVOID, DWORD, DWORD);
2081 	BOOL VirtualFreeEx(HANDLE, PVOID, DWORD, DWORD);
2082 	BOOL VirtualLock(PVOID, DWORD);
2083 	BOOL VirtualProtect(PVOID, DWORD, DWORD, PDWORD);
2084 	BOOL VirtualProtectEx(HANDLE, PVOID, DWORD, DWORD, PDWORD);
2085 	DWORD VirtualQuery(LPCVOID, PMEMORY_BASIC_INFORMATION, DWORD);
2086 	DWORD VirtualQueryEx(HANDLE, LPCVOID, PMEMORY_BASIC_INFORMATION, DWORD);
2087 	BOOL VirtualUnlock(PVOID, DWORD);
2088 // not in MinGW 4.0 - ???
2089 	static if (_WIN32_WINNT >= 0x600) {
2090 		BOOL GetTokenInformation(HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD);
2091 		BOOL CancelIoEx(HANDLE, LPOVERLAPPED);
2092 	}
2093 
2094 	BOOL CancelIo(HANDLE);
2095 	BOOL CancelWaitableTimer(HANDLE);
2096 	PVOID ConvertThreadToFiber(PVOID);
2097 	LPVOID CreateFiber(SIZE_T, LPFIBER_START_ROUTINE, LPVOID);
2098 	HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
2099 	HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
2100 	void DeleteFiber(PVOID);
2101 	BOOL GetFileAttributesExA(LPCSTR, GET_FILEEX_INFO_LEVELS, PVOID);
2102 	BOOL GetFileAttributesExW(LPCWSTR, GET_FILEEX_INFO_LEVELS, PVOID);
2103 	DWORD GetLongPathNameA(LPCSTR, LPSTR, DWORD);
2104 	DWORD GetLongPathNameW(LPCWSTR, LPWSTR, DWORD);
2105 	BOOL InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION, DWORD);
2106 	BOOL IsDebuggerPresent();
2107 	HANDLE OpenWaitableTimerA(DWORD, BOOL, LPCSTR);
2108 	HANDLE OpenWaitableTimerW(DWORD, BOOL, LPCWSTR);
2109 	DWORD QueryDosDeviceA(LPCSTR, LPSTR, DWORD);
2110 	DWORD QueryDosDeviceW(LPCWSTR, LPWSTR, DWORD);
2111 	version(LDC){}else BOOL SetWaitableTimer(HANDLE, const(LARGE_INTEGER)*, LONG, PTIMERAPCROUTINE, PVOID, BOOL);
2112 	BOOL SetWaitableTimer(HANDLE, const(LARGE_INTEGER)*, LONG, VOID*, PVOID, BOOL);
2113 	void SwitchToFiber(PVOID);
2114 
2115 	static if (_WIN32_WINNT >= 0x500) {
2116 		HANDLE OpenThread(DWORD, BOOL, DWORD);
2117 	}
2118 
2119 	BOOL AccessCheck(PSECURITY_DESCRIPTOR, HANDLE, DWORD, PGENERIC_MAPPING, PPRIVILEGE_SET, PDWORD, PDWORD, PBOOL);
2120 	BOOL AccessCheckAndAuditAlarmA(LPCSTR, LPVOID, LPSTR, LPSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, PDWORD, PBOOL, PBOOL);
2121 	BOOL AccessCheckAndAuditAlarmW(LPCWSTR, LPVOID, LPWSTR, LPWSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, PDWORD, PBOOL, PBOOL);
2122 	BOOL AddAccessAllowedAce(PACL, DWORD, DWORD, PSID);
2123 	BOOL AddAccessDeniedAce(PACL, DWORD, DWORD, PSID);
2124 	BOOL AddAce(PACL, DWORD, DWORD, PVOID, DWORD);
2125 	BOOL AddAuditAccessAce(PACL, DWORD, DWORD, PSID, BOOL, BOOL);
2126 	BOOL AdjustTokenGroups(HANDLE, BOOL, PTOKEN_GROUPS, DWORD, PTOKEN_GROUPS, PDWORD);
2127 	BOOL AdjustTokenPrivileges(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
2128 	BOOL AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
2129 	BOOL AllocateLocallyUniqueId(PLUID);
2130 	BOOL AreAllAccessesGranted(DWORD, DWORD);
2131 	BOOL AreAnyAccessesGranted(DWORD, DWORD);
2132 	BOOL BackupEventLogA(HANDLE, LPCSTR);
2133 	BOOL BackupEventLogW(HANDLE, LPCWSTR);
2134 	BOOL BackupRead(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*);
2135 	BOOL BackupSeek(HANDLE, DWORD, DWORD, LPDWORD, LPDWORD, LPVOID*);
2136 	BOOL BackupWrite(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*);
2137 	BOOL ClearEventLogA(HANDLE, LPCSTR);
2138 	BOOL ClearEventLogW(HANDLE, LPCWSTR);
2139 	BOOL CloseEventLog(HANDLE);
2140 	BOOL ConnectNamedPipe(HANDLE, LPOVERLAPPED);
2141 	BOOL CopySid(DWORD, PSID, PSID);
2142 	HANDLE CreateNamedPipeA(LPCSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
2143 	HANDLE CreateNamedPipeW(LPCWSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
2144 	BOOL CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR*, BOOL, HANDLE, PGENERIC_MAPPING);
2145 	BOOL CreateProcessAsUserA(HANDLE, LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
2146 	BOOL CreateProcessAsUserW(HANDLE, LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
2147 	HANDLE CreateRemoteThread(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD);
2148 	DWORD CreateTapePartition(HANDLE, DWORD, DWORD, DWORD);
2149 	BOOL DefineDosDeviceA(DWORD, LPCSTR, LPCSTR);
2150 	BOOL DefineDosDeviceW(DWORD, LPCWSTR, LPCWSTR);
2151 	BOOL DeleteAce(PACL, DWORD);
2152 	BOOL DeregisterEventSource(HANDLE);
2153 	BOOL DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR*);
2154 	BOOL DeviceIoControl(HANDLE, DWORD, PVOID, DWORD, PVOID, DWORD, PDWORD, POVERLAPPED);
2155 	BOOL DisconnectNamedPipe(HANDLE);
2156 	BOOL DuplicateToken(HANDLE, SECURITY_IMPERSONATION_LEVEL, PHANDLE);
2157 	BOOL DuplicateTokenEx(HANDLE, DWORD, LPSECURITY_ATTRIBUTES, SECURITY_IMPERSONATION_LEVEL, TOKEN_TYPE, PHANDLE);
2158 	BOOL EqualPrefixSid(PSID, PSID);
2159 	BOOL EqualSid(PSID, PSID);
2160 	DWORD EraseTape(HANDLE, DWORD, BOOL);
2161 	HANDLE FindFirstFileExA(LPCSTR, FINDEX_INFO_LEVELS, PVOID, FINDEX_SEARCH_OPS, PVOID, DWORD);
2162 	HANDLE FindFirstFileExW(LPCWSTR, FINDEX_INFO_LEVELS, PVOID, FINDEX_SEARCH_OPS, PVOID, DWORD);
2163 	BOOL FindFirstFreeAce(PACL, PVOID*);
2164 	PVOID FreeSid(PSID);
2165 	BOOL GetAce(PACL, DWORD, LPVOID*);
2166 	BOOL GetAclInformation(PACL, PVOID, DWORD, ACL_INFORMATION_CLASS);
2167 	BOOL GetBinaryTypeA(LPCSTR, PDWORD);
2168 	BOOL GetBinaryTypeW(LPCWSTR, PDWORD);
2169 	DWORD GetCompressedFileSizeA(LPCSTR, PDWORD);
2170 	DWORD GetCompressedFileSizeW(LPCWSTR, PDWORD);
2171 	BOOL GetCurrentHwProfileA(LPHW_PROFILE_INFOA);
2172 	BOOL GetCurrentHwProfileW(LPHW_PROFILE_INFOW);
2173 	BOOL GetFileSecurityA(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2174 	BOOL GetFileSecurityW(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2175 	BOOL GetHandleInformation(HANDLE, PDWORD);
2176 	BOOL GetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2177 	DWORD GetLengthSid(PSID);
2178 	BOOL GetNumberOfEventLogRecords(HANDLE, PDWORD);
2179 	BOOL GetOldestEventLogRecord(HANDLE, PDWORD);
2180 	BOOL GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
2181 	BOOL GetProcessPriorityBoost(HANDLE, PBOOL);
2182 	BOOL GetProcessShutdownParameters(PDWORD, PDWORD);
2183 	BOOL GetProcessTimes(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
2184 	HWINSTA GetProcessWindowStation();
2185 	BOOL GetProcessWorkingSetSize(HANDLE, PSIZE_T, PSIZE_T);
2186 	BOOL GetQueuedCompletionStatus(HANDLE, PDWORD, PULONG_PTR, LPOVERLAPPED*, DWORD);
2187 	BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR_CONTROL, PDWORD);
2188 	BOOL GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, LPBOOL, PACL*, LPBOOL);
2189 	BOOL GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID*, LPBOOL);
2190 	DWORD GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR);
2191 	BOOL GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID*, LPBOOL);
2192 	BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, LPBOOL, PACL*, LPBOOL);
2193 	PSID_IDENTIFIER_AUTHORITY GetSidIdentifierAuthority(PSID);
2194 	DWORD GetSidLengthRequired(UCHAR);
2195 	PDWORD GetSidSubAuthority(PSID, DWORD);
2196 	PUCHAR GetSidSubAuthorityCount(PSID);
2197 	DWORD GetTapeParameters(HANDLE, DWORD, PDWORD, PVOID);
2198 	DWORD GetTapePosition(HANDLE, DWORD, PDWORD, PDWORD, PDWORD);
2199 	DWORD GetTapeStatus(HANDLE);
2200 	BOOL GetThreadPriorityBoost(HANDLE, PBOOL);
2201 	BOOL GetThreadTimes(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
2202 	BOOL ImpersonateLoggedOnUser(HANDLE);
2203 	BOOL ImpersonateNamedPipeClient(HANDLE);
2204 	BOOL ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL);
2205 	BOOL InitializeAcl(PACL, DWORD, DWORD);
2206 	DWORD SetCriticalSectionSpinCount(LPCRITICAL_SECTION, DWORD);
2207 	BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR, DWORD);
2208 	BOOL InitializeSid(PSID, PSID_IDENTIFIER_AUTHORITY, BYTE);
2209 	BOOL IsProcessorFeaturePresent(DWORD);
2210 	BOOL IsTextUnicode(PCVOID, int, LPINT);
2211 	BOOL IsValidAcl(PACL);
2212 	BOOL IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR);
2213 	BOOL IsValidSid(PSID);
2214 	BOOL CreateWellKnownSid(WELL_KNOWN_SID_TYPE, PSID, PSID, PDWORD);
2215 	BOOL LockFileEx(HANDLE, DWORD, DWORD, DWORD, DWORD, LPOVERLAPPED);
2216 	BOOL LogonUserA(LPSTR, LPSTR, LPSTR, DWORD, DWORD, PHANDLE);
2217 	BOOL LogonUserW(LPWSTR, LPWSTR, LPWSTR, DWORD, DWORD, PHANDLE);
2218 	BOOL LookupAccountNameA(LPCSTR, LPCSTR, PSID, PDWORD, LPSTR, PDWORD, PSID_NAME_USE);
2219 	BOOL LookupAccountNameW(LPCWSTR, LPCWSTR, PSID, PDWORD, LPWSTR, PDWORD, PSID_NAME_USE);
2220 	BOOL LookupAccountSidA(LPCSTR, PSID, LPSTR, PDWORD, LPSTR, PDWORD, PSID_NAME_USE);
2221 	BOOL LookupAccountSidW(LPCWSTR, PSID, LPWSTR, PDWORD, LPWSTR, PDWORD, PSID_NAME_USE);
2222 	BOOL LookupPrivilegeDisplayNameA(LPCSTR, LPCSTR, LPSTR, PDWORD, PDWORD);
2223 	BOOL LookupPrivilegeDisplayNameW(LPCWSTR, LPCWSTR, LPWSTR, PDWORD, PDWORD);
2224 	BOOL LookupPrivilegeNameA(LPCSTR, PLUID, LPSTR, PDWORD);
2225 	BOOL LookupPrivilegeNameW(LPCWSTR, PLUID, LPWSTR, PDWORD);
2226 	BOOL LookupPrivilegeValueA(LPCSTR, LPCSTR, PLUID);
2227 	BOOL LookupPrivilegeValueW(LPCWSTR, LPCWSTR, PLUID);
2228 	BOOL MakeAbsoluteSD(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PDWORD, PACL, PDWORD, PACL, PDWORD, PSID, PDWORD, PSID, PDWORD);
2229 	BOOL MakeSelfRelativeSD(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PDWORD);
2230 	VOID MapGenericMask(PDWORD, PGENERIC_MAPPING);
2231 	BOOL MoveFileExA(LPCSTR, LPCSTR, DWORD);
2232 	BOOL MoveFileExW(LPCWSTR, LPCWSTR, DWORD);
2233 	BOOL NotifyChangeEventLog(HANDLE, HANDLE);
2234 	BOOL ObjectCloseAuditAlarmA(LPCSTR, PVOID, BOOL);
2235 	BOOL ObjectCloseAuditAlarmW(LPCWSTR, PVOID, BOOL);
2236 	BOOL ObjectDeleteAuditAlarmA(LPCSTR, PVOID, BOOL);
2237 	BOOL ObjectDeleteAuditAlarmW(LPCWSTR, PVOID, BOOL);
2238 	BOOL ObjectOpenAuditAlarmA(LPCSTR, PVOID, LPSTR, LPSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, PBOOL);
2239 	BOOL ObjectOpenAuditAlarmW(LPCWSTR, PVOID, LPWSTR, LPWSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, PBOOL);
2240 	BOOL ObjectPrivilegeAuditAlarmA(LPCSTR, PVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
2241 	BOOL ObjectPrivilegeAuditAlarmW(LPCWSTR, PVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
2242 	HANDLE OpenBackupEventLogA(LPCSTR, LPCSTR);
2243 	HANDLE OpenBackupEventLogW(LPCWSTR, LPCWSTR);
2244 	HANDLE OpenEventLogA(LPCSTR, LPCSTR);
2245 	HANDLE OpenEventLogW(LPCWSTR, LPCWSTR);
2246 	BOOL OpenProcessToken(HANDLE, DWORD, PHANDLE);
2247 	BOOL OpenThreadToken(HANDLE, DWORD, BOOL, PHANDLE);
2248 	BOOL PostQueuedCompletionStatus(HANDLE, DWORD, ULONG_PTR, LPOVERLAPPED);
2249 	DWORD PrepareTape(HANDLE, DWORD, BOOL);
2250 	BOOL PrivilegeCheck(HANDLE, PPRIVILEGE_SET, PBOOL);
2251 	BOOL PrivilegedServiceAuditAlarmA(LPCSTR, LPCSTR, HANDLE, PPRIVILEGE_SET, BOOL);
2252 	BOOL PrivilegedServiceAuditAlarmW(LPCWSTR, LPCWSTR, HANDLE, PPRIVILEGE_SET, BOOL);
2253 	BOOL ReadDirectoryChangesW(HANDLE, PVOID, DWORD, BOOL, DWORD, PDWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
2254 	BOOL ReadEventLogA(HANDLE, DWORD, DWORD, PVOID, DWORD, DWORD*, DWORD*);
2255 	BOOL ReadEventLogW(HANDLE, DWORD, DWORD, PVOID, DWORD, DWORD*, DWORD*);
2256 	BOOL ReadFileScatter(HANDLE, FILE_SEGMENT_ELEMENT*, DWORD, LPDWORD, LPOVERLAPPED);
2257 	HANDLE RegisterEventSourceA (LPCSTR, LPCSTR);
2258 	HANDLE RegisterEventSourceW(LPCWSTR, LPCWSTR);
2259 	BOOL ReportEventA(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCSTR*, PVOID);
2260 	BOOL ReportEventW(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCWSTR*, PVOID);
2261 	BOOL RevertToSelf();
2262 	BOOL SetAclInformation(PACL, PVOID, DWORD, ACL_INFORMATION_CLASS);
2263 	BOOL SetFileSecurityA(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2264 	BOOL SetFileSecurityW(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2265 	BOOL SetHandleInformation(HANDLE, DWORD, DWORD);
2266 	BOOL SetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
2267 	BOOL SetPrivateObjectSecurity(SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR*, PGENERIC_MAPPING, HANDLE);
2268 	BOOL SetProcessAffinityMask(HANDLE, DWORD);
2269 	BOOL SetProcessPriorityBoost(HANDLE, BOOL);
2270 	BOOL SetProcessShutdownParameters(DWORD, DWORD);
2271 	BOOL SetProcessWorkingSetSize(HANDLE, SIZE_T, SIZE_T);
2272 	BOOL SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
2273 	BOOL SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID, BOOL);
2274 	BOOL SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID, BOOL);
2275 	BOOL SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
2276 	BOOL SetSystemTimeAdjustment(DWORD, BOOL);
2277 	DWORD SetTapeParameters(HANDLE, DWORD, PVOID);
2278 	DWORD SetTapePosition(HANDLE, DWORD, DWORD, DWORD, DWORD, BOOL);
2279 	BOOL SetThreadPriorityBoost(HANDLE, BOOL);
2280 	BOOL SetThreadToken(PHANDLE, HANDLE);
2281 	BOOL SetTokenInformation(HANDLE, TOKEN_INFORMATION_CLASS, PTOKEN_ELEVATION_TYPE, DWORD);
2282 	DWORD SignalObjectAndWait(HANDLE, HANDLE, DWORD, BOOL);
2283 	BOOL SwitchToThread();
2284 	BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
2285 	BOOL TryEnterCriticalSection(LPCRITICAL_SECTION);
2286 	BOOL UnlockFileEx(HANDLE, DWORD, DWORD, DWORD, LPOVERLAPPED);
2287 	BOOL UpdateResourceA(HANDLE, LPCSTR, LPCSTR, WORD, PVOID, DWORD);
2288 	BOOL UpdateResourceW(HANDLE, LPCWSTR, LPCWSTR, WORD, PVOID, DWORD);
2289 	BOOL WriteFileGather(HANDLE, FILE_SEGMENT_ELEMENT*, DWORD, LPDWORD, LPOVERLAPPED);
2290 	DWORD WriteTapemark(HANDLE, DWORD, DWORD, BOOL);
2291 
2292 	static if (_WIN32_WINNT >= 0x500) {
2293 		BOOL AddAccessAllowedAceEx(PACL, DWORD, DWORD, DWORD, PSID);
2294 		BOOL AddAccessDeniedAceEx(PACL, DWORD, DWORD, DWORD, PSID);
2295 		PVOID AddVectoredExceptionHandler(ULONG, PVECTORED_EXCEPTION_HANDLER);
2296 		BOOL AllocateUserPhysicalPages(HANDLE, PULONG_PTR, PULONG_PTR);
2297 		BOOL AssignProcessToJobObject(HANDLE, HANDLE);
2298 		BOOL ChangeTimerQueueTimer(HANDLE,HANDLE,ULONG,ULONG);
2299 		LPVOID CreateFiberEx(SIZE_T, SIZE_T, DWORD, LPFIBER_START_ROUTINE, LPVOID);
2300 		HANDLE CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCSTR);
2301 		HANDLE CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCWSTR);
2302 		BOOL CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
2303 		BOOL CreateHardLinkW(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
2304 		HANDLE CreateJobObjectA(LPSECURITY_ATTRIBUTES, LPCSTR);
2305 		HANDLE CreateJobObjectW(LPSECURITY_ATTRIBUTES, LPCWSTR);
2306 		BOOL CreateProcessWithLogonW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPCWSTR, LPWSTR, DWORD, LPVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
2307 		HANDLE CreateTimerQueue();
2308 		BOOL CreateTimerQueueTimer(PHANDLE, HANDLE, WAITORTIMERCALLBACK, PVOID, DWORD, DWORD, ULONG);
2309 		BOOL DeleteTimerQueue(HANDLE);
2310 		BOOL DeleteTimerQueueEx(HANDLE, HANDLE);
2311 		BOOL DeleteTimerQueueTimer(HANDLE, HANDLE, HANDLE);
2312 		BOOL DeleteVolumeMountPointA(LPCSTR);
2313 		BOOL DeleteVolumeMountPointW(LPCWSTR);
2314 		BOOL DnsHostnameToComputerNameA(LPCSTR, LPSTR, LPDWORD);
2315 		BOOL DnsHostnameToComputerNameW(LPCWSTR, LPWSTR, LPDWORD);
2316 		BOOL EncryptFileA(LPCSTR);
2317 		BOOL EncryptFileW(LPCWSTR);
2318 		BOOL FileEncryptionStatusA(LPCSTR, LPDWORD);
2319 		BOOL FileEncryptionStatusW(LPCWSTR, LPDWORD);
2320 		HANDLE FindFirstVolumeA(LPCSTR, DWORD);
2321 		HANDLE FindFirstVolumeMountPointA(LPSTR, LPSTR, DWORD);
2322 		HANDLE FindFirstVolumeMountPointW(LPWSTR, LPWSTR, DWORD);
2323 		HANDLE FindFirstVolumeW(LPCWSTR, DWORD);
2324 		BOOL FindNextVolumeA(HANDLE, LPCSTR, DWORD);
2325 		BOOL FindNextVolumeW(HANDLE, LPWSTR, DWORD);
2326 		BOOL FindNextVolumeMountPointA(HANDLE, LPSTR, DWORD);
2327 		BOOL FindNextVolumeMountPointW(HANDLE, LPWSTR, DWORD);
2328 		BOOL FindVolumeClose(HANDLE);
2329 		BOOL FindVolumeMountPointClose(HANDLE);
2330 		BOOL FlushViewOfFile(PCVOID, DWORD);
2331 		BOOL FreeUserPhysicalPages(HANDLE, PULONG_PTR, PULONG_PTR);
2332 		BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD);
2333 		BOOL GetComputerNameExW(COMPUTER_NAME_FORMAT, LPWSTR, LPDWORD);
2334 		BOOL GetFileSizeEx(HANDLE, PLARGE_INTEGER);
2335 		BOOL GetModuleHandleExA(DWORD, LPCSTR, HMODULE*);
2336 		BOOL GetModuleHandleExW(DWORD, LPCWSTR, HMODULE*);
2337 		HANDLE GetProcessHeap();
2338 		DWORD GetProcessHeaps(DWORD, PHANDLE);
2339 		BOOL GetProcessIoCounters(HANDLE, PIO_COUNTERS);
2340 		BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS);
2341 		UINT GetSystemWindowsDirectoryA(LPSTR, UINT);
2342 		UINT GetSystemWindowsDirectoryW(LPWSTR, UINT);
2343 		BOOL GetVolumeNameForVolumeMountPointA(LPCSTR, LPSTR, DWORD);
2344 		BOOL GetVolumeNameForVolumeMountPointW(LPCWSTR, LPWSTR, DWORD);
2345 		BOOL GetVolumePathNameA(LPCSTR, LPSTR, DWORD);
2346 		BOOL GetVolumePathNameW(LPCWSTR, LPWSTR, DWORD);
2347 		BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX);
2348 		BOOL IsBadCodePtr(FARPROC);
2349 		BOOL IsSystemResumeAutomatic();
2350 		BOOL MapUserPhysicalPages(PVOID, ULONG_PTR, PULONG_PTR);
2351 		BOOL MapUserPhysicalPagesScatter(PVOID*, ULONG_PTR, PULONG_PTR);
2352 		PVOID MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
2353 		PVOID MapViewOfFileEx(HANDLE, DWORD, DWORD, DWORD, DWORD, PVOID);
2354 		HANDLE OpenFileMappingA(DWORD, BOOL, LPCSTR);
2355 		HANDLE OpenFileMappingW(DWORD, BOOL, LPCWSTR);
2356 		BOOL ProcessIdToSessionId(DWORD, DWORD*);
2357 		BOOL QueryInformationJobObject(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
2358 		ULONG RemoveVectoredExceptionHandler(PVOID);
2359 		BOOL ReplaceFileA(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID);
2360 		BOOL ReplaceFileW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID);
2361 		BOOL SetComputerNameExA(COMPUTER_NAME_FORMAT, LPCSTR);
2362 		BOOL SetComputerNameExW(COMPUTER_NAME_FORMAT, LPCWSTR);
2363 		BOOL SetFilePointerEx(HANDLE, LARGE_INTEGER, PLARGE_INTEGER, DWORD);
2364 		BOOL SetInformationJobObject(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD);
2365 		BOOL SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL);
2366 		BOOL SetSystemPowerState(BOOL, BOOL);
2367 		EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE);
2368 		DWORD SetThreadIdealProcessor(HANDLE, DWORD);
2369 		BOOL SetVolumeMountPointA(LPCSTR, LPCSTR);
2370 		BOOL SetVolumeMountPointW(LPCWSTR, LPCWSTR);
2371 		BOOL TerminateJobObject(HANDLE, UINT);
2372 		BOOL UnmapViewOfFile(PVOID);
2373 		BOOL UnregisterWait(HANDLE);
2374 		BOOL UnregisterWaitEx(HANDLE, HANDLE);
2375 		BOOL VerifyVersionInfoA(LPOSVERSIONINFOEXA, DWORD, DWORDLONG);
2376 		BOOL VerifyVersionInfoW(LPOSVERSIONINFOEXW, DWORD, DWORDLONG);
2377 	}
2378 
2379 	static if (_WIN32_WINNT >= 0x501) {
2380 		BOOL ActivateActCtx(HANDLE, ULONG_PTR*);
2381 		void AddRefActCtx(HANDLE);
2382 		BOOL CheckNameLegalDOS8Dot3A(LPCSTR, LPSTR, DWORD, PBOOL, PBOOL);
2383 		BOOL CheckNameLegalDOS8Dot3W(LPCWSTR, LPSTR, DWORD, PBOOL, PBOOL);
2384 		BOOL CheckRemoteDebuggerPresent(HANDLE, PBOOL);
2385 		BOOL ConvertFiberToThread();
2386 		HANDLE CreateActCtxA(PCACTCTXA);
2387 		HANDLE CreateActCtxW(PCACTCTXW);
2388 		HANDLE CreateMemoryResourceNotification(MEMORY_RESOURCE_NOTIFICATION_TYPE);
2389 		BOOL DeactivateActCtx(DWORD, ULONG_PTR);
2390 		BOOL DebugActiveProcessStop(DWORD);
2391 		BOOL DebugBreakProcess(HANDLE);
2392 		BOOL DebugSetProcessKillOnExit(BOOL);
2393 		BOOL FindActCtxSectionGuid(DWORD, const(GUID)*, ULONG, const(GUID)*,
2394 		  PACTCTX_SECTION_KEYED_DATA);
2395 		BOOL FindActCtxSectionStringA(DWORD, const(GUID)*, ULONG, LPCSTR,
2396 		  PACTCTX_SECTION_KEYED_DATA);
2397 		BOOL FindActCtxSectionStringW(DWORD, const(GUID)*, ULONG, LPCWSTR,
2398 		  PACTCTX_SECTION_KEYED_DATA);
2399 		BOOL GetCurrentActCtx(HANDLE*);
2400 		VOID GetNativeSystemInfo(LPSYSTEM_INFO);
2401 		BOOL GetProcessHandleCount(HANDLE, PDWORD);
2402 		BOOL GetSystemRegistryQuota(PDWORD, PDWORD);
2403 		BOOL GetSystemTimes(LPFILETIME, LPFILETIME, LPFILETIME);
2404 		UINT GetSystemWow64DirectoryA(LPSTR, UINT);
2405 		UINT GetSystemWow64DirectoryW(LPWSTR, UINT);
2406 		BOOL GetThreadIOPendingFlag(HANDLE, PBOOL);
2407 		BOOL GetVolumePathNamesForVolumeNameA(LPCSTR, LPSTR, DWORD, PDWORD);
2408 		BOOL GetVolumePathNamesForVolumeNameW(LPCWSTR, LPWSTR, DWORD, PDWORD);
2409 		UINT GetWriteWatch(DWORD, PVOID, SIZE_T, PVOID*, PULONG_PTR, PULONG);
2410 		BOOL HeapQueryInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T);
2411 		BOOL HeapSetInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
2412 		BOOL IsProcessInJob(HANDLE, HANDLE, PBOOL);
2413 		BOOL IsWow64Process(HANDLE, PBOOL);
2414 		BOOL QueryActCtxW(DWORD, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T*);
2415 		BOOL QueryMemoryResourceNotification(HANDLE, PBOOL);
2416 		void ReleaseActCtx(HANDLE);
2417 		UINT ResetWriteWatch(LPVOID, SIZE_T);
2418 		BOOL SetFileShortNameA(HANDLE, LPCSTR);
2419 		BOOL SetFileShortNameW(HANDLE, LPCWSTR);
2420 		BOOL SetFileValidData(HANDLE, LONGLONG);
2421 		BOOL ZombifyActCtx(HANDLE);
2422 	}
2423 
2424 	static if (_WIN32_WINNT >= 0x502) {
2425 		DWORD GetFirmwareEnvironmentVariableA(LPCSTR, LPCSTR, PVOID, DWORD);
2426 		DWORD GetFirmwareEnvironmentVariableW(LPCWSTR, LPCWSTR, PVOID, DWORD);
2427 		DWORD GetDllDirectoryA(DWORD, LPSTR);
2428 		DWORD GetDllDirectoryW(DWORD, LPWSTR);
2429 		DWORD GetThreadId(HANDLE);
2430 		DWORD GetProcessId(HANDLE);
2431 		HANDLE ReOpenFile(HANDLE, DWORD, DWORD, DWORD);
2432 		BOOL SetDllDirectoryA(LPCSTR);
2433 		BOOL SetDllDirectoryW(LPCWSTR);
2434 		BOOL SetFirmwareEnvironmentVariableA(LPCSTR, LPCSTR, PVOID, DWORD);
2435 		BOOL SetFirmwareEnvironmentVariableW(LPCWSTR, LPCWSTR, PVOID, DWORD);
2436 		DWORD WTSGetActiveConsoleSessionId();
2437 		BOOL WTSQueryUserToken(ULONG, PHANDLE);
2438 		
2439 	}
2440 
2441 	// ???
2442 	static if (_WIN32_WINNT >= 0x510) {
2443 		VOID RestoreLastError(DWORD);
2444 	}
2445 }
2446 
2447 mixin DECLARE_AW!("STARTUPINFO");
2448 version (Unicode) {
2449 	//alias STARTUPINFOW STARTUPINFO;
2450 	alias WIN32_FIND_DATAW WIN32_FIND_DATA;
2451 	alias ENUMRESLANGPROCW ENUMRESLANGPROC;
2452 	alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
2453 	alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
2454 	alias AddAtomW AddAtom;
2455 	alias BeginUpdateResourceW BeginUpdateResource;
2456 	alias BuildCommDCBW BuildCommDCB;
2457 	alias BuildCommDCBAndTimeoutsW BuildCommDCBAndTimeouts;
2458 	alias CallNamedPipeW CallNamedPipe;
2459 	alias CommConfigDialogW CommConfigDialog;
2460 	alias CopyFileW CopyFile;
2461 	alias CopyFileExW CopyFileEx;
2462 	alias CreateDirectoryW CreateDirectory;
2463 	alias CreateDirectoryExW CreateDirectoryEx;
2464 	alias CreateEventW CreateEvent;
2465 	alias CreateFileW CreateFile;
2466 	alias CreateMailslotW CreateMailslot;
2467 	alias CreateMutexW CreateMutex;
2468 	alias CreateProcessW CreateProcess;
2469 	alias CreateSemaphoreW CreateSemaphore;
2470 	alias DeleteFileW DeleteFile;
2471 	alias EndUpdateResourceW EndUpdateResource;
2472 	alias EnumResourceLanguagesW EnumResourceLanguages;
2473 	alias EnumResourceNamesW EnumResourceNames;
2474 	alias EnumResourceTypesW EnumResourceTypes;
2475 	alias ExpandEnvironmentStringsW ExpandEnvironmentStrings;
2476 	alias FatalAppExitW FatalAppExit;
2477 	alias FindAtomW FindAtom;
2478 	alias FindFirstChangeNotificationW FindFirstChangeNotification;
2479 	alias FindFirstFileW FindFirstFile;
2480 	alias FindNextFileW FindNextFile;
2481 	alias FindResourceW FindResource;
2482 	alias FindResourceExW FindResourceEx;
2483 	alias FormatMessageW FormatMessage;
2484 	alias FreeEnvironmentStringsW FreeEnvironmentStrings;
2485 	alias GetAtomNameW GetAtomName;
2486 	alias GetCommandLineW GetCommandLine;
2487 	alias GetComputerNameW GetComputerName;
2488 	alias GetCurrentDirectoryW GetCurrentDirectory;
2489 	alias GetDefaultCommConfigW GetDefaultCommConfig;
2490 	alias GetDiskFreeSpaceW GetDiskFreeSpace;
2491 	alias GetDiskFreeSpaceExW GetDiskFreeSpaceEx;
2492 	alias GetDriveTypeW GetDriveType;
2493 	alias GetEnvironmentStringsW GetEnvironmentStrings;
2494 	alias GetEnvironmentVariableW GetEnvironmentVariable;
2495 	alias GetFileAttributesW GetFileAttributes;
2496 	alias GetFullPathNameW GetFullPathName;
2497 	alias GetLogicalDriveStringsW GetLogicalDriveStrings;
2498 	alias GetModuleFileNameW GetModuleFileName;
2499 	alias GetModuleHandleW GetModuleHandle;
2500 	alias GetNamedPipeHandleStateW GetNamedPipeHandleState;
2501 	alias GetPrivateProfileIntW GetPrivateProfileInt;
2502 	alias GetPrivateProfileSectionW GetPrivateProfileSection;
2503 	alias GetPrivateProfileSectionNamesW GetPrivateProfileSectionNames;
2504 	alias GetPrivateProfileStringW GetPrivateProfileString;
2505 	alias GetPrivateProfileStructW GetPrivateProfileStruct;
2506 	alias GetProfileIntW GetProfileInt;
2507 	alias GetProfileSectionW GetProfileSection;
2508 	alias GetProfileStringW GetProfileString;
2509 	alias GetShortPathNameW GetShortPathName;
2510 	alias GetStartupInfoW GetStartupInfo;
2511 	alias GetSystemDirectoryW GetSystemDirectory;
2512 	alias GetTempFileNameW GetTempFileName;
2513 	alias GetTempPathW GetTempPath;
2514 	alias GetUserNameW GetUserName;
2515 	alias GetVersionExW GetVersionEx;
2516 	alias GetVolumeInformationW GetVolumeInformation;
2517 	alias GetWindowsDirectoryW GetWindowsDirectory;
2518 	alias GlobalAddAtomW GlobalAddAtom;
2519 	alias GlobalFindAtomW GlobalFindAtom;
2520 	alias GlobalGetAtomNameW GlobalGetAtomName;
2521 	alias IsBadStringPtrW IsBadStringPtr;
2522 	alias LoadLibraryW LoadLibrary;
2523 	alias LoadLibraryExW LoadLibraryEx;
2524 	alias lstrcatW lstrcat;
2525 	alias lstrcmpW lstrcmp;
2526 	alias lstrcmpiW lstrcmpi;
2527 	alias lstrcpyW lstrcpy;
2528 	alias lstrcpynW lstrcpyn;
2529 	alias lstrlenW lstrlen;
2530 	alias MoveFileW MoveFile;
2531 	alias OpenEventW OpenEvent;
2532 	alias OpenMutexW OpenMutex;
2533 	alias OpenSemaphoreW OpenSemaphore;
2534 	alias OutputDebugStringW OutputDebugString;
2535 	alias RemoveDirectoryW RemoveDirectory;
2536 	alias SearchPathW SearchPath;
2537 	alias SetComputerNameW SetComputerName;
2538 	alias SetCurrentDirectoryW SetCurrentDirectory;
2539 	alias SetDefaultCommConfigW SetDefaultCommConfig;
2540 	alias SetEnvironmentVariableW SetEnvironmentVariable;
2541 	alias SetFileAttributesW SetFileAttributes;
2542 	alias SetVolumeLabelW SetVolumeLabel;
2543 	alias WaitNamedPipeW WaitNamedPipe;
2544 	alias WritePrivateProfileSectionW WritePrivateProfileSection;
2545 	alias WritePrivateProfileStringW WritePrivateProfileString;
2546 	alias WritePrivateProfileStructW WritePrivateProfileStruct;
2547 	alias WriteProfileSectionW WriteProfileSection;
2548 	alias WriteProfileStringW WriteProfileString;
2549 	alias CreateWaitableTimerW CreateWaitableTimer;
2550 	alias GetFileAttributesExW GetFileAttributesEx;
2551 	alias GetLongPathNameW GetLongPathName;
2552 	alias QueryDosDeviceW QueryDosDevice;
2553 
2554 	alias HW_PROFILE_INFOW HW_PROFILE_INFO;
2555 	alias AccessCheckAndAuditAlarmW AccessCheckAndAuditAlarm;
2556 	alias BackupEventLogW BackupEventLog;
2557 	alias ClearEventLogW ClearEventLog;
2558 	alias CreateNamedPipeW CreateNamedPipe;
2559 	alias CreateProcessAsUserW CreateProcessAsUser;
2560 	alias DefineDosDeviceW DefineDosDevice;
2561 	alias FindFirstFileExW FindFirstFileEx;
2562 	alias GetBinaryTypeW GetBinaryType;
2563 	alias GetCompressedFileSizeW GetCompressedFileSize;
2564 	alias GetFileSecurityW GetFileSecurity;
2565 	alias LogonUserW LogonUser;
2566 	alias LookupAccountNameW LookupAccountName;
2567 	alias LookupAccountSidW LookupAccountSid;
2568 	alias LookupPrivilegeDisplayNameW LookupPrivilegeDisplayName;
2569 	alias LookupPrivilegeNameW LookupPrivilegeName;
2570 	alias LookupPrivilegeValueW LookupPrivilegeValue;
2571 	alias MoveFileExW MoveFileEx;
2572 	alias ObjectCloseAuditAlarmW ObjectCloseAuditAlarm;
2573 	alias ObjectDeleteAuditAlarmW ObjectDeleteAuditAlarm;
2574 	alias ObjectOpenAuditAlarmW ObjectOpenAuditAlarm;
2575 	alias ObjectPrivilegeAuditAlarmW ObjectPrivilegeAuditAlarm;
2576 	alias OpenBackupEventLogW OpenBackupEventLog;
2577 	alias OpenEventLogW OpenEventLog;
2578 	alias PrivilegedServiceAuditAlarmW PrivilegedServiceAuditAlarm;
2579 	alias ReadEventLogW ReadEventLog;
2580 	alias RegisterEventSourceW RegisterEventSource;
2581 	alias ReportEventW ReportEvent;
2582 	alias SetFileSecurityW SetFileSecurity;
2583 	alias UpdateResourceW UpdateResource;
2584 
2585 	static if (_WIN32_WINNT >= 0x500) {
2586 		alias CreateFileMappingW CreateFileMapping;
2587 		alias CreateHardLinkW CreateHardLink;
2588 		alias CreateJobObjectW CreateJobObject;
2589 		alias DeleteVolumeMountPointW DeleteVolumeMountPoint;
2590 		alias DnsHostnameToComputerNameW DnsHostnameToComputerName;
2591 		alias EncryptFileW EncryptFile;
2592 		alias FileEncryptionStatusW FileEncryptionStatus;
2593 		alias FindFirstVolumeW FindFirstVolume;
2594 		alias FindFirstVolumeMountPointW FindFirstVolumeMountPoint;
2595 		alias FindNextVolumeW FindNextVolume;
2596 		alias FindNextVolumeMountPointW FindNextVolumeMountPoint;
2597 		alias GetModuleHandleExW GetModuleHandleEx;
2598 		alias GetSystemWindowsDirectoryW GetSystemWindowsDirectory;
2599 		alias GetVolumeNameForVolumeMountPointW GetVolumeNameForVolumeMountPoint;
2600 		alias GetVolumePathNameW GetVolumePathName;
2601 		alias OpenFileMappingW OpenFileMapping;
2602 		alias ReplaceFileW ReplaceFile;
2603 		alias SetVolumeMountPointW SetVolumeMountPoint;
2604 		alias VerifyVersionInfoW VerifyVersionInfo;
2605 	}
2606 
2607 	static if (_WIN32_WINNT >= 0x501) {
2608 		alias ACTCTXW ACTCTX;
2609 		alias CheckNameLegalDOS8Dot3W CheckNameLegalDOS8Dot3;
2610 		alias CreateActCtxW CreateActCtx;
2611 		alias FindActCtxSectionStringW FindActCtxSectionString;
2612 		alias GetSystemWow64DirectoryW GetSystemWow64Directory;
2613 		alias GetVolumePathNamesForVolumeNameW GetVolumePathNamesForVolumeName;
2614 		alias SetFileShortNameW SetFileShortName;
2615 	}
2616 
2617 	static if (_WIN32_WINNT >= 0x502) {
2618 		alias SetFirmwareEnvironmentVariableW SetFirmwareEnvironmentVariable;
2619 		alias SetDllDirectoryW SetDllDirectory;
2620 		alias GetDllDirectoryW GetDllDirectory;
2621 	}
2622 
2623 } else {
2624 	//alias STARTUPINFOA STARTUPINFO;
2625 	alias WIN32_FIND_DATAA WIN32_FIND_DATA;
2626 	alias ENUMRESLANGPROCW ENUMRESLANGPROC;
2627 	alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
2628 	alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
2629 	alias AddAtomA AddAtom;
2630 	alias BeginUpdateResourceA BeginUpdateResource;
2631 	alias BuildCommDCBA BuildCommDCB;
2632 	alias BuildCommDCBAndTimeoutsA BuildCommDCBAndTimeouts;
2633 	alias CallNamedPipeA CallNamedPipe;
2634 	alias CommConfigDialogA CommConfigDialog;
2635 	alias CopyFileA CopyFile;
2636 	alias CopyFileExA CopyFileEx;
2637 	alias CreateDirectoryA CreateDirectory;
2638 	alias CreateDirectoryExA CreateDirectoryEx;
2639 	alias CreateEventA CreateEvent;
2640 	alias CreateFileA CreateFile;
2641 	alias CreateMailslotA CreateMailslot;
2642 	alias CreateMutexA CreateMutex;
2643 	alias CreateProcessA CreateProcess;
2644 	alias CreateSemaphoreA CreateSemaphore;
2645 	alias DeleteFileA DeleteFile;
2646 	alias EndUpdateResourceA EndUpdateResource;
2647 	alias EnumResourceLanguagesA EnumResourceLanguages;
2648 	alias EnumResourceNamesA EnumResourceNames;
2649 	alias EnumResourceTypesA EnumResourceTypes;
2650 	alias ExpandEnvironmentStringsA ExpandEnvironmentStrings;
2651 	alias FatalAppExitA FatalAppExit;
2652 	alias FindAtomA FindAtom;
2653 	alias FindFirstChangeNotificationA FindFirstChangeNotification;
2654 	alias FindFirstFileA FindFirstFile;
2655 	alias FindNextFileA FindNextFile;
2656 	alias FindResourceA FindResource;
2657 	alias FindResourceExA FindResourceEx;
2658 	alias FormatMessageA FormatMessage;
2659 	alias FreeEnvironmentStringsA FreeEnvironmentStrings;
2660 	alias GetAtomNameA GetAtomName;
2661 	alias GetCommandLineA GetCommandLine;
2662 	alias GetComputerNameA GetComputerName;
2663 	alias GetCurrentDirectoryA GetCurrentDirectory;
2664 	alias GetDefaultCommConfigA GetDefaultCommConfig;
2665 	alias GetDiskFreeSpaceA GetDiskFreeSpace;
2666 	alias GetDiskFreeSpaceExA GetDiskFreeSpaceEx;
2667 	alias GetDriveTypeA GetDriveType;
2668 	alias GetEnvironmentVariableA GetEnvironmentVariable;
2669 	alias GetFileAttributesA GetFileAttributes;
2670 	alias GetFullPathNameA GetFullPathName;
2671 	alias GetLogicalDriveStringsA GetLogicalDriveStrings;
2672 	alias GetNamedPipeHandleStateA GetNamedPipeHandleState;
2673 	alias GetModuleHandleA GetModuleHandle;
2674 	alias GetModuleFileNameA GetModuleFileName;
2675 	alias GetPrivateProfileIntA GetPrivateProfileInt;
2676 	alias GetPrivateProfileSectionA GetPrivateProfileSection;
2677 	alias GetPrivateProfileSectionNamesA GetPrivateProfileSectionNames;
2678 	alias GetPrivateProfileStringA GetPrivateProfileString;
2679 	alias GetPrivateProfileStructA GetPrivateProfileStruct;
2680 	alias GetProfileIntA GetProfileInt;
2681 	alias GetProfileSectionA GetProfileSection;
2682 	alias GetProfileStringA GetProfileString;
2683 	alias GetShortPathNameA GetShortPathName;
2684 	alias GetStartupInfoA GetStartupInfo;
2685 	alias GetSystemDirectoryA GetSystemDirectory;
2686 	alias GetTempFileNameA GetTempFileName;
2687 	alias GetTempPathA GetTempPath;
2688 	alias GetUserNameA GetUserName;
2689 	alias GetVersionExA GetVersionEx;
2690 	alias GetVolumeInformationA GetVolumeInformation;
2691 	alias GetWindowsDirectoryA GetWindowsDirectory;
2692 	alias GlobalAddAtomA GlobalAddAtom;
2693 	alias GlobalFindAtomA GlobalFindAtom;
2694 	alias GlobalGetAtomNameA GlobalGetAtomName;
2695 	alias IsBadStringPtrA IsBadStringPtr;
2696 	alias LoadLibraryA LoadLibrary;
2697 	alias LoadLibraryExA LoadLibraryEx;
2698 	alias lstrcatA lstrcat;
2699 	alias lstrcmpA lstrcmp;
2700 	alias lstrcmpiA lstrcmpi;
2701 	alias lstrcpyA lstrcpy;
2702 	alias lstrcpynA lstrcpyn;
2703 	alias lstrlenA lstrlen;
2704 	alias MoveFileA MoveFile;
2705 	alias OpenEventA OpenEvent;
2706 	alias OpenMutexA OpenMutex;
2707 	alias OpenSemaphoreA OpenSemaphore;
2708 	alias OutputDebugStringA OutputDebugString;
2709 	alias RemoveDirectoryA RemoveDirectory;
2710 	alias SearchPathA SearchPath;
2711 	alias SetComputerNameA SetComputerName;
2712 	alias SetCurrentDirectoryA SetCurrentDirectory;
2713 	alias SetDefaultCommConfigA SetDefaultCommConfig;
2714 	alias SetEnvironmentVariableA SetEnvironmentVariable;
2715 	alias SetFileAttributesA SetFileAttributes;
2716 	alias SetVolumeLabelA SetVolumeLabel;
2717 	alias WaitNamedPipeA WaitNamedPipe;
2718 	alias WritePrivateProfileSectionA WritePrivateProfileSection;
2719 	alias WritePrivateProfileStringA WritePrivateProfileString;
2720 	alias WritePrivateProfileStructA WritePrivateProfileStruct;
2721 	alias WriteProfileSectionA WriteProfileSection;
2722 	alias WriteProfileStringA WriteProfileString;
2723 	alias CreateWaitableTimerA CreateWaitableTimer;
2724 	alias GetFileAttributesExA GetFileAttributesEx;
2725 	alias GetLongPathNameA GetLongPathName;
2726 	alias QueryDosDeviceA QueryDosDevice;
2727 
2728 	alias HW_PROFILE_INFOA HW_PROFILE_INFO;
2729 	alias AccessCheckAndAuditAlarmA AccessCheckAndAuditAlarm;
2730 	alias BackupEventLogA BackupEventLog;
2731 	alias ClearEventLogA ClearEventLog;
2732 	alias CreateNamedPipeA CreateNamedPipe;
2733 	alias CreateProcessAsUserA CreateProcessAsUser;
2734 	alias DefineDosDeviceA DefineDosDevice;
2735 	alias FindFirstFileExA FindFirstFileEx;
2736 	alias GetBinaryTypeA GetBinaryType;
2737 	alias GetCompressedFileSizeA GetCompressedFileSize;
2738 	alias GetFileSecurityA GetFileSecurity;
2739 	alias LogonUserA LogonUser;
2740 	alias LookupAccountNameA LookupAccountName;
2741 	alias LookupAccountSidA LookupAccountSid;
2742 	alias LookupPrivilegeDisplayNameA LookupPrivilegeDisplayName;
2743 	alias LookupPrivilegeNameA LookupPrivilegeName;
2744 	alias LookupPrivilegeValueA LookupPrivilegeValue;
2745 	alias MoveFileExA MoveFileEx;
2746 	alias ObjectCloseAuditAlarmA ObjectCloseAuditAlarm;
2747 	alias ObjectDeleteAuditAlarmA ObjectDeleteAuditAlarm;
2748 	alias ObjectOpenAuditAlarmA ObjectOpenAuditAlarm;
2749 	alias ObjectPrivilegeAuditAlarmA ObjectPrivilegeAuditAlarm;
2750 	alias OpenBackupEventLogA OpenBackupEventLog;
2751 	alias OpenEventLogA OpenEventLog;
2752 	alias PrivilegedServiceAuditAlarmA PrivilegedServiceAuditAlarm;
2753 	alias ReadEventLogA ReadEventLog;
2754 	alias RegisterEventSourceA RegisterEventSource;
2755 	alias ReportEventA ReportEvent;
2756 	alias SetFileSecurityA SetFileSecurity;
2757 	alias UpdateResourceA UpdateResource;
2758 
2759 	static if (_WIN32_WINNT >= 0x500) {
2760 		alias CreateFileMappingA CreateFileMapping;
2761 		alias CreateHardLinkA CreateHardLink;
2762 		alias CreateJobObjectA CreateJobObject;
2763 		alias DeleteVolumeMountPointA DeleteVolumeMountPoint;
2764 		alias DnsHostnameToComputerNameA DnsHostnameToComputerName;
2765 		alias EncryptFileA EncryptFile;
2766 		alias FileEncryptionStatusA FileEncryptionStatus;
2767 		alias FindFirstVolumeA FindFirstVolume;
2768 		alias FindFirstVolumeMountPointA FindFirstVolumeMountPoint;
2769 		alias FindNextVolumeA FindNextVolume;
2770 		alias FindNextVolumeMountPointA FindNextVolumeMountPoint;
2771 		alias GetModuleHandleExA GetModuleHandleEx;
2772 		alias GetSystemWindowsDirectoryA GetSystemWindowsDirectory;
2773 		alias GetVolumeNameForVolumeMountPointA GetVolumeNameForVolumeMountPoint;
2774 		alias GetVolumePathNameA GetVolumePathName;
2775 		alias OpenFileMappingA OpenFileMapping;
2776 		alias ReplaceFileA ReplaceFile;
2777 		alias SetVolumeMountPointA SetVolumeMountPoint;
2778 		alias VerifyVersionInfoA VerifyVersionInfo;
2779 	}
2780 
2781 	static if (_WIN32_WINNT >= 0x501) {
2782 		alias ACTCTXA ACTCTX;
2783 		alias CheckNameLegalDOS8Dot3A CheckNameLegalDOS8Dot3;
2784 		alias CreateActCtxA CreateActCtx;
2785 		alias FindActCtxSectionStringA FindActCtxSectionString;
2786 		alias GetSystemWow64DirectoryA GetSystemWow64Directory;
2787 		alias GetVolumePathNamesForVolumeNameA GetVolumePathNamesForVolumeName;
2788 		alias SetFileShortNameA SetFileShortName;
2789 	}
2790 
2791 	static if (_WIN32_WINNT >= 0x502) {
2792 		alias GetDllDirectoryA GetDllDirectory;
2793 		alias SetDllDirectoryA SetDllDirectory;
2794 		alias SetFirmwareEnvironmentVariableA SetFirmwareEnvironmentVariable;
2795 	}
2796 }
2797 
2798 alias STARTUPINFO* LPSTARTUPINFO;
2799 alias WIN32_FIND_DATA* LPWIN32_FIND_DATA;
2800 
2801 alias HW_PROFILE_INFO* LPHW_PROFILE_INFO;
2802 
2803 static if (_WIN32_WINNT >= 0x501) {
2804 	alias ACTCTX* PACTCTX, PCACTCTX;
2805 }