]> git.llucax.com Git - software/druntime.git/blob - import/core/sys/windows/windows.d
Use unix EOL style for makefiles
[software/druntime.git] / import / core / sys / windows / windows.d
1
2 /* Windows is a registered trademark of Microsoft Corporation in the United
3 States and other countries. */
4
5 module core.sys.windows.windows;
6
7 version (Windows)
8 {
9 }
10 else
11 {
12     static assert(0);       // Windows only
13 }
14
15 extern (Windows)
16 {
17     alias uint ULONG;
18     alias ULONG *PULONG;
19     alias ushort USHORT;
20     alias USHORT *PUSHORT;
21     alias ubyte UCHAR;
22     alias UCHAR *PUCHAR;
23     alias char *PSZ;
24     alias wchar WCHAR;
25
26     alias void VOID;
27     alias char CHAR;
28     alias short SHORT;
29     alias int LONG;
30     alias CHAR *LPSTR;
31     alias CHAR *PSTR;
32   version(D_Version2)
33   {
34     mixin("alias const(CHAR) *LPCSTR;");
35     mixin("alias const(CHAR) *PCSTR;");
36   }
37   else
38   {
39     alias CHAR *LPCSTR;
40     alias CHAR *PCSTR;
41   }
42     alias LPSTR LPTCH, PTCH;
43     alias LPSTR PTSTR, LPTSTR;
44     alias LPCSTR LPCTSTR;
45
46     alias WCHAR* LPWSTR;
47   version(D_Version2)
48   {
49     mixin("alias const(WCHAR)* LPCWSTR, PCWSTR;");
50   }
51   else
52   {
53     alias WCHAR* LPCWSTR, PCWSTR;
54   }
55     alias uint DWORD;
56     alias int BOOL;
57     alias ubyte BYTE;
58     alias ushort WORD;
59     alias float FLOAT;
60     alias FLOAT *PFLOAT;
61     alias BOOL *PBOOL;
62     alias BOOL *LPBOOL;
63     alias BYTE *PBYTE;
64     alias BYTE *LPBYTE;
65     alias int *PINT;
66     alias int *LPINT;
67     alias WORD *PWORD;
68     alias WORD *LPWORD;
69     alias int *LPLONG;
70     alias DWORD *PDWORD;
71     alias DWORD *LPDWORD;
72     alias void *LPVOID;
73     alias void *LPCVOID;
74
75     alias int INT;
76     alias uint UINT;
77     alias uint *PUINT;
78
79 // ULONG_PTR must be able to store a pointer as an integral type
80 version(Win64)
81 {
82     alias  long INT_PTR;
83     alias ulong UINT_PTR;
84     alias  long LONG_PTR;
85     alias ulong ULONG_PTR;
86     alias  long * PINT_PTR;
87     alias ulong * PUINT_PTR;
88     alias  long * PLONG_PTR;
89     alias ulong * PULONG_PTR;
90 }
91 version(Windows)
92 {
93     alias  int INT_PTR;
94     alias uint UINT_PTR;
95     alias  int LONG_PTR;
96     alias uint ULONG_PTR;
97     alias  int * PINT_PTR;
98     alias uint * PUINT_PTR;
99     alias  int * PLONG_PTR;
100     alias uint * PULONG_PTR;
101 }
102
103     typedef void *HANDLE;
104     alias void *PVOID;
105     alias HANDLE HGLOBAL;
106     alias HANDLE HLOCAL;
107     alias LONG HRESULT;
108     alias LONG SCODE;
109     alias HANDLE HINSTANCE;
110     alias HINSTANCE HMODULE;
111     alias HANDLE HWND;
112
113     alias HANDLE HGDIOBJ;
114     alias HANDLE HACCEL;
115     alias HANDLE HBITMAP;
116     alias HANDLE HBRUSH;
117     alias HANDLE HCOLORSPACE;
118     alias HANDLE HDC;
119     alias HANDLE HGLRC;
120     alias HANDLE HDESK;
121     alias HANDLE HENHMETAFILE;
122     alias HANDLE HFONT;
123     alias HANDLE HICON;
124     alias HANDLE HMENU;
125     alias HANDLE HMETAFILE;
126     alias HANDLE HPALETTE;
127     alias HANDLE HPEN;
128     alias HANDLE HRGN;
129     alias HANDLE HRSRC;
130     alias HANDLE HSTR;
131     alias HANDLE HTASK;
132     alias HANDLE HWINSTA;
133     alias HANDLE HKL;
134     alias HICON HCURSOR;
135
136     alias HANDLE HKEY;
137     alias HKEY *PHKEY;
138     alias DWORD ACCESS_MASK;
139     alias ACCESS_MASK *PACCESS_MASK;
140     alias ACCESS_MASK REGSAM;
141
142     alias int (*FARPROC)();
143
144     alias UINT WPARAM;
145     alias LONG LPARAM;
146     alias LONG LRESULT;
147
148     alias DWORD   COLORREF;
149     alias DWORD   *LPCOLORREF;
150     alias WORD    ATOM;
151
152 version (0)
153 {   // Properly prototyped versions
154     alias BOOL function(HWND, UINT, WPARAM, LPARAM) DLGPROC;
155     alias VOID function(HWND, UINT, UINT, DWORD) TIMERPROC;
156     alias BOOL function(HDC, LPARAM, int) GRAYSTRINGPROC;
157     alias BOOL function(HWND, LPARAM) WNDENUMPROC;
158     alias LRESULT function(int code, WPARAM wParam, LPARAM lParam) HOOKPROC;
159     alias VOID function(HWND, UINT, DWORD, LRESULT) SENDASYNCPROC;
160     alias BOOL function(HWND, LPCSTR, HANDLE) PROPENUMPROCA;
161     alias BOOL function(HWND, LPCWSTR, HANDLE) PROPENUMPROCW;
162     alias BOOL function(HWND, LPSTR, HANDLE, DWORD) PROPENUMPROCEXA;
163     alias BOOL function(HWND, LPWSTR, HANDLE, DWORD) PROPENUMPROCEXW;
164     alias int function(LPSTR lpch, int ichCurrent, int cch, int code)
165        EDITWORDBREAKPROCA;
166     alias int function(LPWSTR lpch, int ichCurrent, int cch, int code)
167        EDITWORDBREAKPROCW;
168     alias BOOL function(HDC hdc, LPARAM lData, WPARAM wData, int cx, int cy)
169        DRAWSTATEPROC;
170 }
171 else
172 {
173     alias FARPROC DLGPROC;
174     alias FARPROC TIMERPROC;
175     alias FARPROC GRAYSTRINGPROC;
176     alias FARPROC WNDENUMPROC;
177     alias FARPROC HOOKPROC;
178     alias FARPROC SENDASYNCPROC;
179     alias FARPROC EDITWORDBREAKPROCA;
180     alias FARPROC EDITWORDBREAKPROCW;
181     alias FARPROC PROPENUMPROCA;
182     alias FARPROC PROPENUMPROCW;
183     alias FARPROC PROPENUMPROCEXA;
184     alias FARPROC PROPENUMPROCEXW;
185     alias FARPROC DRAWSTATEPROC;
186 }
187
188 extern (D)
189 {
190 WORD HIWORD(int l) { return cast(WORD)((l >> 16) & 0xFFFF); }
191 WORD LOWORD(int l) { return cast(WORD)l; }
192 bool FAILED(int status) { return status < 0; }
193 bool SUCCEEDED(int Status) { return Status >= 0; }
194 }
195
196 enum : int
197 {
198     FALSE = 0,
199     TRUE = 1,
200 }
201
202 enum : uint
203 {
204     MAX_PATH = 260,
205     HINSTANCE_ERROR = 32,
206 }
207
208 enum
209 {
210     ERROR_SUCCESS =                    0,
211     ERROR_INVALID_FUNCTION =           1,
212     ERROR_FILE_NOT_FOUND =             2,
213     ERROR_PATH_NOT_FOUND =             3,
214     ERROR_TOO_MANY_OPEN_FILES =        4,
215     ERROR_ACCESS_DENIED =              5,
216     ERROR_INVALID_HANDLE =             6,
217     ERROR_NO_MORE_FILES =              18,
218     ERROR_MORE_DATA =          234,
219     ERROR_NO_MORE_ITEMS =          259,
220 }
221
222 enum
223 {
224     DLL_PROCESS_ATTACH = 1,
225     DLL_THREAD_ATTACH =  2,
226     DLL_THREAD_DETACH =  3,
227     DLL_PROCESS_DETACH = 0,
228 }
229
230 enum
231 {
232     FILE_BEGIN           = 0,
233     FILE_CURRENT         = 1,
234     FILE_END             = 2,
235 }
236
237 enum : uint
238 {
239     DELETE =                           0x00010000,
240     READ_CONTROL =                     0x00020000,
241     WRITE_DAC =                        0x00040000,
242     WRITE_OWNER =                      0x00080000,
243     SYNCHRONIZE =                      0x00100000,
244
245     STANDARD_RIGHTS_REQUIRED =         0x000F0000,
246     STANDARD_RIGHTS_READ =             READ_CONTROL,
247     STANDARD_RIGHTS_WRITE =            READ_CONTROL,
248     STANDARD_RIGHTS_EXECUTE =          READ_CONTROL,
249     STANDARD_RIGHTS_ALL =              0x001F0000,
250     SPECIFIC_RIGHTS_ALL =              0x0000FFFF,
251     ACCESS_SYSTEM_SECURITY =           0x01000000,
252     MAXIMUM_ALLOWED =                  0x02000000,
253
254     GENERIC_READ                     = 0x80000000,
255     GENERIC_WRITE                    = 0x40000000,
256     GENERIC_EXECUTE                  = 0x20000000,
257     GENERIC_ALL                      = 0x10000000,
258 }
259
260 enum
261 {
262     FILE_SHARE_READ                 = 0x00000001,
263     FILE_SHARE_WRITE                = 0x00000002,
264     FILE_SHARE_DELETE               = 0x00000004,
265     FILE_ATTRIBUTE_READONLY         = 0x00000001,
266     FILE_ATTRIBUTE_HIDDEN           = 0x00000002,
267     FILE_ATTRIBUTE_SYSTEM           = 0x00000004,
268     FILE_ATTRIBUTE_DIRECTORY        = 0x00000010,
269     FILE_ATTRIBUTE_ARCHIVE          = 0x00000020,
270     FILE_ATTRIBUTE_NORMAL           = 0x00000080,
271     FILE_ATTRIBUTE_TEMPORARY        = 0x00000100,
272     FILE_ATTRIBUTE_COMPRESSED       = 0x00000800,
273     FILE_ATTRIBUTE_OFFLINE          = 0x00001000,
274     FILE_NOTIFY_CHANGE_FILE_NAME    = 0x00000001,
275     FILE_NOTIFY_CHANGE_DIR_NAME     = 0x00000002,
276     FILE_NOTIFY_CHANGE_ATTRIBUTES   = 0x00000004,
277     FILE_NOTIFY_CHANGE_SIZE         = 0x00000008,
278     FILE_NOTIFY_CHANGE_LAST_WRITE   = 0x00000010,
279     FILE_NOTIFY_CHANGE_LAST_ACCESS  = 0x00000020,
280     FILE_NOTIFY_CHANGE_CREATION     = 0x00000040,
281     FILE_NOTIFY_CHANGE_SECURITY     = 0x00000100,
282     FILE_ACTION_ADDED               = 0x00000001,
283     FILE_ACTION_REMOVED             = 0x00000002,
284     FILE_ACTION_MODIFIED            = 0x00000003,
285     FILE_ACTION_RENAMED_OLD_NAME    = 0x00000004,
286     FILE_ACTION_RENAMED_NEW_NAME    = 0x00000005,
287     FILE_CASE_SENSITIVE_SEARCH      = 0x00000001,
288     FILE_CASE_PRESERVED_NAMES       = 0x00000002,
289     FILE_UNICODE_ON_DISK            = 0x00000004,
290     FILE_PERSISTENT_ACLS            = 0x00000008,
291     FILE_FILE_COMPRESSION           = 0x00000010,
292     FILE_VOLUME_IS_COMPRESSED       = 0x00008000,
293 }
294
295 enum : DWORD
296 {
297     MAILSLOT_NO_MESSAGE = cast(DWORD)-1,
298     MAILSLOT_WAIT_FOREVER = cast(DWORD)-1,
299 }
300
301 enum : uint
302 {
303     FILE_FLAG_WRITE_THROUGH         = 0x80000000,
304     FILE_FLAG_OVERLAPPED            = 0x40000000,
305     FILE_FLAG_NO_BUFFERING          = 0x20000000,
306     FILE_FLAG_RANDOM_ACCESS         = 0x10000000,
307     FILE_FLAG_SEQUENTIAL_SCAN       = 0x08000000,
308     FILE_FLAG_DELETE_ON_CLOSE       = 0x04000000,
309     FILE_FLAG_BACKUP_SEMANTICS      = 0x02000000,
310     FILE_FLAG_POSIX_SEMANTICS       = 0x01000000,
311 }
312
313 enum
314 {
315     CREATE_NEW          = 1,
316     CREATE_ALWAYS       = 2,
317     OPEN_EXISTING       = 3,
318     OPEN_ALWAYS         = 4,
319     TRUNCATE_EXISTING   = 5,
320 }
321
322 version(D_Version2)
323 {
324     mixin("
325     enum
326     {
327         HANDLE INVALID_HANDLE_VALUE = cast(HANDLE)-1,
328         DWORD INVALID_SET_FILE_POINTER = cast(DWORD)-1,
329         DWORD INVALID_FILE_SIZE = cast(DWORD)0xFFFFFFFF,
330     }");
331 }
332 else
333 {
334     const HANDLE INVALID_HANDLE_VALUE = cast(HANDLE)-1;
335
336     enum : DWORD
337     {
338         INVALID_SET_FILE_POINTER = cast(DWORD)-1,
339         INVALID_FILE_SIZE = cast(DWORD)0xFFFFFFFF,
340     }
341 }
342
343 struct OVERLAPPED {
344     DWORD   Internal;
345     DWORD   InternalHigh;
346     DWORD   Offset;
347     DWORD   OffsetHigh;
348     HANDLE  hEvent;
349 }
350
351 struct SECURITY_ATTRIBUTES {
352     DWORD nLength;
353     void *lpSecurityDescriptor;
354     BOOL bInheritHandle;
355 }
356
357 alias SECURITY_ATTRIBUTES* PSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES;
358
359 struct FILETIME {
360     DWORD dwLowDateTime;
361     DWORD dwHighDateTime;
362 }
363 alias FILETIME* PFILETIME, LPFILETIME;
364
365 struct WIN32_FIND_DATA {
366     DWORD dwFileAttributes;
367     FILETIME ftCreationTime;
368     FILETIME ftLastAccessTime;
369     FILETIME ftLastWriteTime;
370     DWORD nFileSizeHigh;
371     DWORD nFileSizeLow;
372     DWORD dwReserved0;
373     DWORD dwReserved1;
374     char   cFileName[MAX_PATH];
375     char   cAlternateFileName[ 14 ];
376 }
377
378 struct WIN32_FIND_DATAW {
379     DWORD dwFileAttributes;
380     FILETIME ftCreationTime;
381     FILETIME ftLastAccessTime;
382     FILETIME ftLastWriteTime;
383     DWORD nFileSizeHigh;
384     DWORD nFileSizeLow;
385     DWORD dwReserved0;
386     DWORD dwReserved1;
387     wchar  cFileName[ 260  ];
388     wchar  cAlternateFileName[ 14 ];
389 }
390
391 // Critical Section
392
393 struct _LIST_ENTRY
394 {
395     _LIST_ENTRY *Flink;
396     _LIST_ENTRY *Blink;
397 }
398 alias _LIST_ENTRY LIST_ENTRY;
399
400 struct _RTL_CRITICAL_SECTION_DEBUG
401 {
402     WORD   Type;
403     WORD   CreatorBackTraceIndex;
404     _RTL_CRITICAL_SECTION *CriticalSection;
405     LIST_ENTRY ProcessLocksList;
406     DWORD EntryCount;
407     DWORD ContentionCount;
408     DWORD Spare[ 2 ];
409 }
410 alias _RTL_CRITICAL_SECTION_DEBUG RTL_CRITICAL_SECTION_DEBUG;
411
412 struct _RTL_CRITICAL_SECTION
413 {
414     RTL_CRITICAL_SECTION_DEBUG * DebugInfo;
415
416     //
417     //  The following three fields control entering and exiting the critical
418     //  section for the resource
419     //
420
421     LONG LockCount;
422     LONG RecursionCount;
423     HANDLE OwningThread;        // from the thread's ClientId->UniqueThread
424     HANDLE LockSemaphore;
425     ULONG_PTR SpinCount;        // force size on 64-bit systems when packed
426 }
427 alias _RTL_CRITICAL_SECTION CRITICAL_SECTION;
428
429
430 enum
431 {
432     STD_INPUT_HANDLE =    cast(DWORD)-10,
433     STD_OUTPUT_HANDLE =   cast(DWORD)-11,
434     STD_ERROR_HANDLE =    cast(DWORD)-12,
435 }
436
437 export
438 {
439 BOOL SetCurrentDirectoryA(LPCSTR lpPathName);
440 BOOL SetCurrentDirectoryW(LPCWSTR lpPathName);
441 DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer);
442 DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer);
443 BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
444 BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
445 BOOL CreateDirectoryExA(LPCSTR lpTemplateDirectory, LPCSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
446 BOOL CreateDirectoryExW(LPCWSTR lpTemplateDirectory, LPCWSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
447 BOOL RemoveDirectoryA(LPCSTR lpPathName);
448 BOOL RemoveDirectoryW(LPCWSTR lpPathName);
449
450 BOOL   CloseHandle(HANDLE hObject);
451
452 HANDLE CreateFileA(in char* lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
453     SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition,
454     DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
455 HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
456     SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition,
457     DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
458
459 BOOL   DeleteFileA(in char *lpFileName);
460 BOOL   DeleteFileW(LPCWSTR lpFileName);
461
462 BOOL   FindClose(HANDLE hFindFile);
463 HANDLE FindFirstFileA(in char *lpFileName, WIN32_FIND_DATA* lpFindFileData);
464 HANDLE FindFirstFileW(in LPCWSTR lpFileName, WIN32_FIND_DATAW* lpFindFileData);
465 BOOL   FindNextFileA(HANDLE hFindFile, WIN32_FIND_DATA* lpFindFileData);
466 BOOL   FindNextFileW(HANDLE hFindFile, WIN32_FIND_DATAW* lpFindFileData);
467 BOOL   GetExitCodeThread(HANDLE hThread, DWORD *lpExitCode);
468 DWORD  GetLastError();
469 DWORD  GetFileAttributesA(in char *lpFileName);
470 DWORD  GetFileAttributesW(in wchar *lpFileName);
471 DWORD  GetFileSize(HANDLE hFile, DWORD *lpFileSizeHigh);
472 BOOL   CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, BOOL bFailIfExists);
473 BOOL   CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists);
474 BOOL   MoveFileA(in char *from, in char *to);
475 BOOL   MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName);
476 BOOL   ReadFile(HANDLE hFile, void *lpBuffer, DWORD nNumberOfBytesToRead,
477     DWORD *lpNumberOfBytesRead, OVERLAPPED *lpOverlapped);
478 DWORD  SetFilePointer(HANDLE hFile, LONG lDistanceToMove,
479     LONG *lpDistanceToMoveHigh, DWORD dwMoveMethod);
480 BOOL   WriteFile(HANDLE hFile, in void *lpBuffer, DWORD nNumberOfBytesToWrite,
481     DWORD *lpNumberOfBytesWritten, OVERLAPPED *lpOverlapped);
482 DWORD  GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
483 HANDLE GetStdHandle(DWORD nStdHandle);
484 BOOL   SetStdHandle(DWORD nStdHandle, HANDLE hHandle);
485 }
486
487 struct MEMORYSTATUS {
488     DWORD dwLength;
489     DWORD dwMemoryLoad;
490     DWORD dwTotalPhys;
491     DWORD dwAvailPhys;
492     DWORD dwTotalPageFile;
493     DWORD dwAvailPageFile;
494     DWORD dwTotalVirtual;
495     DWORD dwAvailVirtual;
496 };
497 alias MEMORYSTATUS *LPMEMORYSTATUS;
498
499 HMODULE LoadLibraryA(LPCSTR lpLibFileName);
500 FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
501 DWORD GetVersion();
502 BOOL FreeLibrary(HMODULE hLibModule);
503 void FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode);
504 BOOL DisableThreadLibraryCalls(HMODULE hLibModule);
505
506 //
507 // Registry Specific Access Rights.
508 //
509
510 enum
511 {
512     KEY_QUERY_VALUE =         0x0001,
513     KEY_SET_VALUE =           0x0002,
514     KEY_CREATE_SUB_KEY =      0x0004,
515     KEY_ENUMERATE_SUB_KEYS =  0x0008,
516     KEY_NOTIFY =              0x0010,
517     KEY_CREATE_LINK =         0x0020,
518
519     KEY_READ =       cast(int)((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY)   & ~SYNCHRONIZE),
520     KEY_WRITE =      cast(int)((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & ~SYNCHRONIZE),
521     KEY_EXECUTE =    cast(int)(KEY_READ & ~SYNCHRONIZE),
522     KEY_ALL_ACCESS = cast(int)((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & ~SYNCHRONIZE),
523 }
524
525 //
526 // Key creation/open disposition
527 //
528
529 enum : int
530 {
531     REG_CREATED_NEW_KEY =         0x00000001,   // New Registry Key created
532     REG_OPENED_EXISTING_KEY =     0x00000002,   // Existing Key opened
533 }
534
535 //
536 //
537 // Predefined Value Types.
538 //
539 enum
540 {
541     REG_NONE =                    0,   // No value type
542     REG_SZ =                      1,   // Unicode nul terminated string
543     REG_EXPAND_SZ =               2,   // Unicode nul terminated string
544                                             // (with environment variable references)
545     REG_BINARY =                  3,   // Free form binary
546     REG_DWORD =                   4,   // 32-bit number
547     REG_DWORD_LITTLE_ENDIAN =     4,   // 32-bit number (same as REG_DWORD)
548     REG_DWORD_BIG_ENDIAN =        5,   // 32-bit number
549     REG_LINK =                    6,   // Symbolic Link (unicode)
550     REG_MULTI_SZ =                7,   // Multiple Unicode strings
551     REG_RESOURCE_LIST =           8,   // Resource list in the resource map
552     REG_FULL_RESOURCE_DESCRIPTOR = 9,  // Resource list in the hardware description
553     REG_RESOURCE_REQUIREMENTS_LIST = 10,
554     REG_QWORD =         11,
555     REG_QWORD_LITTLE_ENDIAN =   11,
556 }
557
558 /*
559  * MessageBox() Flags
560  */
561 enum
562 {
563     MB_OK =                       0x00000000,
564     MB_OKCANCEL =                 0x00000001,
565     MB_ABORTRETRYIGNORE =         0x00000002,
566     MB_YESNOCANCEL =              0x00000003,
567     MB_YESNO =                    0x00000004,
568     MB_RETRYCANCEL =              0x00000005,
569
570
571     MB_ICONHAND =                 0x00000010,
572     MB_ICONQUESTION =             0x00000020,
573     MB_ICONEXCLAMATION =          0x00000030,
574     MB_ICONASTERISK =             0x00000040,
575
576
577     MB_USERICON =                 0x00000080,
578     MB_ICONWARNING =              MB_ICONEXCLAMATION,
579     MB_ICONERROR =                MB_ICONHAND,
580
581
582     MB_ICONINFORMATION =          MB_ICONASTERISK,
583     MB_ICONSTOP =                 MB_ICONHAND,
584
585     MB_DEFBUTTON1 =               0x00000000,
586     MB_DEFBUTTON2 =               0x00000100,
587     MB_DEFBUTTON3 =               0x00000200,
588
589     MB_DEFBUTTON4 =               0x00000300,
590
591
592     MB_APPLMODAL =                0x00000000,
593     MB_SYSTEMMODAL =              0x00001000,
594     MB_TASKMODAL =                0x00002000,
595
596     MB_HELP =                     0x00004000, // Help Button
597
598
599     MB_NOFOCUS =                  0x00008000,
600     MB_SETFOREGROUND =            0x00010000,
601     MB_DEFAULT_DESKTOP_ONLY =     0x00020000,
602
603
604     MB_TOPMOST =                  0x00040000,
605     MB_RIGHT =                    0x00080000,
606     MB_RTLREADING =               0x00100000,
607
608
609     MB_TYPEMASK =                 0x0000000F,
610     MB_ICONMASK =                 0x000000F0,
611     MB_DEFMASK =                  0x00000F00,
612     MB_MODEMASK =                 0x00003000,
613     MB_MISCMASK =                 0x0000C000,
614 }
615
616
617 int MessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
618 int MessageBoxExA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, WORD wLanguageId);
619
620 version(D_Version2)
621 {
622     mixin("
623     enum : HKEY
624     {
625         HKEY_CLASSES_ROOT =           cast(HKEY)(0x80000000),
626         HKEY_CURRENT_USER =           cast(HKEY)(0x80000001),
627         HKEY_LOCAL_MACHINE =          cast(HKEY)(0x80000002),
628         HKEY_USERS =                  cast(HKEY)(0x80000003),
629         HKEY_PERFORMANCE_DATA =       cast(HKEY)(0x80000004),
630         HKEY_PERFORMANCE_TEXT =       cast(HKEY)(0x80000050),
631         HKEY_PERFORMANCE_NLSTEXT =    cast(HKEY)(0x80000060),
632         HKEY_CURRENT_CONFIG =         cast(HKEY)(0x80000005),
633         HKEY_DYN_DATA =               cast(HKEY)(0x80000006),
634     }");
635 }
636 else
637 {
638     const HKEY_CLASSES_ROOT =           cast(HKEY)(0x80000000);
639     const HKEY_CURRENT_USER =           cast(HKEY)(0x80000001);
640     const HKEY_LOCAL_MACHINE =          cast(HKEY)(0x80000002);
641     const HKEY_USERS =                  cast(HKEY)(0x80000003);
642     const HKEY_PERFORMANCE_DATA =       cast(HKEY)(0x80000004);
643     const HKEY_PERFORMANCE_TEXT =       cast(HKEY)(0x80000050);
644     const HKEY_PERFORMANCE_NLSTEXT =    cast(HKEY)(0x80000060);
645     const HKEY_CURRENT_CONFIG =         cast(HKEY)(0x80000005);
646     const HKEY_DYN_DATA =               cast(HKEY)(0x80000006);
647 }
648
649
650 enum
651 {
652     REG_OPTION_RESERVED =         (0x00000000),   // Parameter is reserved
653
654     REG_OPTION_NON_VOLATILE =     (0x00000000),   // Key is preserved
655                                                     // when system is rebooted
656
657     REG_OPTION_VOLATILE =         (0x00000001),   // Key is not preserved
658                                                     // when system is rebooted
659
660     REG_OPTION_CREATE_LINK =      (0x00000002),   // Created key is a
661                                                     // symbolic link
662
663     REG_OPTION_BACKUP_RESTORE =   (0x00000004),   // open for backup or restore
664                                                     // special access rules
665                                                     // privilege required
666
667     REG_OPTION_OPEN_LINK =        (0x00000008),   // Open symbolic link
668
669     REG_LEGAL_OPTION = (REG_OPTION_RESERVED | REG_OPTION_NON_VOLATILE | REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK),
670 }
671
672 export LONG RegDeleteKeyA(HKEY hKey, LPCSTR lpSubKey);
673 export LONG RegDeleteValueA(HKEY hKey, LPCSTR lpValueName);
674
675 export LONG  RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName, LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass, FILETIME* lpftLastWriteTime);
676 export LONG RegEnumValueA(HKEY hKey, DWORD dwIndex, LPSTR lpValueName, LPDWORD lpcbValueName, LPDWORD lpReserved,
677     LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
678
679 export LONG RegCloseKey(HKEY hKey);
680 export LONG RegFlushKey(HKEY hKey);
681
682 export LONG RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult);
683 export LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
684
685 export LONG RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcbClass,
686     LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcbMaxSubKeyLen, LPDWORD lpcbMaxClassLen,
687     LPDWORD lpcValues, LPDWORD lpcbMaxValueNameLen, LPDWORD lpcbMaxValueLen, LPDWORD lpcbSecurityDescriptor,
688     PFILETIME lpftLastWriteTime);
689
690 export LONG RegQueryValueA(HKEY hKey, LPCSTR lpSubKey, LPSTR lpValue,
691     LPLONG lpcbValue);
692
693 export LONG RegCreateKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass,
694    DWORD dwOptions, REGSAM samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes,
695     PHKEY phkResult, LPDWORD lpdwDisposition);
696
697 export LONG RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, BYTE* lpData, DWORD cbData);
698
699 struct MEMORY_BASIC_INFORMATION {
700     PVOID BaseAddress;
701     PVOID AllocationBase;
702     DWORD AllocationProtect;
703     DWORD RegionSize;
704     DWORD State;
705     DWORD Protect;
706     DWORD Type;
707 }
708 alias MEMORY_BASIC_INFORMATION* PMEMORY_BASIC_INFORMATION;
709
710 enum
711 {
712     SECTION_QUERY       = 0x0001,
713     SECTION_MAP_WRITE   = 0x0002,
714     SECTION_MAP_READ    = 0x0004,
715     SECTION_MAP_EXECUTE = 0x0008,
716     SECTION_EXTEND_SIZE = 0x0010,
717
718     SECTION_ALL_ACCESS = cast(int)(STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE),
719     PAGE_NOACCESS          = 0x01,
720     PAGE_READONLY          = 0x02,
721     PAGE_READWRITE         = 0x04,
722     PAGE_WRITECOPY         = 0x08,
723     PAGE_EXECUTE           = 0x10,
724     PAGE_EXECUTE_READ      = 0x20,
725     PAGE_EXECUTE_READWRITE = 0x40,
726     PAGE_EXECUTE_WRITECOPY = 0x80,
727     PAGE_GUARD            = 0x100,
728     PAGE_NOCACHE          = 0x200,
729     MEM_COMMIT           = 0x1000,
730     MEM_RESERVE          = 0x2000,
731     MEM_DECOMMIT         = 0x4000,
732     MEM_RELEASE          = 0x8000,
733     MEM_FREE            = 0x10000,
734     MEM_PRIVATE         = 0x20000,
735     MEM_MAPPED          = 0x40000,
736     MEM_RESET           = 0x80000,
737     MEM_TOP_DOWN       = 0x100000,
738     SEC_FILE           = 0x800000,
739     SEC_IMAGE         = 0x1000000,
740     SEC_RESERVE       = 0x4000000,
741     SEC_COMMIT        = 0x8000000,
742     SEC_NOCACHE      = 0x10000000,
743     MEM_IMAGE        = SEC_IMAGE,
744 }
745
746 enum
747 {
748     FILE_MAP_COPY =       SECTION_QUERY,
749     FILE_MAP_WRITE =      SECTION_MAP_WRITE,
750     FILE_MAP_READ =       SECTION_MAP_READ,
751     FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS,
752 }
753
754
755 //
756 // Define access rights to files and directories
757 //
758
759 //
760 // The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in
761 // devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these
762 // constants *MUST* always be in sync.
763 // The values are redefined in devioctl.h because they must be available to
764 // both DOS and NT.
765 //
766
767 enum
768 {
769     FILE_READ_DATA =            ( 0x0001 ),   // file & pipe
770     FILE_LIST_DIRECTORY =       ( 0x0001 ),    // directory
771
772     FILE_WRITE_DATA =           ( 0x0002 ),    // file & pipe
773     FILE_ADD_FILE =             ( 0x0002 ),    // directory
774
775     FILE_APPEND_DATA =          ( 0x0004 ),    // file
776     FILE_ADD_SUBDIRECTORY =     ( 0x0004 ),    // directory
777     FILE_CREATE_PIPE_INSTANCE = ( 0x0004 ),    // named pipe
778
779     FILE_READ_EA =              ( 0x0008 ),    // file & directory
780
781     FILE_WRITE_EA =             ( 0x0010 ),    // file & directory
782
783     FILE_EXECUTE =              ( 0x0020 ),    // file
784     FILE_TRAVERSE =             ( 0x0020 ),    // directory
785
786     FILE_DELETE_CHILD =         ( 0x0040 ),    // directory
787
788     FILE_READ_ATTRIBUTES =      ( 0x0080 ),    // all
789
790     FILE_WRITE_ATTRIBUTES =     ( 0x0100 ),    // all
791
792     FILE_ALL_ACCESS =       cast(int)(STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF),
793
794     FILE_GENERIC_READ =         cast(int)(STANDARD_RIGHTS_READ  | FILE_READ_DATA |  FILE_READ_ATTRIBUTES |                 FILE_READ_EA |  SYNCHRONIZE),
795
796     FILE_GENERIC_WRITE =        cast(int)(STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |  FILE_WRITE_ATTRIBUTES |                      FILE_WRITE_EA  |  FILE_APPEND_DATA |  SYNCHRONIZE),
797
798     FILE_GENERIC_EXECUTE =      cast(int)(STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES |                 FILE_EXECUTE |  SYNCHRONIZE),
799 }
800
801 export
802 {
803  BOOL  FreeResource(HGLOBAL hResData);
804  LPVOID LockResource(HGLOBAL hResData);
805  BOOL GlobalUnlock(HGLOBAL hMem);
806  HGLOBAL GlobalFree(HGLOBAL hMem);
807  UINT GlobalCompact(DWORD dwMinFree);
808  void GlobalFix(HGLOBAL hMem);
809  void GlobalUnfix(HGLOBAL hMem);
810  LPVOID GlobalWire(HGLOBAL hMem);
811  BOOL GlobalUnWire(HGLOBAL hMem);
812  void GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer);
813  HLOCAL LocalAlloc(UINT uFlags, UINT uBytes);
814  HLOCAL LocalReAlloc(HLOCAL hMem, UINT uBytes, UINT uFlags);
815  LPVOID LocalLock(HLOCAL hMem);
816  HLOCAL LocalHandle(LPCVOID pMem);
817  BOOL LocalUnlock(HLOCAL hMem);
818  UINT LocalSize(HLOCAL hMem);
819  UINT LocalFlags(HLOCAL hMem);
820  HLOCAL LocalFree(HLOCAL hMem);
821  UINT LocalShrink(HLOCAL hMem, UINT cbNewSize);
822  UINT LocalCompact(UINT uMinFree);
823  BOOL FlushInstructionCache(HANDLE hProcess, LPCVOID lpBaseAddress, DWORD dwSize);
824  LPVOID VirtualAlloc(LPVOID lpAddress, DWORD dwSize, DWORD flAllocationType, DWORD flProtect);
825  BOOL VirtualFree(LPVOID lpAddress, DWORD dwSize, DWORD dwFreeType);
826  BOOL VirtualProtect(LPVOID lpAddress, DWORD dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
827  DWORD VirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, DWORD dwLength);
828  LPVOID VirtualAllocEx(HANDLE hProcess, LPVOID lpAddress, DWORD dwSize, DWORD flAllocationType, DWORD flProtect);
829  BOOL VirtualFreeEx(HANDLE hProcess, LPVOID lpAddress, DWORD dwSize, DWORD dwFreeType);
830  BOOL VirtualProtectEx(HANDLE hProcess, LPVOID lpAddress, DWORD dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
831  DWORD VirtualQueryEx(HANDLE hProcess, LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, DWORD dwLength);
832 }
833
834 struct SYSTEMTIME
835 {
836     WORD wYear;
837     WORD wMonth;
838     WORD wDayOfWeek;
839     WORD wDay;
840     WORD wHour;
841     WORD wMinute;
842     WORD wSecond;
843     WORD wMilliseconds;
844 }
845
846 struct TIME_ZONE_INFORMATION {
847     LONG Bias;
848     WCHAR StandardName[ 32 ];
849     SYSTEMTIME StandardDate;
850     LONG StandardBias;
851     WCHAR DaylightName[ 32 ];
852     SYSTEMTIME DaylightDate;
853     LONG DaylightBias;
854 }
855
856 enum
857 {
858     TIME_ZONE_ID_UNKNOWN =  0,
859     TIME_ZONE_ID_STANDARD = 1,
860     TIME_ZONE_ID_DAYLIGHT = 2,
861 }
862
863 export void GetSystemTime(SYSTEMTIME* lpSystemTime);
864 export void GetSystemTimeAsFileTime(FILETIME* lpSystemTimeAsFileTime);
865 export BOOL SetSystemTime(SYSTEMTIME* lpSystemTime);
866 export void GetLocalTime(SYSTEMTIME* lpSystemTime);
867 export BOOL SetLocalTime(SYSTEMTIME* lpSystemTime);
868 export BOOL SystemTimeToTzSpecificLocalTime(TIME_ZONE_INFORMATION* lpTimeZoneInformation, SYSTEMTIME* lpUniversalTime, SYSTEMTIME* lpLocalTime);
869 export DWORD GetTimeZoneInformation(TIME_ZONE_INFORMATION* lpTimeZoneInformation);
870 export BOOL SetTimeZoneInformation(TIME_ZONE_INFORMATION* lpTimeZoneInformation);
871
872 export BOOL SystemTimeToFileTime(in SYSTEMTIME *lpSystemTime, FILETIME* lpFileTime);
873 export BOOL FileTimeToLocalFileTime(in FILETIME *lpFileTime, FILETIME* lpLocalFileTime);
874 export BOOL LocalFileTimeToFileTime(in FILETIME *lpLocalFileTime, FILETIME* lpFileTime);
875 export BOOL FileTimeToSystemTime(in FILETIME *lpFileTime, SYSTEMTIME* lpSystemTime);
876 export LONG CompareFileTime(in FILETIME *lpFileTime1, in FILETIME *lpFileTime2);
877 export BOOL FileTimeToDosDateTime(in FILETIME *lpFileTime, WORD* lpFatDate, WORD* lpFatTime);
878 export BOOL DosDateTimeToFileTime(WORD wFatDate, WORD wFatTime, FILETIME* lpFileTime);
879 export DWORD GetTickCount();
880 export BOOL SetSystemTimeAdjustment(DWORD dwTimeAdjustment, BOOL bTimeAdjustmentDisabled);
881 export BOOL GetSystemTimeAdjustment(DWORD* lpTimeAdjustment, DWORD* lpTimeIncrement, BOOL* lpTimeAdjustmentDisabled);
882 export DWORD FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, void* *Arguments);export DWORD FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, void* *Arguments);
883
884 enum
885 {
886     FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100,
887     FORMAT_MESSAGE_IGNORE_INSERTS =  0x00000200,
888     FORMAT_MESSAGE_FROM_STRING =     0x00000400,
889     FORMAT_MESSAGE_FROM_HMODULE =    0x00000800,
890     FORMAT_MESSAGE_FROM_SYSTEM =     0x00001000,
891     FORMAT_MESSAGE_ARGUMENT_ARRAY =  0x00002000,
892     FORMAT_MESSAGE_MAX_WIDTH_MASK =  0x000000FF,
893 };
894
895
896 //
897 //  Language IDs.
898 //
899 //  The following two combinations of primary language ID and
900 //  sublanguage ID have special semantics:
901 //
902 //    Primary Language ID   Sublanguage ID      Result
903 //    -------------------   ---------------     ------------------------
904 //    LANG_NEUTRAL          SUBLANG_NEUTRAL     Language neutral
905 //    LANG_NEUTRAL          SUBLANG_DEFAULT     User default language
906 //    LANG_NEUTRAL          SUBLANG_SYS_DEFAULT System default language
907 //
908
909 //
910 //  Primary language IDs.
911 //
912
913 enum
914 {
915     LANG_NEUTRAL                     = 0x00,
916
917     LANG_AFRIKAANS                   = 0x36,
918     LANG_ALBANIAN                    = 0x1c,
919     LANG_ARABIC                      = 0x01,
920     LANG_BASQUE                      = 0x2d,
921     LANG_BELARUSIAN                  = 0x23,
922     LANG_BULGARIAN                   = 0x02,
923     LANG_CATALAN                     = 0x03,
924     LANG_CHINESE                     = 0x04,
925     LANG_CROATIAN                    = 0x1a,
926     LANG_CZECH                       = 0x05,
927     LANG_DANISH                      = 0x06,
928     LANG_DUTCH                       = 0x13,
929     LANG_ENGLISH                     = 0x09,
930     LANG_ESTONIAN                    = 0x25,
931     LANG_FAEROESE                    = 0x38,
932     LANG_FARSI                       = 0x29,
933     LANG_FINNISH                     = 0x0b,
934     LANG_FRENCH                      = 0x0c,
935     LANG_GERMAN                      = 0x07,
936     LANG_GREEK                       = 0x08,
937     LANG_HEBREW                      = 0x0d,
938     LANG_HUNGARIAN                   = 0x0e,
939     LANG_ICELANDIC                   = 0x0f,
940     LANG_INDONESIAN                  = 0x21,
941     LANG_ITALIAN                     = 0x10,
942     LANG_JAPANESE                    = 0x11,
943     LANG_KOREAN                      = 0x12,
944     LANG_LATVIAN                     = 0x26,
945     LANG_LITHUANIAN                  = 0x27,
946     LANG_NORWEGIAN                   = 0x14,
947     LANG_POLISH                      = 0x15,
948     LANG_PORTUGUESE                  = 0x16,
949     LANG_ROMANIAN                    = 0x18,
950     LANG_RUSSIAN                     = 0x19,
951     LANG_SERBIAN                     = 0x1a,
952     LANG_SLOVAK                      = 0x1b,
953     LANG_SLOVENIAN                   = 0x24,
954     LANG_SPANISH                     = 0x0a,
955     LANG_SWEDISH                     = 0x1d,
956     LANG_THAI                        = 0x1e,
957     LANG_TURKISH                     = 0x1f,
958     LANG_UKRAINIAN                   = 0x22,
959     LANG_VIETNAMESE                  = 0x2a,
960 }
961 //
962 //  Sublanguage IDs.
963 //
964 //  The name immediately following SUBLANG_ dictates which primary
965 //  language ID that sublanguage ID can be combined with to form a
966 //  valid language ID.
967 //
968 enum
969 {
970     SUBLANG_NEUTRAL =                  0x00,    // language neutral
971     SUBLANG_DEFAULT =                  0x01,    // user default
972     SUBLANG_SYS_DEFAULT =              0x02,    // system default
973
974     SUBLANG_ARABIC_SAUDI_ARABIA =      0x01,    // Arabic (Saudi Arabia)
975     SUBLANG_ARABIC_IRAQ =              0x02,    // Arabic (Iraq)
976     SUBLANG_ARABIC_EGYPT =             0x03,    // Arabic (Egypt)
977     SUBLANG_ARABIC_LIBYA =             0x04,    // Arabic (Libya)
978     SUBLANG_ARABIC_ALGERIA =           0x05,    // Arabic (Algeria)
979     SUBLANG_ARABIC_MOROCCO =           0x06,    // Arabic (Morocco)
980     SUBLANG_ARABIC_TUNISIA =           0x07,    // Arabic (Tunisia)
981     SUBLANG_ARABIC_OMAN =              0x08,    // Arabic (Oman)
982     SUBLANG_ARABIC_YEMEN =             0x09,    // Arabic (Yemen)
983     SUBLANG_ARABIC_SYRIA =             0x0a,    // Arabic (Syria)
984     SUBLANG_ARABIC_JORDAN =            0x0b,    // Arabic (Jordan)
985     SUBLANG_ARABIC_LEBANON =           0x0c,    // Arabic (Lebanon)
986     SUBLANG_ARABIC_KUWAIT =            0x0d,    // Arabic (Kuwait)
987     SUBLANG_ARABIC_UAE =               0x0e,    // Arabic (U.A.E)
988     SUBLANG_ARABIC_BAHRAIN =           0x0f,    // Arabic (Bahrain)
989     SUBLANG_ARABIC_QATAR =             0x10,    // Arabic (Qatar)
990     SUBLANG_CHINESE_TRADITIONAL =      0x01,    // Chinese (Taiwan)
991     SUBLANG_CHINESE_SIMPLIFIED =       0x02,    // Chinese (PR China)
992     SUBLANG_CHINESE_HONGKONG =         0x03,    // Chinese (Hong Kong)
993     SUBLANG_CHINESE_SINGAPORE =        0x04,    // Chinese (Singapore)
994     SUBLANG_DUTCH =                    0x01,    // Dutch
995     SUBLANG_DUTCH_BELGIAN =            0x02,    // Dutch (Belgian)
996     SUBLANG_ENGLISH_US =               0x01,    // English (USA)
997     SUBLANG_ENGLISH_UK =               0x02,    // English (UK)
998     SUBLANG_ENGLISH_AUS =              0x03,    // English (Australian)
999     SUBLANG_ENGLISH_CAN =              0x04,    // English (Canadian)
1000     SUBLANG_ENGLISH_NZ =               0x05,    // English (New Zealand)
1001     SUBLANG_ENGLISH_EIRE =             0x06,    // English (Irish)
1002     SUBLANG_ENGLISH_SOUTH_AFRICA =     0x07,    // English (South Africa)
1003     SUBLANG_ENGLISH_JAMAICA =          0x08,    // English (Jamaica)
1004     SUBLANG_ENGLISH_CARIBBEAN =        0x09,    // English (Caribbean)
1005     SUBLANG_ENGLISH_BELIZE =           0x0a,    // English (Belize)
1006     SUBLANG_ENGLISH_TRINIDAD =         0x0b,    // English (Trinidad)
1007     SUBLANG_FRENCH =                   0x01,    // French
1008     SUBLANG_FRENCH_BELGIAN =           0x02,    // French (Belgian)
1009     SUBLANG_FRENCH_CANADIAN =          0x03,    // French (Canadian)
1010     SUBLANG_FRENCH_SWISS =             0x04,    // French (Swiss)
1011     SUBLANG_FRENCH_LUXEMBOURG =        0x05,    // French (Luxembourg)
1012     SUBLANG_GERMAN =                   0x01,    // German
1013     SUBLANG_GERMAN_SWISS =             0x02,    // German (Swiss)
1014     SUBLANG_GERMAN_AUSTRIAN =          0x03,    // German (Austrian)
1015     SUBLANG_GERMAN_LUXEMBOURG =        0x04,    // German (Luxembourg)
1016     SUBLANG_GERMAN_LIECHTENSTEIN =     0x05,    // German (Liechtenstein)
1017     SUBLANG_ITALIAN =                  0x01,    // Italian
1018     SUBLANG_ITALIAN_SWISS =            0x02,    // Italian (Swiss)
1019     SUBLANG_KOREAN =                   0x01,    // Korean (Extended Wansung)
1020     SUBLANG_KOREAN_JOHAB =             0x02,    // Korean (Johab)
1021     SUBLANG_NORWEGIAN_BOKMAL =         0x01,    // Norwegian (Bokmal)
1022     SUBLANG_NORWEGIAN_NYNORSK =        0x02,    // Norwegian (Nynorsk)
1023     SUBLANG_PORTUGUESE =               0x02,    // Portuguese
1024     SUBLANG_PORTUGUESE_BRAZILIAN =     0x01,    // Portuguese (Brazilian)
1025     SUBLANG_SERBIAN_LATIN =            0x02,    // Serbian (Latin)
1026     SUBLANG_SERBIAN_CYRILLIC =         0x03,    // Serbian (Cyrillic)
1027     SUBLANG_SPANISH =                  0x01,    // Spanish (Castilian)
1028     SUBLANG_SPANISH_MEXICAN =          0x02,    // Spanish (Mexican)
1029     SUBLANG_SPANISH_MODERN =           0x03,    // Spanish (Modern)
1030     SUBLANG_SPANISH_GUATEMALA =        0x04,    // Spanish (Guatemala)
1031     SUBLANG_SPANISH_COSTA_RICA =       0x05,    // Spanish (Costa Rica)
1032     SUBLANG_SPANISH_PANAMA =           0x06,    // Spanish (Panama)
1033     SUBLANG_SPANISH_DOMINICAN_REPUBLIC = 0x07,  // Spanish (Dominican Republic)
1034     SUBLANG_SPANISH_VENEZUELA =        0x08,    // Spanish (Venezuela)
1035     SUBLANG_SPANISH_COLOMBIA =         0x09,    // Spanish (Colombia)
1036     SUBLANG_SPANISH_PERU =             0x0a,    // Spanish (Peru)
1037     SUBLANG_SPANISH_ARGENTINA =        0x0b,    // Spanish (Argentina)
1038     SUBLANG_SPANISH_ECUADOR =          0x0c,    // Spanish (Ecuador)
1039     SUBLANG_SPANISH_CHILE =            0x0d,    // Spanish (Chile)
1040     SUBLANG_SPANISH_URUGUAY =          0x0e,    // Spanish (Uruguay)
1041     SUBLANG_SPANISH_PARAGUAY =         0x0f,    // Spanish (Paraguay)
1042     SUBLANG_SPANISH_BOLIVIA =          0x10,    // Spanish (Bolivia)
1043     SUBLANG_SPANISH_EL_SALVADOR =      0x11,    // Spanish (El Salvador)
1044     SUBLANG_SPANISH_HONDURAS =         0x12,    // Spanish (Honduras)
1045     SUBLANG_SPANISH_NICARAGUA =        0x13,    // Spanish (Nicaragua)
1046     SUBLANG_SPANISH_PUERTO_RICO =      0x14,    // Spanish (Puerto Rico)
1047     SUBLANG_SWEDISH =                  0x01,    // Swedish
1048     SUBLANG_SWEDISH_FINLAND =          0x02,    // Swedish (Finland)
1049 }
1050 //
1051 //  Sorting IDs.
1052 //
1053
1054 enum
1055 {
1056     SORT_DEFAULT                   = 0x0,    // sorting default
1057
1058     SORT_JAPANESE_XJIS             = 0x0,    // Japanese XJIS order
1059     SORT_JAPANESE_UNICODE          = 0x1,    // Japanese Unicode order
1060
1061     SORT_CHINESE_BIG5              = 0x0,    // Chinese BIG5 order
1062     SORT_CHINESE_PRCP              = 0x0,    // PRC Chinese Phonetic order
1063     SORT_CHINESE_UNICODE           = 0x1,    // Chinese Unicode order
1064     SORT_CHINESE_PRC               = 0x2,    // PRC Chinese Stroke Count order
1065
1066     SORT_KOREAN_KSC                = 0x0,    // Korean KSC order
1067     SORT_KOREAN_UNICODE            = 0x1,    // Korean Unicode order
1068
1069     SORT_GERMAN_PHONE_BOOK         = 0x1,    // German Phone Book order
1070 }
1071
1072 // end_r_winnt
1073
1074 //
1075 //  A language ID is a 16 bit value which is the combination of a
1076 //  primary language ID and a secondary language ID.  The bits are
1077 //  allocated as follows:
1078 //
1079 //       +-----------------------+-------------------------+
1080 //       |     Sublanguage ID    |   Primary Language ID   |
1081 //       +-----------------------+-------------------------+
1082 //        15                   10 9                       0   bit
1083 //
1084 //
1085 //  Language ID creation/extraction macros:
1086 //
1087 //    MAKELANGID    - construct language id from a primary language id and
1088 //                    a sublanguage id.
1089 //    PRIMARYLANGID - extract primary language id from a language id.
1090 //    SUBLANGID     - extract sublanguage id from a language id.
1091 //
1092
1093 int MAKELANGID(int p, int s) { return ((cast(WORD)s) << 10) | cast(WORD)p; }
1094 WORD PRIMARYLANGID(int lgid) { return cast(WORD)(lgid & 0x3ff); }
1095 WORD SUBLANGID(int lgid)     { return cast(WORD)(lgid >> 10); }
1096
1097
1098 struct FLOATING_SAVE_AREA {
1099     DWORD   ControlWord;
1100     DWORD   StatusWord;
1101     DWORD   TagWord;
1102     DWORD   ErrorOffset;
1103     DWORD   ErrorSelector;
1104     DWORD   DataOffset;
1105     DWORD   DataSelector;
1106     BYTE    RegisterArea[80 ];
1107     DWORD   Cr0NpxState;
1108 }
1109
1110 enum
1111 {
1112     SIZE_OF_80387_REGISTERS =      80,
1113 //
1114 // The following flags control the contents of the CONTEXT structure.
1115 //
1116     CONTEXT_i386 =    0x00010000,    // this assumes that i386 and
1117     CONTEXT_i486 =    0x00010000,    // i486 have identical context records
1118
1119     CONTEXT_CONTROL =         (CONTEXT_i386 | 0x00000001), // SS:SP, CS:IP, FLAGS, BP
1120     CONTEXT_INTEGER =         (CONTEXT_i386 | 0x00000002), // AX, BX, CX, DX, SI, DI
1121     CONTEXT_SEGMENTS =        (CONTEXT_i386 | 0x00000004), // DS, ES, FS, GS
1122     CONTEXT_FLOATING_POINT =  (CONTEXT_i386 | 0x00000008), // 387 state
1123     CONTEXT_DEBUG_REGISTERS = (CONTEXT_i386 | 0x00000010), // DB 0-3,6,7
1124
1125     CONTEXT_FULL = (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS),
1126 }
1127
1128 struct CONTEXT
1129 {
1130
1131     //
1132     // The flags values within this flag control the contents of
1133     // a CONTEXT record.
1134     //
1135     // If the context record is used as an input parameter, then
1136     // for each portion of the context record controlled by a flag
1137     // whose value is set, it is assumed that that portion of the
1138     // context record contains valid context. If the context record
1139     // is being used to modify a threads context, then only that
1140     // portion of the threads context will be modified.
1141     //
1142     // If the context record is used as an IN OUT parameter to capture
1143     // the context of a thread, then only those portions of the thread's
1144     // context corresponding to set flags will be returned.
1145     //
1146     // The context record is never used as an OUT only parameter.
1147     //
1148
1149     DWORD ContextFlags;
1150
1151     //
1152     // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
1153     // set in ContextFlags.  Note that CONTEXT_DEBUG_REGISTERS is NOT
1154     // included in CONTEXT_FULL.
1155     //
1156
1157     DWORD   Dr0;
1158     DWORD   Dr1;
1159     DWORD   Dr2;
1160     DWORD   Dr3;
1161     DWORD   Dr6;
1162     DWORD   Dr7;
1163
1164     //
1165     // This section is specified/returned if the
1166     // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
1167     //
1168
1169     FLOATING_SAVE_AREA FloatSave;
1170
1171     //
1172     // This section is specified/returned if the
1173     // ContextFlags word contians the flag CONTEXT_SEGMENTS.
1174     //
1175
1176     DWORD   SegGs;
1177     DWORD   SegFs;
1178     DWORD   SegEs;
1179     DWORD   SegDs;
1180
1181     //
1182     // This section is specified/returned if the
1183     // ContextFlags word contians the flag CONTEXT_INTEGER.
1184     //
1185
1186     DWORD   Edi;
1187     DWORD   Esi;
1188     DWORD   Ebx;
1189     DWORD   Edx;
1190     DWORD   Ecx;
1191     DWORD   Eax;
1192
1193     //
1194     // This section is specified/returned if the
1195     // ContextFlags word contians the flag CONTEXT_CONTROL.
1196     //
1197
1198     DWORD   Ebp;
1199     DWORD   Eip;
1200     DWORD   SegCs;              // MUST BE SANITIZED
1201     DWORD   EFlags;             // MUST BE SANITIZED
1202     DWORD   Esp;
1203     DWORD   SegSs;
1204 }
1205
1206 enum
1207 {
1208     THREAD_BASE_PRIORITY_LOWRT =  15,  // value that gets a thread to LowRealtime-1
1209     THREAD_BASE_PRIORITY_MAX =    2,   // maximum thread base priority boost
1210     THREAD_BASE_PRIORITY_MIN =    -2,  // minimum thread base priority boost
1211     THREAD_BASE_PRIORITY_IDLE =   -15, // value that gets a thread to idle
1212
1213     THREAD_PRIORITY_LOWEST =          THREAD_BASE_PRIORITY_MIN,
1214     THREAD_PRIORITY_BELOW_NORMAL =    (THREAD_PRIORITY_LOWEST+1),
1215     THREAD_PRIORITY_NORMAL =          0,
1216     THREAD_PRIORITY_HIGHEST =         THREAD_BASE_PRIORITY_MAX,
1217     THREAD_PRIORITY_ABOVE_NORMAL =    (THREAD_PRIORITY_HIGHEST-1),
1218     THREAD_PRIORITY_ERROR_RETURN =    int.max,
1219
1220     THREAD_PRIORITY_TIME_CRITICAL =   THREAD_BASE_PRIORITY_LOWRT,
1221     THREAD_PRIORITY_IDLE =            THREAD_BASE_PRIORITY_IDLE,
1222 }
1223
1224 export HANDLE GetCurrentThread();
1225 export BOOL GetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
1226 export HANDLE GetCurrentProcess();
1227 export DWORD GetCurrentProcessId();
1228 export BOOL DuplicateHandle (HANDLE sourceProcess, HANDLE sourceThread,
1229         HANDLE targetProcessHandle, HANDLE *targetHandle, DWORD access,
1230         BOOL inheritHandle, DWORD options);
1231 export DWORD GetCurrentThreadId();
1232 export BOOL SetThreadPriority(HANDLE hThread, int nPriority);
1233 export BOOL SetThreadPriorityBoost(HANDLE hThread, BOOL bDisablePriorityBoost);
1234 export BOOL GetThreadPriorityBoost(HANDLE hThread, PBOOL pDisablePriorityBoost);
1235 export BOOL GetThreadTimes(HANDLE hThread, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
1236 export int GetThreadPriority(HANDLE hThread);
1237 export BOOL GetThreadContext(HANDLE hThread, CONTEXT* lpContext);
1238 export BOOL SetThreadContext(HANDLE hThread, CONTEXT* lpContext);
1239 export DWORD SuspendThread(HANDLE hThread);
1240 export DWORD ResumeThread(HANDLE hThread);
1241 export DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
1242 export DWORD WaitForMultipleObjects(DWORD nCount, HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds);
1243 export void Sleep(DWORD dwMilliseconds);
1244
1245 // Synchronization
1246
1247 export
1248 {
1249 LONG  InterlockedIncrement(LPLONG lpAddend);
1250 LONG  InterlockedDecrement(LPLONG lpAddend);
1251 LONG  InterlockedExchange(LPLONG Target, LONG Value);
1252 LONG  InterlockedExchangeAdd(LPLONG Addend, LONG Value);
1253 PVOID InterlockedCompareExchange(PVOID *Destination, PVOID Exchange, PVOID Comperand);
1254
1255 void InitializeCriticalSection(CRITICAL_SECTION * lpCriticalSection);
1256 void EnterCriticalSection(CRITICAL_SECTION * lpCriticalSection);
1257 BOOL TryEnterCriticalSection(CRITICAL_SECTION * lpCriticalSection);
1258 void LeaveCriticalSection(CRITICAL_SECTION * lpCriticalSection);
1259 void DeleteCriticalSection(CRITICAL_SECTION * lpCriticalSection);
1260
1261 }
1262
1263
1264
1265 export BOOL QueryPerformanceCounter(long* lpPerformanceCount);
1266 export BOOL QueryPerformanceFrequency(long* lpFrequency);
1267
1268 enum
1269 {
1270     WM_NOTIFY =                       0x004E,
1271     WM_INPUTLANGCHANGEREQUEST =       0x0050,
1272     WM_INPUTLANGCHANGE =              0x0051,
1273     WM_TCARD =                        0x0052,
1274     WM_HELP =                         0x0053,
1275     WM_USERCHANGED =                  0x0054,
1276     WM_NOTIFYFORMAT =                 0x0055,
1277
1278     NFR_ANSI =                             1,
1279     NFR_UNICODE =                          2,
1280     NF_QUERY =                             3,
1281     NF_REQUERY =                           4,
1282
1283     WM_CONTEXTMENU =                  0x007B,
1284     WM_STYLECHANGING =                0x007C,
1285     WM_STYLECHANGED =                 0x007D,
1286     WM_DISPLAYCHANGE =                0x007E,
1287     WM_GETICON =                      0x007F,
1288     WM_SETICON =                      0x0080,
1289
1290
1291
1292     WM_NCCREATE =                     0x0081,
1293     WM_NCDESTROY =                    0x0082,
1294     WM_NCCALCSIZE =                   0x0083,
1295     WM_NCHITTEST =                    0x0084,
1296     WM_NCPAINT =                      0x0085,
1297     WM_NCACTIVATE =                   0x0086,
1298     WM_GETDLGCODE =                   0x0087,
1299
1300     WM_NCMOUSEMOVE =                  0x00A0,
1301     WM_NCLBUTTONDOWN =                0x00A1,
1302     WM_NCLBUTTONUP =                  0x00A2,
1303     WM_NCLBUTTONDBLCLK =              0x00A3,
1304     WM_NCRBUTTONDOWN =                0x00A4,
1305     WM_NCRBUTTONUP =                  0x00A5,
1306     WM_NCRBUTTONDBLCLK =              0x00A6,
1307     WM_NCMBUTTONDOWN =                0x00A7,
1308     WM_NCMBUTTONUP =                  0x00A8,
1309     WM_NCMBUTTONDBLCLK =              0x00A9,
1310
1311     WM_KEYFIRST =                     0x0100,
1312     WM_KEYDOWN =                      0x0100,
1313     WM_KEYUP =                        0x0101,
1314     WM_CHAR =                         0x0102,
1315     WM_DEADCHAR =                     0x0103,
1316     WM_SYSKEYDOWN =                   0x0104,
1317     WM_SYSKEYUP =                     0x0105,
1318     WM_SYSCHAR =                      0x0106,
1319     WM_SYSDEADCHAR =                  0x0107,
1320     WM_KEYLAST =                      0x0108,
1321
1322
1323     WM_IME_STARTCOMPOSITION =         0x010D,
1324     WM_IME_ENDCOMPOSITION =           0x010E,
1325     WM_IME_COMPOSITION =              0x010F,
1326     WM_IME_KEYLAST =                  0x010F,
1327
1328
1329     WM_INITDIALOG =                   0x0110,
1330     WM_COMMAND =                      0x0111,
1331     WM_SYSCOMMAND =                   0x0112,
1332     WM_TIMER =                        0x0113,
1333     WM_HSCROLL =                      0x0114,
1334     WM_VSCROLL =                      0x0115,
1335     WM_INITMENU =                     0x0116,
1336     WM_INITMENUPOPUP =                0x0117,
1337     WM_MENUSELECT =                   0x011F,
1338     WM_MENUCHAR =                     0x0120,
1339     WM_ENTERIDLE =                    0x0121,
1340
1341     WM_CTLCOLORMSGBOX =               0x0132,
1342     WM_CTLCOLOREDIT =                 0x0133,
1343     WM_CTLCOLORLISTBOX =              0x0134,
1344     WM_CTLCOLORBTN =                  0x0135,
1345     WM_CTLCOLORDLG =                  0x0136,
1346     WM_CTLCOLORSCROLLBAR =            0x0137,
1347     WM_CTLCOLORSTATIC =               0x0138,
1348
1349
1350
1351     WM_MOUSEFIRST =                   0x0200,
1352     WM_MOUSEMOVE =                    0x0200,
1353     WM_LBUTTONDOWN =                  0x0201,
1354     WM_LBUTTONUP =                    0x0202,
1355     WM_LBUTTONDBLCLK =                0x0203,
1356     WM_RBUTTONDOWN =                  0x0204,
1357     WM_RBUTTONUP =                    0x0205,
1358     WM_RBUTTONDBLCLK =                0x0206,
1359     WM_MBUTTONDOWN =                  0x0207,
1360     WM_MBUTTONUP =                    0x0208,
1361     WM_MBUTTONDBLCLK =                0x0209,
1362
1363
1364
1365     WM_MOUSELAST =                    0x0209,
1366
1367
1368
1369
1370
1371
1372
1373
1374     WM_PARENTNOTIFY =                 0x0210,
1375     MENULOOP_WINDOW =                 0,
1376     MENULOOP_POPUP =                  1,
1377     WM_ENTERMENULOOP =                0x0211,
1378     WM_EXITMENULOOP =                 0x0212,
1379
1380
1381     WM_NEXTMENU =                     0x0213,
1382 }
1383
1384 enum
1385 {
1386 /*
1387  * Dialog Box Command IDs
1388  */
1389     IDOK =                1,
1390     IDCANCEL =            2,
1391     IDABORT =             3,
1392     IDRETRY =             4,
1393     IDIGNORE =            5,
1394     IDYES =               6,
1395     IDNO =                7,
1396
1397     IDCLOSE =         8,
1398     IDHELP =          9,
1399
1400
1401 // end_r_winuser
1402
1403
1404
1405 /*
1406  * Control Manager Structures and Definitions
1407  */
1408
1409
1410
1411 // begin_r_winuser
1412
1413 /*
1414  * Edit Control Styles
1415  */
1416     ES_LEFT =             0x0000,
1417     ES_CENTER =           0x0001,
1418     ES_RIGHT =            0x0002,
1419     ES_MULTILINE =        0x0004,
1420     ES_UPPERCASE =        0x0008,
1421     ES_LOWERCASE =        0x0010,
1422     ES_PASSWORD =         0x0020,
1423     ES_AUTOVSCROLL =      0x0040,
1424     ES_AUTOHSCROLL =      0x0080,
1425     ES_NOHIDESEL =        0x0100,
1426     ES_OEMCONVERT =       0x0400,
1427     ES_READONLY =         0x0800,
1428     ES_WANTRETURN =       0x1000,
1429
1430     ES_NUMBER =           0x2000,
1431
1432
1433 // end_r_winuser
1434
1435
1436
1437 /*
1438  * Edit Control Notification Codes
1439  */
1440     EN_SETFOCUS =         0x0100,
1441     EN_KILLFOCUS =        0x0200,
1442     EN_CHANGE =           0x0300,
1443     EN_UPDATE =           0x0400,
1444     EN_ERRSPACE =         0x0500,
1445     EN_MAXTEXT =          0x0501,
1446     EN_HSCROLL =          0x0601,
1447     EN_VSCROLL =          0x0602,
1448
1449
1450 /* Edit control EM_SETMARGIN parameters */
1451     EC_LEFTMARGIN =       0x0001,
1452     EC_RIGHTMARGIN =      0x0002,
1453     EC_USEFONTINFO =      0xffff,
1454
1455
1456
1457
1458 // begin_r_winuser
1459
1460 /*
1461  * Edit Control Messages
1462  */
1463     EM_GETSEL =               0x00B0,
1464     EM_SETSEL =               0x00B1,
1465     EM_GETRECT =              0x00B2,
1466     EM_SETRECT =              0x00B3,
1467     EM_SETRECTNP =            0x00B4,
1468     EM_SCROLL =               0x00B5,
1469     EM_LINESCROLL =           0x00B6,
1470     EM_SCROLLCARET =          0x00B7,
1471     EM_GETMODIFY =            0x00B8,
1472     EM_SETMODIFY =            0x00B9,
1473     EM_GETLINECOUNT =         0x00BA,
1474     EM_LINEINDEX =            0x00BB,
1475     EM_SETHANDLE =            0x00BC,
1476     EM_GETHANDLE =            0x00BD,
1477     EM_GETTHUMB =             0x00BE,
1478     EM_LINELENGTH =           0x00C1,
1479     EM_REPLACESEL =           0x00C2,
1480     EM_GETLINE =              0x00C4,
1481     EM_LIMITTEXT =            0x00C5,
1482     EM_CANUNDO =              0x00C6,
1483     EM_UNDO =                 0x00C7,
1484     EM_FMTLINES =             0x00C8,
1485     EM_LINEFROMCHAR =         0x00C9,
1486     EM_SETTABSTOPS =          0x00CB,
1487     EM_SETPASSWORDCHAR =      0x00CC,
1488     EM_EMPTYUNDOBUFFER =      0x00CD,
1489     EM_GETFIRSTVISIBLELINE =  0x00CE,
1490     EM_SETREADONLY =          0x00CF,
1491     EM_SETWORDBREAKPROC =     0x00D0,
1492     EM_GETWORDBREAKPROC =     0x00D1,
1493     EM_GETPASSWORDCHAR =      0x00D2,
1494
1495     EM_SETMARGINS =           0x00D3,
1496     EM_GETMARGINS =           0x00D4,
1497     EM_SETLIMITTEXT =         EM_LIMITTEXT, /* ;win40 Name change */
1498     EM_GETLIMITTEXT =         0x00D5,
1499     EM_POSFROMCHAR =          0x00D6,
1500     EM_CHARFROMPOS =          0x00D7,
1501
1502
1503
1504 // end_r_winuser
1505
1506
1507 /*
1508  * EDITWORDBREAKPROC code values
1509  */
1510     WB_LEFT =            0,
1511     WB_RIGHT =           1,
1512     WB_ISDELIMITER =     2,
1513
1514 // begin_r_winuser
1515
1516 /*
1517  * Button Control Styles
1518  */
1519     BS_PUSHBUTTON =       0x00000000,
1520     BS_DEFPUSHBUTTON =    0x00000001,
1521     BS_CHECKBOX =         0x00000002,
1522     BS_AUTOCHECKBOX =     0x00000003,
1523     BS_RADIOBUTTON =      0x00000004,
1524     BS_3STATE =           0x00000005,
1525     BS_AUTO3STATE =       0x00000006,
1526     BS_GROUPBOX =         0x00000007,
1527     BS_USERBUTTON =       0x00000008,
1528     BS_AUTORADIOBUTTON =  0x00000009,
1529     BS_OWNERDRAW =        0x0000000B,
1530     BS_LEFTTEXT =         0x00000020,
1531
1532     BS_TEXT =             0x00000000,
1533     BS_ICON =             0x00000040,
1534     BS_BITMAP =           0x00000080,
1535     BS_LEFT =             0x00000100,
1536     BS_RIGHT =            0x00000200,
1537     BS_CENTER =           0x00000300,
1538     BS_TOP =              0x00000400,
1539     BS_BOTTOM =           0x00000800,
1540     BS_VCENTER =          0x00000C00,
1541     BS_PUSHLIKE =         0x00001000,
1542     BS_MULTILINE =        0x00002000,
1543     BS_NOTIFY =           0x00004000,
1544     BS_FLAT =             0x00008000,
1545     BS_RIGHTBUTTON =      BS_LEFTTEXT,
1546
1547
1548
1549 /*
1550  * User Button Notification Codes
1551  */
1552     BN_CLICKED =          0,
1553     BN_PAINT =            1,
1554     BN_HILITE =           2,
1555     BN_UNHILITE =         3,
1556     BN_DISABLE =          4,
1557     BN_DOUBLECLICKED =    5,
1558
1559     BN_PUSHED =           BN_HILITE,
1560     BN_UNPUSHED =         BN_UNHILITE,
1561     BN_DBLCLK =           BN_DOUBLECLICKED,
1562     BN_SETFOCUS =         6,
1563     BN_KILLFOCUS =        7,
1564
1565 /*
1566  * Button Control Messages
1567  */
1568     BM_GETCHECK =        0x00F0,
1569     BM_SETCHECK =        0x00F1,
1570     BM_GETSTATE =        0x00F2,
1571     BM_SETSTATE =        0x00F3,
1572     BM_SETSTYLE =        0x00F4,
1573
1574     BM_CLICK =           0x00F5,
1575     BM_GETIMAGE =        0x00F6,
1576     BM_SETIMAGE =        0x00F7,
1577
1578     BST_UNCHECKED =      0x0000,
1579     BST_CHECKED =        0x0001,
1580     BST_INDETERMINATE =  0x0002,
1581     BST_PUSHED =         0x0004,
1582     BST_FOCUS =          0x0008,
1583
1584
1585 /*
1586  * Static Control Constants
1587  */
1588     SS_LEFT =             0x00000000,
1589     SS_CENTER =           0x00000001,
1590     SS_RIGHT =            0x00000002,
1591     SS_ICON =             0x00000003,
1592     SS_BLACKRECT =        0x00000004,
1593     SS_GRAYRECT =         0x00000005,
1594     SS_WHITERECT =        0x00000006,
1595     SS_BLACKFRAME =       0x00000007,
1596     SS_GRAYFRAME =        0x00000008,
1597     SS_WHITEFRAME =       0x00000009,
1598     SS_USERITEM =         0x0000000A,
1599     SS_SIMPLE =           0x0000000B,
1600     SS_LEFTNOWORDWRAP =   0x0000000C,
1601
1602     SS_OWNERDRAW =        0x0000000D,
1603     SS_BITMAP =           0x0000000E,
1604     SS_ENHMETAFILE =      0x0000000F,
1605     SS_ETCHEDHORZ =       0x00000010,
1606     SS_ETCHEDVERT =       0x00000011,
1607     SS_ETCHEDFRAME =      0x00000012,
1608     SS_TYPEMASK =         0x0000001F,
1609
1610     SS_NOPREFIX =         0x00000080, /* Don't do "&" character translation */
1611
1612     SS_NOTIFY =           0x00000100,
1613     SS_CENTERIMAGE =      0x00000200,
1614     SS_RIGHTJUST =        0x00000400,
1615     SS_REALSIZEIMAGE =    0x00000800,
1616     SS_SUNKEN =           0x00001000,
1617     SS_ENDELLIPSIS =      0x00004000,
1618     SS_PATHELLIPSIS =     0x00008000,
1619     SS_WORDELLIPSIS =     0x0000C000,
1620     SS_ELLIPSISMASK =     0x0000C000,
1621
1622
1623 // end_r_winuser
1624
1625
1626 /*
1627  * Static Control Mesages
1628  */
1629     STM_SETICON =         0x0170,
1630     STM_GETICON =         0x0171,
1631
1632     STM_SETIMAGE =        0x0172,
1633     STM_GETIMAGE =        0x0173,
1634     STN_CLICKED =         0,
1635     STN_DBLCLK =          1,
1636     STN_ENABLE =          2,
1637     STN_DISABLE =         3,
1638
1639     STM_MSGMAX =          0x0174,
1640 }
1641
1642
1643 enum
1644 {
1645 /*
1646  * Window Messages
1647  */
1648
1649     WM_NULL =                         0x0000,
1650     WM_CREATE =                       0x0001,
1651     WM_DESTROY =                      0x0002,
1652     WM_MOVE =                         0x0003,
1653     WM_SIZE =                         0x0005,
1654
1655     WM_ACTIVATE =                     0x0006,
1656 /*
1657  * WM_ACTIVATE state values
1658  */
1659     WA_INACTIVE =     0,
1660     WA_ACTIVE =       1,
1661     WA_CLICKACTIVE =  2,
1662
1663     WM_SETFOCUS =                     0x0007,
1664     WM_KILLFOCUS =                    0x0008,
1665     WM_ENABLE =                       0x000A,
1666     WM_SETREDRAW =                    0x000B,
1667     WM_SETTEXT =                      0x000C,
1668     WM_GETTEXT =                      0x000D,
1669     WM_GETTEXTLENGTH =                0x000E,
1670     WM_PAINT =                        0x000F,
1671     WM_CLOSE =                        0x0010,
1672     WM_QUERYENDSESSION =              0x0011,
1673     WM_QUIT =                         0x0012,
1674     WM_QUERYOPEN =                    0x0013,
1675     WM_ERASEBKGND =                   0x0014,
1676     WM_SYSCOLORCHANGE =               0x0015,
1677     WM_ENDSESSION =                   0x0016,
1678     WM_SHOWWINDOW =                   0x0018,
1679     WM_WININICHANGE =                 0x001A,
1680
1681     WM_SETTINGCHANGE =                WM_WININICHANGE,
1682
1683
1684
1685     WM_DEVMODECHANGE =                0x001B,
1686     WM_ACTIVATEAPP =                  0x001C,
1687     WM_FONTCHANGE =                   0x001D,
1688     WM_TIMECHANGE =                   0x001E,
1689     WM_CANCELMODE =                   0x001F,
1690     WM_SETCURSOR =                    0x0020,
1691     WM_MOUSEACTIVATE =                0x0021,
1692     WM_CHILDACTIVATE =                0x0022,
1693     WM_QUEUESYNC =                    0x0023,
1694
1695     WM_GETMINMAXINFO =                0x0024,
1696 }
1697
1698 struct RECT
1699 {
1700     LONG    left;
1701     LONG    top;
1702     LONG    right;
1703     LONG    bottom;
1704 }
1705 alias RECT* PRECT, NPRECT, LPRECT;
1706
1707 struct PAINTSTRUCT {
1708     HDC         hdc;
1709     BOOL        fErase;
1710     RECT        rcPaint;
1711     BOOL        fRestore;
1712     BOOL        fIncUpdate;
1713     BYTE        rgbReserved[32];
1714 }
1715 alias PAINTSTRUCT* PPAINTSTRUCT, NPPAINTSTRUCT, LPPAINTSTRUCT;
1716
1717 // flags for GetDCEx()
1718
1719 enum
1720 {
1721     DCX_WINDOW =           0x00000001,
1722     DCX_CACHE =            0x00000002,
1723     DCX_NORESETATTRS =     0x00000004,
1724     DCX_CLIPCHILDREN =     0x00000008,
1725     DCX_CLIPSIBLINGS =     0x00000010,
1726     DCX_PARENTCLIP =       0x00000020,
1727     DCX_EXCLUDERGN =       0x00000040,
1728     DCX_INTERSECTRGN =     0x00000080,
1729     DCX_EXCLUDEUPDATE =    0x00000100,
1730     DCX_INTERSECTUPDATE =  0x00000200,
1731     DCX_LOCKWINDOWUPDATE = 0x00000400,
1732     DCX_VALIDATE =         0x00200000,
1733 }
1734
1735 export
1736 {
1737  BOOL UpdateWindow(HWND hWnd);
1738  HWND SetActiveWindow(HWND hWnd);
1739  HWND GetForegroundWindow();
1740  BOOL PaintDesktop(HDC hdc);
1741  BOOL SetForegroundWindow(HWND hWnd);
1742  HWND WindowFromDC(HDC hDC);
1743  HDC GetDC(HWND hWnd);
1744  HDC GetDCEx(HWND hWnd, HRGN hrgnClip, DWORD flags);
1745  HDC GetWindowDC(HWND hWnd);
1746  int ReleaseDC(HWND hWnd, HDC hDC);
1747  HDC BeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
1748  BOOL EndPaint(HWND hWnd, PAINTSTRUCT *lpPaint);
1749  BOOL GetUpdateRect(HWND hWnd, LPRECT lpRect, BOOL bErase);
1750  int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase);
1751  int SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw);
1752  int GetWindowRgn(HWND hWnd, HRGN hRgn);
1753  int ExcludeUpdateRgn(HDC hDC, HWND hWnd);
1754  BOOL InvalidateRect(HWND hWnd, RECT *lpRect, BOOL bErase);
1755  BOOL ValidateRect(HWND hWnd, RECT *lpRect);
1756  BOOL InvalidateRgn(HWND hWnd, HRGN hRgn, BOOL bErase);
1757  BOOL ValidateRgn(HWND hWnd, HRGN hRgn);
1758  BOOL RedrawWindow(HWND hWnd, RECT *lprcUpdate, HRGN hrgnUpdate, UINT flags);
1759 }
1760
1761 // flags for RedrawWindow()
1762 enum
1763 {
1764     RDW_INVALIDATE =          0x0001,
1765     RDW_INTERNALPAINT =       0x0002,
1766     RDW_ERASE =               0x0004,
1767     RDW_VALIDATE =            0x0008,
1768     RDW_NOINTERNALPAINT =     0x0010,
1769     RDW_NOERASE =             0x0020,
1770     RDW_NOCHILDREN =          0x0040,
1771     RDW_ALLCHILDREN =         0x0080,
1772     RDW_UPDATENOW =           0x0100,
1773     RDW_ERASENOW =            0x0200,
1774     RDW_FRAME =               0x0400,
1775     RDW_NOFRAME =             0x0800,
1776 }
1777
1778 export
1779 {
1780  BOOL GetClientRect(HWND hWnd, LPRECT lpRect);
1781  BOOL GetWindowRect(HWND hWnd, LPRECT lpRect);
1782  BOOL AdjustWindowRect(LPRECT lpRect, DWORD dwStyle, BOOL bMenu);
1783  BOOL AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle);
1784  HFONT CreateFontA(int, int, int, int, int, DWORD,
1785                              DWORD, DWORD, DWORD, DWORD, DWORD,
1786                              DWORD, DWORD, LPCSTR);
1787  HFONT CreateFontW(int, int, int, int, int, DWORD,
1788                              DWORD, DWORD, DWORD, DWORD, DWORD,
1789                              DWORD, DWORD, LPCWSTR);
1790 }
1791
1792 enum
1793 {
1794     OUT_DEFAULT_PRECIS =          0,
1795     OUT_STRING_PRECIS =           1,
1796     OUT_CHARACTER_PRECIS =        2,
1797     OUT_STROKE_PRECIS =           3,
1798     OUT_TT_PRECIS =               4,
1799     OUT_DEVICE_PRECIS =           5,
1800     OUT_RASTER_PRECIS =           6,
1801     OUT_TT_ONLY_PRECIS =          7,
1802     OUT_OUTLINE_PRECIS =          8,
1803     OUT_SCREEN_OUTLINE_PRECIS =   9,
1804
1805     CLIP_DEFAULT_PRECIS =     0,
1806     CLIP_CHARACTER_PRECIS =   1,
1807     CLIP_STROKE_PRECIS =      2,
1808     CLIP_MASK =               0xf,
1809     CLIP_LH_ANGLES =          (1<<4),
1810     CLIP_TT_ALWAYS =          (2<<4),
1811     CLIP_EMBEDDED =           (8<<4),
1812
1813     DEFAULT_QUALITY =         0,
1814     DRAFT_QUALITY =           1,
1815     PROOF_QUALITY =           2,
1816
1817     NONANTIALIASED_QUALITY =  3,
1818     ANTIALIASED_QUALITY =     4,
1819
1820
1821     DEFAULT_PITCH =           0,
1822     FIXED_PITCH =             1,
1823     VARIABLE_PITCH =          2,
1824
1825     MONO_FONT =               8,
1826
1827
1828     ANSI_CHARSET =            0,
1829     DEFAULT_CHARSET =         1,
1830     SYMBOL_CHARSET =          2,
1831     SHIFTJIS_CHARSET =        128,
1832     HANGEUL_CHARSET =         129,
1833     GB2312_CHARSET =          134,
1834     CHINESEBIG5_CHARSET =     136,
1835     OEM_CHARSET =             255,
1836
1837     JOHAB_CHARSET =           130,
1838     HEBREW_CHARSET =          177,
1839     ARABIC_CHARSET =          178,
1840     GREEK_CHARSET =           161,
1841     TURKISH_CHARSET =         162,
1842     VIETNAMESE_CHARSET =      163,
1843     THAI_CHARSET =            222,
1844     EASTEUROPE_CHARSET =      238,
1845     RUSSIAN_CHARSET =         204,
1846
1847     MAC_CHARSET =             77,
1848     BALTIC_CHARSET =          186,
1849
1850     FS_LATIN1 =               0x00000001L,
1851     FS_LATIN2 =               0x00000002L,
1852     FS_CYRILLIC =             0x00000004L,
1853     FS_GREEK =                0x00000008L,
1854     FS_TURKISH =              0x00000010L,
1855     FS_HEBREW =               0x00000020L,
1856     FS_ARABIC =               0x00000040L,
1857     FS_BALTIC =               0x00000080L,
1858     FS_VIETNAMESE =           0x00000100L,
1859     FS_THAI =                 0x00010000L,
1860     FS_JISJAPAN =             0x00020000L,
1861     FS_CHINESESIMP =          0x00040000L,
1862     FS_WANSUNG =              0x00080000L,
1863     FS_CHINESETRAD =          0x00100000L,
1864     FS_JOHAB =                0x00200000L,
1865     FS_SYMBOL =               cast(int)0x80000000L,
1866
1867
1868 /* Font Families */
1869     FF_DONTCARE =         (0<<4), /* Don't care or don't know. */
1870     FF_ROMAN =            (1<<4), /* Variable stroke width, serifed. */
1871                                     /* Times Roman, Century Schoolbook, etc. */
1872     FF_SWISS =            (2<<4), /* Variable stroke width, sans-serifed. */
1873                                     /* Helvetica, Swiss, etc. */
1874     FF_MODERN =           (3<<4), /* Constant stroke width, serifed or sans-serifed. */
1875                                     /* Pica, Elite, Courier, etc. */
1876     FF_SCRIPT =           (4<<4), /* Cursive, etc. */
1877     FF_DECORATIVE =       (5<<4), /* Old English, etc. */
1878
1879 /* Font Weights */
1880     FW_DONTCARE =         0,
1881     FW_THIN =             100,
1882     FW_EXTRALIGHT =       200,
1883     FW_LIGHT =            300,
1884     FW_NORMAL =           400,
1885     FW_MEDIUM =           500,
1886     FW_SEMIBOLD =         600,
1887     FW_BOLD =             700,
1888     FW_EXTRABOLD =        800,
1889     FW_HEAVY =            900,
1890
1891     FW_ULTRALIGHT =       FW_EXTRALIGHT,
1892     FW_REGULAR =          FW_NORMAL,
1893     FW_DEMIBOLD =         FW_SEMIBOLD,
1894     FW_ULTRABOLD =        FW_EXTRABOLD,
1895     FW_BLACK =            FW_HEAVY,
1896
1897     PANOSE_COUNT =               10,
1898     PAN_FAMILYTYPE_INDEX =        0,
1899     PAN_SERIFSTYLE_INDEX =        1,
1900     PAN_WEIGHT_INDEX =            2,
1901     PAN_PROPORTION_INDEX =        3,
1902     PAN_CONTRAST_INDEX =          4,
1903     PAN_STROKEVARIATION_INDEX =   5,
1904     PAN_ARMSTYLE_INDEX =          6,
1905     PAN_LETTERFORM_INDEX =        7,
1906     PAN_MIDLINE_INDEX =           8,
1907     PAN_XHEIGHT_INDEX =           9,
1908
1909     PAN_CULTURE_LATIN =           0,
1910 }
1911
1912 struct RGBQUAD {
1913         BYTE    rgbBlue;
1914         BYTE    rgbGreen;
1915         BYTE    rgbRed;
1916         BYTE    rgbReserved;
1917 }
1918 alias RGBQUAD* LPRGBQUAD;
1919
1920 struct BITMAPINFOHEADER
1921 {
1922         DWORD      biSize;
1923         LONG       biWidth;
1924         LONG       biHeight;
1925         WORD       biPlanes;
1926         WORD       biBitCount;
1927         DWORD      biCompression;
1928         DWORD      biSizeImage;
1929         LONG       biXPelsPerMeter;
1930         LONG       biYPelsPerMeter;
1931         DWORD      biClrUsed;
1932         DWORD      biClrImportant;
1933 }
1934 alias BITMAPINFOHEADER* LPBITMAPINFOHEADER, PBITMAPINFOHEADER;
1935
1936 struct BITMAPINFO {
1937     BITMAPINFOHEADER    bmiHeader;
1938     RGBQUAD             bmiColors[1];
1939 }
1940 alias BITMAPINFO* LPBITMAPINFO, PBITMAPINFO;
1941
1942 struct PALETTEENTRY {
1943     BYTE        peRed;
1944     BYTE        peGreen;
1945     BYTE        peBlue;
1946     BYTE        peFlags;
1947 }
1948 alias PALETTEENTRY* PPALETTEENTRY, LPPALETTEENTRY;
1949
1950 struct LOGPALETTE {
1951     WORD        palVersion;
1952     WORD        palNumEntries;
1953     PALETTEENTRY        palPalEntry[1];
1954 }
1955 alias LOGPALETTE* PLOGPALETTE, NPLOGPALETTE, LPLOGPALETTE;
1956
1957 /* Pixel format descriptor */
1958 struct PIXELFORMATDESCRIPTOR
1959 {
1960     WORD  nSize;
1961     WORD  nVersion;
1962     DWORD dwFlags;
1963     BYTE  iPixelType;
1964     BYTE  cColorBits;
1965     BYTE  cRedBits;
1966     BYTE  cRedShift;
1967     BYTE  cGreenBits;
1968     BYTE  cGreenShift;
1969     BYTE  cBlueBits;
1970     BYTE  cBlueShift;
1971     BYTE  cAlphaBits;
1972     BYTE  cAlphaShift;
1973     BYTE  cAccumBits;
1974     BYTE  cAccumRedBits;
1975     BYTE  cAccumGreenBits;
1976     BYTE  cAccumBlueBits;
1977     BYTE  cAccumAlphaBits;
1978     BYTE  cDepthBits;
1979     BYTE  cStencilBits;
1980     BYTE  cAuxBuffers;
1981     BYTE  iLayerType;
1982     BYTE  bReserved;
1983     DWORD dwLayerMask;
1984     DWORD dwVisibleMask;
1985     DWORD dwDamageMask;
1986 }
1987 alias PIXELFORMATDESCRIPTOR* PPIXELFORMATDESCRIPTOR, LPPIXELFORMATDESCRIPTOR;
1988
1989
1990 export
1991 {
1992  BOOL   RoundRect(HDC, int, int, int, int, int, int);
1993  BOOL   ResizePalette(HPALETTE, UINT);
1994  int    SaveDC(HDC);
1995  int    SelectClipRgn(HDC, HRGN);
1996  int    ExtSelectClipRgn(HDC, HRGN, int);
1997  int    SetMetaRgn(HDC);
1998  HGDIOBJ   SelectObject(HDC, HGDIOBJ);
1999  HPALETTE   SelectPalette(HDC, HPALETTE, BOOL);
2000  COLORREF   SetBkColor(HDC, COLORREF);
2001  int     SetBkMode(HDC, int);
2002  LONG    SetBitmapBits(HBITMAP, DWORD, void *);
2003  UINT    SetBoundsRect(HDC,   RECT *, UINT);
2004  int     SetDIBits(HDC, HBITMAP, UINT, UINT, void *, BITMAPINFO *, UINT);
2005  int     SetDIBitsToDevice(HDC, int, int, DWORD, DWORD, int,
2006         int, UINT, UINT, void *, BITMAPINFO *, UINT);
2007  DWORD   SetMapperFlags(HDC, DWORD);
2008  int     SetGraphicsMode(HDC hdc, int iMode);
2009  int     SetMapMode(HDC, int);
2010  HMETAFILE     SetMetaFileBitsEx(UINT, BYTE *);
2011  UINT    SetPaletteEntries(HPALETTE, UINT, UINT, PALETTEENTRY *);
2012  COLORREF   SetPixel(HDC, int, int, COLORREF);
2013  BOOL     SetPixelV(HDC, int, int, COLORREF);
2014  BOOL    SetPixelFormat(HDC, int, PIXELFORMATDESCRIPTOR *);
2015  int     SetPolyFillMode(HDC, int);
2016  BOOL    StretchBlt(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
2017  BOOL    SetRectRgn(HRGN, int, int, int, int);
2018  int     StretchDIBits(HDC, int, int, int, int, int, int, int, int,
2019          void *, BITMAPINFO *, UINT, DWORD);
2020  int     SetROP2(HDC, int);
2021  int     SetStretchBltMode(HDC, int);
2022  UINT    SetSystemPaletteUse(HDC, UINT);
2023  int     SetTextCharacterExtra(HDC, int);
2024  COLORREF   SetTextColor(HDC, COLORREF);
2025  UINT    SetTextAlign(HDC, UINT);
2026  BOOL    SetTextJustification(HDC, int, int);
2027  BOOL    UpdateColors(HDC);
2028 }
2029
2030 /* Text Alignment Options */
2031 enum
2032 {
2033     TA_NOUPDATECP =                0,
2034     TA_UPDATECP =                  1,
2035
2036     TA_LEFT =                      0,
2037     TA_RIGHT =                     2,
2038     TA_CENTER =                    6,
2039
2040     TA_TOP =                       0,
2041     TA_BOTTOM =                    8,
2042     TA_BASELINE =                  24,
2043
2044     TA_RTLREADING =                256,
2045     TA_MASK =       (TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING),
2046 }
2047
2048 struct POINT
2049 {
2050     LONG  x;
2051     LONG  y;
2052 }
2053 alias POINT* PPOINT, NPPOINT, LPPOINT;
2054
2055
2056 export
2057 {
2058  BOOL    MoveToEx(HDC, int, int, LPPOINT);
2059  BOOL    TextOutA(HDC, int, int, LPCSTR, int);
2060  BOOL    TextOutW(HDC, int, int, LPCWSTR, int);
2061 }
2062
2063 export void PostQuitMessage(int nExitCode);
2064 export LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
2065 export HMODULE GetModuleHandleA(LPCSTR lpModuleName);
2066
2067 alias LRESULT (* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
2068
2069 struct WNDCLASSEXA {
2070     UINT        cbSize;
2071     /* Win 3.x */
2072     UINT        style;
2073     WNDPROC     lpfnWndProc;
2074     int         cbClsExtra;
2075     int         cbWndExtra;
2076     HINSTANCE   hInstance;
2077     HICON       hIcon;
2078     HCURSOR     hCursor;
2079     HBRUSH      hbrBackground;
2080     LPCSTR      lpszMenuName;
2081     LPCSTR      lpszClassName;
2082     /* Win 4.0 */
2083     HICON       hIconSm;
2084 }
2085 alias WNDCLASSEXA* PWNDCLASSEXA, NPWNDCLASSEXA, LPWNDCLASSEXA;
2086
2087
2088 struct WNDCLASSA {
2089     UINT        style;
2090     WNDPROC     lpfnWndProc;
2091     int         cbClsExtra;
2092     int         cbWndExtra;
2093     HINSTANCE   hInstance;
2094     HICON       hIcon;
2095     HCURSOR     hCursor;
2096     HBRUSH      hbrBackground;
2097     LPCSTR      lpszMenuName;
2098     LPCSTR      lpszClassName;
2099 }
2100 alias WNDCLASSA* PWNDCLASSA, NPWNDCLASSA, LPWNDCLASSA;
2101 alias WNDCLASSA WNDCLASS;
2102
2103 /*
2104  * Window Styles
2105  */
2106 enum : uint
2107 {
2108     WS_OVERLAPPED =       0x00000000,
2109     WS_POPUP =            0x80000000,
2110     WS_CHILD =            0x40000000,
2111     WS_MINIMIZE =         0x20000000,
2112     WS_VISIBLE =          0x10000000,
2113     WS_DISABLED =         0x08000000,
2114     WS_CLIPSIBLINGS =     0x04000000,
2115     WS_CLIPCHILDREN =     0x02000000,
2116     WS_MAXIMIZE =         0x01000000,
2117     WS_CAPTION =          0x00C00000,  /* WS_BORDER | WS_DLGFRAME  */
2118     WS_BORDER =           0x00800000,
2119     WS_DLGFRAME =         0x00400000,
2120     WS_VSCROLL =          0x00200000,
2121     WS_HSCROLL =          0x00100000,
2122     WS_SYSMENU =          0x00080000,
2123     WS_THICKFRAME =       0x00040000,
2124     WS_GROUP =            0x00020000,
2125     WS_TABSTOP =          0x00010000,
2126
2127     WS_MINIMIZEBOX =      0x00020000,
2128     WS_MAXIMIZEBOX =      0x00010000,
2129
2130     WS_TILED =            WS_OVERLAPPED,
2131     WS_ICONIC =           WS_MINIMIZE,
2132     WS_SIZEBOX =          WS_THICKFRAME,
2133
2134 /*
2135  * Common Window Styles
2136  */
2137     WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED |            WS_CAPTION |  WS_SYSMENU |  WS_THICKFRAME |            WS_MINIMIZEBOX |                 WS_MAXIMIZEBOX),
2138     WS_TILEDWINDOW =      WS_OVERLAPPEDWINDOW,
2139     WS_POPUPWINDOW =      (WS_POPUP |  WS_BORDER |  WS_SYSMENU),
2140     WS_CHILDWINDOW =      (WS_CHILD),
2141 }
2142
2143 /*
2144  * Class styles
2145  */
2146 enum
2147 {
2148     CS_VREDRAW =          0x0001,
2149     CS_HREDRAW =          0x0002,
2150     CS_KEYCVTWINDOW =     0x0004,
2151     CS_DBLCLKS =          0x0008,
2152     CS_OWNDC =            0x0020,
2153     CS_CLASSDC =          0x0040,
2154     CS_PARENTDC =         0x0080,
2155     CS_NOKEYCVT =         0x0100,
2156     CS_NOCLOSE =          0x0200,
2157     CS_SAVEBITS =         0x0800,
2158     CS_BYTEALIGNCLIENT =  0x1000,
2159     CS_BYTEALIGNWINDOW =  0x2000,
2160     CS_GLOBALCLASS =      0x4000,
2161
2162
2163     CS_IME =              0x00010000,
2164 }
2165
2166 export
2167 {
2168  HICON LoadIconA(HINSTANCE hInstance, LPCSTR lpIconName);
2169  HICON LoadIconW(HINSTANCE hInstance, LPCWSTR lpIconName);
2170  HCURSOR LoadCursorA(HINSTANCE hInstance, LPCSTR lpCursorName);
2171  HCURSOR LoadCursorW(HINSTANCE hInstance, LPCWSTR lpCursorName);
2172 }
2173
2174 version(D_Version2)
2175 {
2176     mixin("
2177     enum : LPSTR
2178     {
2179         IDI_APPLICATION =     cast(LPSTR)(32512),
2180
2181         IDC_ARROW =           cast(LPSTR)(32512),
2182         IDC_CROSS =           cast(LPSTR)(32515),
2183     }");
2184 }
2185 else
2186 {
2187     const IDI_APPLICATION =     cast(LPSTR)(32512);
2188
2189     const IDC_ARROW =           cast(LPSTR)(32512);
2190     const IDC_CROSS =           cast(LPSTR)(32515);
2191 }
2192
2193 /*
2194  * Color Types
2195  */
2196 enum
2197 {
2198     CTLCOLOR_MSGBOX =         0,
2199     CTLCOLOR_EDIT =           1,
2200     CTLCOLOR_LISTBOX =        2,
2201     CTLCOLOR_BTN =            3,
2202     CTLCOLOR_DLG =            4,
2203     CTLCOLOR_SCROLLBAR =      5,
2204     CTLCOLOR_STATIC =         6,
2205     CTLCOLOR_MAX =            7,
2206
2207     COLOR_SCROLLBAR =         0,
2208     COLOR_BACKGROUND =        1,
2209     COLOR_ACTIVECAPTION =     2,
2210     COLOR_INACTIVECAPTION =   3,
2211     COLOR_MENU =              4,
2212     COLOR_WINDOW =            5,
2213     COLOR_WINDOWFRAME =       6,
2214     COLOR_MENUTEXT =          7,
2215     COLOR_WINDOWTEXT =        8,
2216     COLOR_CAPTIONTEXT =       9,
2217     COLOR_ACTIVEBORDER =      10,
2218     COLOR_INACTIVEBORDER =    11,
2219     COLOR_APPWORKSPACE =      12,
2220     COLOR_HIGHLIGHT =         13,
2221     COLOR_HIGHLIGHTTEXT =     14,
2222     COLOR_BTNFACE =           15,
2223     COLOR_BTNSHADOW =         16,
2224     COLOR_GRAYTEXT =          17,
2225     COLOR_BTNTEXT =           18,
2226     COLOR_INACTIVECAPTIONTEXT = 19,
2227     COLOR_BTNHIGHLIGHT =      20,
2228
2229
2230     COLOR_3DDKSHADOW =        21,
2231     COLOR_3DLIGHT =           22,
2232     COLOR_INFOTEXT =          23,
2233     COLOR_INFOBK =            24,
2234
2235     COLOR_DESKTOP =           COLOR_BACKGROUND,
2236     COLOR_3DFACE =            COLOR_BTNFACE,
2237     COLOR_3DSHADOW =          COLOR_BTNSHADOW,
2238     COLOR_3DHIGHLIGHT =       COLOR_BTNHIGHLIGHT,
2239     COLOR_3DHILIGHT =         COLOR_BTNHIGHLIGHT,
2240     COLOR_BTNHILIGHT =        COLOR_BTNHIGHLIGHT,
2241 }
2242
2243 enum : int
2244 {
2245     CW_USEDEFAULT = cast(int)0x80000000
2246 }
2247
2248 /*
2249  * Special value for CreateWindow, et al.
2250  */
2251 version(D_Version2)
2252 {
2253     mixin("
2254     enum : HWND
2255     {
2256         HWND_DESKTOP = cast(HWND)0,
2257     }");
2258 }
2259 else
2260 {
2261     const HWND_DESKTOP = cast(HWND)0;
2262 }
2263
2264 export ATOM RegisterClassA(WNDCLASSA *lpWndClass);
2265
2266 export HWND CreateWindowExA(
2267     DWORD dwExStyle,
2268     LPCSTR lpClassName,
2269     LPCSTR lpWindowName,
2270     DWORD dwStyle,
2271     int X,
2272     int Y,
2273     int nWidth,
2274     int nHeight,
2275     HWND hWndParent ,
2276     HMENU hMenu,
2277     HINSTANCE hInstance,
2278     LPVOID lpParam);
2279
2280
2281 HWND CreateWindowA(
2282     LPCSTR lpClassName,
2283     LPCSTR lpWindowName,
2284     DWORD dwStyle,
2285     int X,
2286     int Y,
2287     int nWidth,
2288     int nHeight,
2289     HWND hWndParent ,
2290     HMENU hMenu,
2291     HINSTANCE hInstance,
2292     LPVOID lpParam)
2293 {
2294     return CreateWindowExA(0, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
2295 }
2296
2297 /*
2298  * Message structure
2299  */
2300 struct MSG {
2301     HWND        hwnd;
2302     UINT        message;
2303     WPARAM      wParam;
2304     LPARAM      lParam;
2305     DWORD       time;
2306     POINT       pt;
2307 }
2308 alias MSG* PMSG, NPMSG, LPMSG;
2309
2310 export
2311 {
2312  BOOL GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
2313  BOOL TranslateMessage(MSG *lpMsg);
2314  LONG DispatchMessageA(MSG *lpMsg);
2315  BOOL PeekMessageA(MSG *lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
2316  HWND GetFocus();
2317 }
2318
2319 export DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, LPSTR lpDst, DWORD nSize);
2320
2321 export
2322 {
2323  BOOL IsValidCodePage(UINT CodePage);
2324  UINT GetACP();
2325  UINT GetOEMCP();
2326  //BOOL GetCPInfo(UINT CodePage, LPCPINFO lpCPInfo);
2327  BOOL IsDBCSLeadByte(BYTE TestChar);
2328  BOOL IsDBCSLeadByteEx(UINT CodePage, BYTE TestChar);
2329  int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cchMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
2330  int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cchMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
2331 }
2332
2333 export HANDLE CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCSTR lpName);
2334 export HANDLE CreateFileMappingW(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCWSTR lpName);
2335
2336 export BOOL GetMailslotInfo(HANDLE hMailslot, LPDWORD lpMaxMessageSize, LPDWORD lpNextSize, LPDWORD lpMessageCount, LPDWORD lpReadTimeout);
2337 export BOOL SetMailslotInfo(HANDLE hMailslot, DWORD lReadTimeout);
2338 export LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, DWORD dwNumberOfBytesToMap);
2339 export LPVOID MapViewOfFileEx(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, DWORD dwNumberOfBytesToMap, LPVOID lpBaseAddress);
2340 export BOOL FlushViewOfFile(LPCVOID lpBaseAddress, DWORD dwNumberOfBytesToFlush);
2341 export BOOL UnmapViewOfFile(LPCVOID lpBaseAddress);
2342
2343 export  HGDIOBJ   GetStockObject(int);
2344 export BOOL ShowWindow(HWND hWnd, int nCmdShow);
2345
2346 /* Stock Logical Objects */
2347 enum
2348 {   WHITE_BRUSH =         0,
2349     LTGRAY_BRUSH =        1,
2350     GRAY_BRUSH =          2,
2351     DKGRAY_BRUSH =        3,
2352     BLACK_BRUSH =         4,
2353     NULL_BRUSH =          5,
2354     HOLLOW_BRUSH =        NULL_BRUSH,
2355     WHITE_PEN =           6,
2356     BLACK_PEN =           7,
2357     NULL_PEN =            8,
2358     OEM_FIXED_FONT =      10,
2359     ANSI_FIXED_FONT =     11,
2360     ANSI_VAR_FONT =       12,
2361     SYSTEM_FONT =         13,
2362     DEVICE_DEFAULT_FONT = 14,
2363     DEFAULT_PALETTE =     15,
2364     SYSTEM_FIXED_FONT =   16,
2365     DEFAULT_GUI_FONT =    17,
2366     STOCK_LAST =          17,
2367 }
2368
2369 /*
2370  * ShowWindow() Commands
2371  */
2372 enum
2373 {   SW_HIDE =             0,
2374     SW_SHOWNORMAL =       1,
2375     SW_NORMAL =           1,
2376     SW_SHOWMINIMIZED =    2,
2377     SW_SHOWMAXIMIZED =    3,
2378     SW_MAXIMIZE =         3,
2379     SW_SHOWNOACTIVATE =   4,
2380     SW_SHOW =             5,
2381     SW_MINIMIZE =         6,
2382     SW_SHOWMINNOACTIVE =  7,
2383     SW_SHOWNA =           8,
2384     SW_RESTORE =          9,
2385     SW_SHOWDEFAULT =      10,
2386     SW_MAX =              10,
2387 }
2388
2389 struct TEXTMETRICA
2390 {
2391     LONG        tmHeight;
2392     LONG        tmAscent;
2393     LONG        tmDescent;
2394     LONG        tmInternalLeading;
2395     LONG        tmExternalLeading;
2396     LONG        tmAveCharWidth;
2397     LONG        tmMaxCharWidth;
2398     LONG        tmWeight;
2399     LONG        tmOverhang;
2400     LONG        tmDigitizedAspectX;
2401     LONG        tmDigitizedAspectY;
2402     BYTE        tmFirstChar;
2403     BYTE        tmLastChar;
2404     BYTE        tmDefaultChar;
2405     BYTE        tmBreakChar;
2406     BYTE        tmItalic;
2407     BYTE        tmUnderlined;
2408     BYTE        tmStruckOut;
2409     BYTE        tmPitchAndFamily;
2410     BYTE        tmCharSet;
2411 }
2412
2413 export  BOOL   GetTextMetricsA(HDC, TEXTMETRICA*);
2414
2415 /*
2416  * Scroll Bar Constants
2417  */
2418 enum
2419 {   SB_HORZ =             0,
2420     SB_VERT =             1,
2421     SB_CTL =              2,
2422     SB_BOTH =             3,
2423 }
2424
2425 /*
2426  * Scroll Bar Commands
2427  */
2428 enum
2429 {   SB_LINEUP =           0,
2430     SB_LINELEFT =         0,
2431     SB_LINEDOWN =         1,
2432     SB_LINERIGHT =        1,
2433     SB_PAGEUP =           2,
2434     SB_PAGELEFT =         2,
2435     SB_PAGEDOWN =         3,
2436     SB_PAGERIGHT =        3,
2437     SB_THUMBPOSITION =    4,
2438     SB_THUMBTRACK =       5,
2439     SB_TOP =              6,
2440     SB_LEFT =             6,
2441     SB_BOTTOM =           7,
2442     SB_RIGHT =            7,
2443     SB_ENDSCROLL =        8,
2444 }
2445
2446 export int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw);
2447 export int GetScrollPos(HWND hWnd, int nBar);
2448 export BOOL SetScrollRange(HWND hWnd, int nBar, int nMinPos, int nMaxPos, BOOL bRedraw);
2449 export BOOL GetScrollRange(HWND hWnd, int nBar, LPINT lpMinPos, LPINT lpMaxPos);
2450 export BOOL ShowScrollBar(HWND hWnd, int wBar, BOOL bShow);
2451 export BOOL EnableScrollBar(HWND hWnd, UINT wSBflags, UINT wArrows);
2452
2453 /*
2454  * LockWindowUpdate API
2455  */
2456
2457 export BOOL LockWindowUpdate(HWND hWndLock);
2458 export BOOL ScrollWindow(HWND hWnd, int XAmount, int YAmount, RECT* lpRect, RECT* lpClipRect);
2459 export BOOL ScrollDC(HDC hDC, int dx, int dy, RECT* lprcScroll, RECT* lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate);
2460 export int ScrollWindowEx(HWND hWnd, int dx, int dy, RECT* prcScroll, RECT* prcClip, HRGN hrgnUpdate, LPRECT prcUpdate, UINT flags);
2461
2462 /*
2463  * Virtual Keys, Standard Set
2464  */
2465 enum
2466 {   VK_LBUTTON =        0x01,
2467     VK_RBUTTON =        0x02,
2468     VK_CANCEL =         0x03,
2469     VK_MBUTTON =        0x04, /* NOT contiguous with L & RBUTTON */
2470
2471     VK_BACK =           0x08,
2472     VK_TAB =            0x09,
2473
2474     VK_CLEAR =          0x0C,
2475     VK_RETURN =         0x0D,
2476
2477     VK_SHIFT =          0x10,
2478     VK_CONTROL =        0x11,
2479     VK_MENU =           0x12,
2480     VK_PAUSE =          0x13,
2481     VK_CAPITAL =        0x14,
2482
2483
2484     VK_ESCAPE =         0x1B,
2485
2486     VK_SPACE =          0x20,
2487     VK_PRIOR =          0x21,
2488     VK_NEXT =           0x22,
2489     VK_END =            0x23,
2490     VK_HOME =           0x24,
2491     VK_LEFT =           0x25,
2492     VK_UP =             0x26,
2493     VK_RIGHT =          0x27,
2494     VK_DOWN =           0x28,
2495     VK_SELECT =         0x29,
2496     VK_PRINT =          0x2A,
2497     VK_EXECUTE =        0x2B,
2498     VK_SNAPSHOT =       0x2C,
2499     VK_INSERT =         0x2D,
2500     VK_DELETE =         0x2E,
2501     VK_HELP =           0x2F,
2502
2503 /* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
2504 /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
2505
2506     VK_LWIN =           0x5B,
2507     VK_RWIN =           0x5C,
2508     VK_APPS =           0x5D,
2509
2510     VK_NUMPAD0 =        0x60,
2511     VK_NUMPAD1 =        0x61,
2512     VK_NUMPAD2 =        0x62,
2513     VK_NUMPAD3 =        0x63,
2514     VK_NUMPAD4 =        0x64,
2515     VK_NUMPAD5 =        0x65,
2516     VK_NUMPAD6 =        0x66,
2517     VK_NUMPAD7 =        0x67,
2518     VK_NUMPAD8 =        0x68,
2519     VK_NUMPAD9 =        0x69,
2520     VK_MULTIPLY =       0x6A,
2521     VK_ADD =            0x6B,
2522     VK_SEPARATOR =      0x6C,
2523     VK_SUBTRACT =       0x6D,
2524     VK_DECIMAL =        0x6E,
2525     VK_DIVIDE =         0x6F,
2526     VK_F1 =             0x70,
2527     VK_F2 =             0x71,
2528     VK_F3 =             0x72,
2529     VK_F4 =             0x73,
2530     VK_F5 =             0x74,
2531     VK_F6 =             0x75,
2532     VK_F7 =             0x76,
2533     VK_F8 =             0x77,
2534     VK_F9 =             0x78,
2535     VK_F10 =            0x79,
2536     VK_F11 =            0x7A,
2537     VK_F12 =            0x7B,
2538     VK_F13 =            0x7C,
2539     VK_F14 =            0x7D,
2540     VK_F15 =            0x7E,
2541     VK_F16 =            0x7F,
2542     VK_F17 =            0x80,
2543     VK_F18 =            0x81,
2544     VK_F19 =            0x82,
2545     VK_F20 =            0x83,
2546     VK_F21 =            0x84,
2547     VK_F22 =            0x85,
2548     VK_F23 =            0x86,
2549     VK_F24 =            0x87,
2550
2551     VK_NUMLOCK =        0x90,
2552     VK_SCROLL =         0x91,
2553
2554 /*
2555  * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
2556  * Used only as parameters to GetAsyncKeyState() and GetKeyState().
2557  * No other API or message will distinguish left and right keys in this way.
2558  */
2559     VK_LSHIFT =         0xA0,
2560     VK_RSHIFT =         0xA1,
2561     VK_LCONTROL =       0xA2,
2562     VK_RCONTROL =       0xA3,
2563     VK_LMENU =          0xA4,
2564     VK_RMENU =          0xA5,
2565
2566
2567     VK_PROCESSKEY =     0xE5,
2568
2569
2570     VK_ATTN =           0xF6,
2571     VK_CRSEL =          0xF7,
2572     VK_EXSEL =          0xF8,
2573     VK_EREOF =          0xF9,
2574     VK_PLAY =           0xFA,
2575     VK_ZOOM =           0xFB,
2576     VK_NONAME =         0xFC,
2577     VK_PA1 =            0xFD,
2578     VK_OEM_CLEAR =      0xFE,
2579 }
2580
2581 export LRESULT SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
2582
2583 alias UINT (*LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
2584
2585 struct OPENFILENAMEA {
2586    DWORD        lStructSize;
2587    HWND         hwndOwner;
2588    HINSTANCE    hInstance;
2589    LPCSTR       lpstrFilter;
2590    LPSTR        lpstrCustomFilter;
2591    DWORD        nMaxCustFilter;
2592    DWORD        nFilterIndex;
2593    LPSTR        lpstrFile;
2594    DWORD        nMaxFile;
2595    LPSTR        lpstrFileTitle;
2596    DWORD        nMaxFileTitle;
2597    LPCSTR       lpstrInitialDir;
2598    LPCSTR       lpstrTitle;
2599    DWORD        Flags;
2600    WORD         nFileOffset;
2601    WORD         nFileExtension;
2602    LPCSTR       lpstrDefExt;
2603    LPARAM       lCustData;
2604    LPOFNHOOKPROC lpfnHook;
2605    LPCSTR       lpTemplateName;
2606 }
2607 alias OPENFILENAMEA *LPOPENFILENAMEA;
2608
2609 struct OPENFILENAMEW {
2610    DWORD        lStructSize;
2611    HWND         hwndOwner;
2612    HINSTANCE    hInstance;
2613    LPCWSTR      lpstrFilter;
2614    LPWSTR       lpstrCustomFilter;
2615    DWORD        nMaxCustFilter;
2616    DWORD        nFilterIndex;
2617    LPWSTR       lpstrFile;
2618    DWORD        nMaxFile;
2619    LPWSTR       lpstrFileTitle;
2620    DWORD        nMaxFileTitle;
2621    LPCWSTR      lpstrInitialDir;
2622    LPCWSTR      lpstrTitle;
2623    DWORD        Flags;
2624    WORD         nFileOffset;
2625    WORD         nFileExtension;
2626    LPCWSTR      lpstrDefExt;
2627    LPARAM       lCustData;
2628    LPOFNHOOKPROC lpfnHook;
2629    LPCWSTR      lpTemplateName;
2630 }
2631 alias OPENFILENAMEW *LPOPENFILENAMEW;
2632
2633 BOOL          GetOpenFileNameA(LPOPENFILENAMEA);
2634 BOOL          GetOpenFileNameW(LPOPENFILENAMEW);
2635
2636 BOOL          GetSaveFileNameA(LPOPENFILENAMEA);
2637 BOOL          GetSaveFileNameW(LPOPENFILENAMEW);
2638
2639 short         GetFileTitleA(LPCSTR, LPSTR, WORD);
2640 short         GetFileTitleW(LPCWSTR, LPWSTR, WORD);
2641
2642 enum
2643 {
2644     PM_NOREMOVE =         0x0000,
2645     PM_REMOVE =           0x0001,
2646     PM_NOYIELD =          0x0002,
2647 }
2648
2649 /* Bitmap Header Definition */
2650 struct BITMAP
2651 {
2652     LONG        bmType;
2653     LONG        bmWidth;
2654     LONG        bmHeight;
2655     LONG        bmWidthBytes;
2656     WORD        bmPlanes;
2657     WORD        bmBitsPixel;
2658     LPVOID      bmBits;
2659 }
2660 alias BITMAP* PBITMAP, NPBITMAP, LPBITMAP;
2661
2662
2663 export  HDC       CreateCompatibleDC(HDC);
2664
2665 export  int     GetObjectA(HGDIOBJ, int, LPVOID);
2666 export  int     GetObjectW(HGDIOBJ, int, LPVOID);
2667 export  BOOL   DeleteDC(HDC);
2668
2669 struct LOGFONTA
2670 {
2671     LONG      lfHeight;
2672     LONG      lfWidth;
2673     LONG      lfEscapement;
2674     LONG      lfOrientation;
2675     LONG      lfWeight;
2676     BYTE      lfItalic;
2677     BYTE      lfUnderline;
2678     BYTE      lfStrikeOut;
2679     BYTE      lfCharSet;
2680     BYTE      lfOutPrecision;
2681     BYTE      lfClipPrecision;
2682     BYTE      lfQuality;
2683     BYTE      lfPitchAndFamily;
2684     CHAR      lfFaceName[32 ];
2685 }
2686 alias LOGFONTA* PLOGFONTA, NPLOGFONTA, LPLOGFONTA;
2687
2688 export HMENU LoadMenuA(HINSTANCE hInstance, LPCSTR lpMenuName);
2689 export HMENU LoadMenuW(HINSTANCE hInstance, LPCWSTR lpMenuName);
2690
2691 export HMENU GetSubMenu(HMENU hMenu, int nPos);
2692
2693 export HBITMAP LoadBitmapA(HINSTANCE hInstance, LPCSTR lpBitmapName);
2694 export HBITMAP LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName);
2695
2696 LPSTR MAKEINTRESOURCEA(int i) { return cast(LPSTR)(cast(DWORD)(cast(WORD)(i))); }
2697
2698 export  HFONT     CreateFontIndirectA(LOGFONTA *);
2699
2700 export BOOL MessageBeep(UINT uType);
2701 export int ShowCursor(BOOL bShow);
2702 export BOOL SetCursorPos(int X, int Y);
2703 export HCURSOR SetCursor(HCURSOR hCursor);
2704 export BOOL GetCursorPos(LPPOINT lpPoint);
2705 export BOOL ClipCursor( RECT *lpRect);
2706 export BOOL GetClipCursor(LPRECT lpRect);
2707 export HCURSOR GetCursor();
2708 export BOOL CreateCaret(HWND hWnd, HBITMAP hBitmap , int nWidth, int nHeight);
2709 export UINT GetCaretBlinkTime();
2710 export BOOL SetCaretBlinkTime(UINT uMSeconds);
2711 export BOOL DestroyCaret();
2712 export BOOL HideCaret(HWND hWnd);
2713 export BOOL ShowCaret(HWND hWnd);
2714 export BOOL SetCaretPos(int X, int Y);
2715 export BOOL GetCaretPos(LPPOINT lpPoint);
2716 export BOOL ClientToScreen(HWND hWnd, LPPOINT lpPoint);
2717 export BOOL ScreenToClient(HWND hWnd, LPPOINT lpPoint);
2718 export int MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints);
2719 export HWND WindowFromPoint(POINT Point);
2720 export HWND ChildWindowFromPoint(HWND hWndParent, POINT Point);
2721
2722
2723 export BOOL TrackPopupMenu(HMENU hMenu, UINT uFlags, int x, int y,
2724     int nReserved, HWND hWnd, RECT *prcRect);
2725
2726 align (2) struct DLGTEMPLATE {
2727     DWORD style;
2728     DWORD dwExtendedStyle;
2729     WORD cdit;
2730     short x;
2731     short y;
2732     short cx;
2733     short cy;
2734 }
2735 alias DLGTEMPLATE *LPDLGTEMPLATEA;
2736 alias DLGTEMPLATE *LPDLGTEMPLATEW;
2737
2738
2739 alias LPDLGTEMPLATEA LPDLGTEMPLATE;
2740
2741 alias  DLGTEMPLATE *LPCDLGTEMPLATEA;
2742 alias  DLGTEMPLATE *LPCDLGTEMPLATEW;
2743
2744
2745 alias LPCDLGTEMPLATEA LPCDLGTEMPLATE;
2746
2747
2748 export int DialogBoxParamA(HINSTANCE hInstance, LPCSTR lpTemplateName,
2749     HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
2750 export int DialogBoxIndirectParamA(HINSTANCE hInstance,
2751     LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc,
2752     LPARAM dwInitParam);
2753
2754 enum : DWORD
2755 {
2756     SRCCOPY =             cast(DWORD)0x00CC0020, /* dest = source                   */
2757     SRCPAINT =            cast(DWORD)0x00EE0086, /* dest = source OR dest           */
2758     SRCAND =              cast(DWORD)0x008800C6, /* dest = source AND dest          */
2759     SRCINVERT =           cast(DWORD)0x00660046, /* dest = source XOR dest          */
2760     SRCERASE =            cast(DWORD)0x00440328, /* dest = source AND (NOT dest)   */
2761     NOTSRCCOPY =          cast(DWORD)0x00330008, /* dest = (NOT source)             */
2762     NOTSRCERASE =         cast(DWORD)0x001100A6, /* dest = (NOT src) AND (NOT dest) */
2763     MERGECOPY =           cast(DWORD)0x00C000CA, /* dest = (source AND pattern)     */
2764     MERGEPAINT =          cast(DWORD)0x00BB0226, /* dest = (NOT source) OR dest     */
2765     PATCOPY =             cast(DWORD)0x00F00021, /* dest = pattern                  */
2766     PATPAINT =            cast(DWORD)0x00FB0A09, /* dest = DPSnoo                   */
2767     PATINVERT =           cast(DWORD)0x005A0049, /* dest = pattern XOR dest         */
2768     DSTINVERT =           cast(DWORD)0x00550009, /* dest = (NOT dest)               */
2769     BLACKNESS =           cast(DWORD)0x00000042, /* dest = BLACK                    */
2770     WHITENESS =           cast(DWORD)0x00FF0062, /* dest = WHITE                    */
2771 }
2772
2773 enum
2774 {
2775     SND_SYNC =            0x0000, /* play synchronously (default) */
2776     SND_ASYNC =           0x0001, /* play asynchronously */
2777     SND_NODEFAULT =       0x0002, /* silence (!default) if sound not found */
2778     SND_MEMORY =          0x0004, /* pszSound points to a memory file */
2779     SND_LOOP =            0x0008, /* loop the sound until next sndPlaySound */
2780     SND_NOSTOP =          0x0010, /* don't stop any currently playing sound */
2781
2782     SND_NOWAIT =    0x00002000, /* don't wait if the driver is busy */
2783     SND_ALIAS =       0x00010000, /* name is a registry alias */
2784     SND_ALIAS_ID =  0x00110000, /* alias is a predefined ID */
2785     SND_FILENAME =    0x00020000, /* name is file name */
2786     SND_RESOURCE =    0x00040004, /* name is resource name or atom */
2787
2788     SND_PURGE =           0x0040, /* purge non-static events for task */
2789     SND_APPLICATION =     0x0080, /* look for application specific association */
2790
2791
2792     SND_ALIAS_START =   0,     /* alias base */
2793 }
2794
2795 export  BOOL   PlaySoundA(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound);
2796 export  BOOL   PlaySoundW(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound);
2797
2798 export  int     GetClipBox(HDC, LPRECT);
2799 export  int     GetClipRgn(HDC, HRGN);
2800 export  int     GetMetaRgn(HDC, HRGN);
2801 export  HGDIOBJ   GetCurrentObject(HDC, UINT);
2802 export  BOOL    GetCurrentPositionEx(HDC, LPPOINT);
2803 export  int     GetDeviceCaps(HDC, int);
2804
2805 struct LOGPEN
2806   {
2807     UINT        lopnStyle;
2808     POINT       lopnWidth;
2809     COLORREF    lopnColor;
2810 }
2811 alias LOGPEN* PLOGPEN, NPLOGPEN, LPLOGPEN;
2812
2813 enum
2814 {
2815     PS_SOLID =            0,
2816     PS_DASH =             1, /* -------  */
2817     PS_DOT =              2, /* .......  */
2818     PS_DASHDOT =          3, /* _._._._  */
2819     PS_DASHDOTDOT =       4, /* _.._.._  */
2820     PS_NULL =             5,
2821     PS_INSIDEFRAME =      6,
2822     PS_USERSTYLE =        7,
2823     PS_ALTERNATE =        8,
2824     PS_STYLE_MASK =       0x0000000F,
2825
2826     PS_ENDCAP_ROUND =     0x00000000,
2827     PS_ENDCAP_SQUARE =    0x00000100,
2828     PS_ENDCAP_FLAT =      0x00000200,
2829     PS_ENDCAP_MASK =      0x00000F00,
2830
2831     PS_JOIN_ROUND =       0x00000000,
2832     PS_JOIN_BEVEL =       0x00001000,
2833     PS_JOIN_MITER =       0x00002000,
2834     PS_JOIN_MASK =        0x0000F000,
2835
2836     PS_COSMETIC =         0x00000000,
2837     PS_GEOMETRIC =        0x00010000,
2838     PS_TYPE_MASK =        0x000F0000,
2839 }
2840
2841 export  HPALETTE   CreatePalette(LOGPALETTE *);
2842 export  HPEN      CreatePen(int, int, COLORREF);
2843 export  HPEN      CreatePenIndirect(LOGPEN *);
2844 export  HRGN      CreatePolyPolygonRgn(POINT *, INT *, int, int);
2845 export  HBRUSH    CreatePatternBrush(HBITMAP);
2846 export  HRGN      CreateRectRgn(int, int, int, int);
2847 export  HRGN      CreateRectRgnIndirect(RECT *);
2848 export  HRGN      CreateRoundRectRgn(int, int, int, int, int, int);
2849 export  BOOL      CreateScalableFontResourceA(DWORD, LPCSTR, LPCSTR, LPCSTR);
2850 export  BOOL      CreateScalableFontResourceW(DWORD, LPCWSTR, LPCWSTR, LPCWSTR);
2851
2852 COLORREF RGB(int r, int g, int b)
2853 {
2854     return cast(COLORREF)
2855     ((cast(BYTE)r|(cast(WORD)(cast(BYTE)g)<<8))|((cast(DWORD)cast(BYTE)b)<<16));
2856 }
2857
2858 export  BOOL   LineTo(HDC, int, int);
2859 export  BOOL   DeleteObject(HGDIOBJ);
2860 export int FillRect(HDC hDC,  RECT *lprc, HBRUSH hbr);
2861
2862
2863 export BOOL EndDialog(HWND hDlg, int nResult);
2864 export HWND GetDlgItem(HWND hDlg, int nIDDlgItem);
2865
2866 export BOOL SetDlgItemInt(HWND hDlg, int nIDDlgItem, UINT uValue, BOOL bSigned);
2867 export UINT GetDlgItemInt(HWND hDlg, int nIDDlgItem, BOOL *lpTranslated,
2868     BOOL bSigned);
2869
2870 export BOOL SetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPCSTR lpString);
2871 export BOOL SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString);
2872
2873 export UINT GetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount);
2874 export UINT GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount);
2875
2876 export BOOL CheckDlgButton(HWND hDlg, int nIDButton, UINT uCheck);
2877 export BOOL CheckRadioButton(HWND hDlg, int nIDFirstButton, int nIDLastButton,
2878     int nIDCheckButton);
2879
2880 export UINT IsDlgButtonChecked(HWND hDlg, int nIDButton);
2881
2882 export HWND SetFocus(HWND hWnd);
2883
2884 export int wsprintfA(LPSTR, LPCSTR, ...);
2885 export int wsprintfW(LPWSTR, LPCWSTR, ...);
2886
2887 enum : uint
2888 {
2889     INFINITE = uint.max,
2890     WAIT_OBJECT_0 = 0,
2891 }
2892
2893 export HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCTSTR lpName);
2894 export HANDLE OpenSemaphoreA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCTSTR lpName);
2895 export BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount);
2896
2897 struct COORD {
2898     SHORT X;
2899     SHORT Y;
2900 }
2901 alias COORD *PCOORD;
2902
2903 struct SMALL_RECT {
2904     SHORT Left;
2905     SHORT Top;
2906     SHORT Right;
2907     SHORT Bottom;
2908 }
2909 alias SMALL_RECT *PSMALL_RECT;
2910
2911 struct KEY_EVENT_RECORD {
2912     BOOL bKeyDown;
2913     WORD wRepeatCount;
2914     WORD wVirtualKeyCode;
2915     WORD wVirtualScanCode;
2916     union {
2917         WCHAR UnicodeChar;
2918         CHAR   AsciiChar;
2919     }
2920     DWORD dwControlKeyState;
2921 }
2922 alias KEY_EVENT_RECORD *PKEY_EVENT_RECORD;
2923
2924 //
2925 // ControlKeyState flags
2926 //
2927
2928 enum
2929 {
2930     RIGHT_ALT_PRESSED =     0x0001, // the right alt key is pressed.
2931     LEFT_ALT_PRESSED =      0x0002, // the left alt key is pressed.
2932     RIGHT_CTRL_PRESSED =    0x0004, // the right ctrl key is pressed.
2933     LEFT_CTRL_PRESSED =     0x0008, // the left ctrl key is pressed.
2934     SHIFT_PRESSED =         0x0010, // the shift key is pressed.
2935     NUMLOCK_ON =            0x0020, // the numlock light is on.
2936     SCROLLLOCK_ON =         0x0040, // the scrolllock light is on.
2937     CAPSLOCK_ON =           0x0080, // the capslock light is on.
2938     ENHANCED_KEY =          0x0100, // the key is enhanced.
2939 }
2940
2941 struct MOUSE_EVENT_RECORD {
2942     COORD dwMousePosition;
2943     DWORD dwButtonState;
2944     DWORD dwControlKeyState;
2945     DWORD dwEventFlags;
2946 }
2947 alias MOUSE_EVENT_RECORD *PMOUSE_EVENT_RECORD;
2948
2949 //
2950 // ButtonState flags
2951 //
2952 enum
2953 {
2954     FROM_LEFT_1ST_BUTTON_PRESSED =    0x0001,
2955     RIGHTMOST_BUTTON_PRESSED =        0x0002,
2956     FROM_LEFT_2ND_BUTTON_PRESSED =    0x0004,
2957     FROM_LEFT_3RD_BUTTON_PRESSED =    0x0008,
2958     FROM_LEFT_4TH_BUTTON_PRESSED =    0x0010,
2959 }
2960
2961 //
2962 // EventFlags
2963 //
2964
2965 enum
2966 {
2967     MOUSE_MOVED =   0x0001,
2968     DOUBLE_CLICK =  0x0002,
2969 }
2970
2971 struct WINDOW_BUFFER_SIZE_RECORD {
2972     COORD dwSize;
2973 }
2974 alias WINDOW_BUFFER_SIZE_RECORD *PWINDOW_BUFFER_SIZE_RECORD;
2975
2976 struct MENU_EVENT_RECORD {
2977     UINT dwCommandId;
2978 }
2979 alias MENU_EVENT_RECORD *PMENU_EVENT_RECORD;
2980
2981 struct FOCUS_EVENT_RECORD {
2982     BOOL bSetFocus;
2983 }
2984 alias FOCUS_EVENT_RECORD *PFOCUS_EVENT_RECORD;
2985
2986 struct INPUT_RECORD {
2987     WORD EventType;
2988     union {
2989         KEY_EVENT_RECORD KeyEvent;
2990         MOUSE_EVENT_RECORD MouseEvent;
2991         WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
2992         MENU_EVENT_RECORD MenuEvent;
2993         FOCUS_EVENT_RECORD FocusEvent;
2994     }
2995 }
2996 alias INPUT_RECORD *PINPUT_RECORD;
2997
2998 //
2999 //  EventType flags:
3000 //
3001
3002 enum
3003 {
3004     KEY_EVENT =         0x0001, // Event contains key event record
3005     MOUSE_EVENT =       0x0002, // Event contains mouse event record
3006     WINDOW_BUFFER_SIZE_EVENT = 0x0004, // Event contains window change event record
3007     MENU_EVENT = 0x0008, // Event contains menu event record
3008     FOCUS_EVENT = 0x0010, // event contains focus change
3009 }
3010
3011 struct CHAR_INFO {
3012     union {
3013         WCHAR UnicodeChar;
3014         CHAR   AsciiChar;
3015     }
3016     WORD Attributes;
3017 }
3018 alias CHAR_INFO *PCHAR_INFO;
3019
3020 //
3021 // Attributes flags:
3022 //
3023
3024 enum
3025 {
3026     FOREGROUND_BLUE =      0x0001, // text color contains blue.
3027     FOREGROUND_GREEN =     0x0002, // text color contains green.
3028     FOREGROUND_RED =       0x0004, // text color contains red.
3029     FOREGROUND_INTENSITY = 0x0008, // text color is intensified.
3030     BACKGROUND_BLUE =      0x0010, // background color contains blue.
3031     BACKGROUND_GREEN =     0x0020, // background color contains green.
3032     BACKGROUND_RED =       0x0040, // background color contains red.
3033     BACKGROUND_INTENSITY = 0x0080, // background color is intensified.
3034 }
3035
3036 struct CONSOLE_SCREEN_BUFFER_INFO {
3037     COORD dwSize;
3038     COORD dwCursorPosition;
3039     WORD  wAttributes;
3040     SMALL_RECT srWindow;
3041     COORD dwMaximumWindowSize;
3042 }
3043 alias CONSOLE_SCREEN_BUFFER_INFO *PCONSOLE_SCREEN_BUFFER_INFO;
3044
3045 struct CONSOLE_CURSOR_INFO {
3046     DWORD  dwSize;
3047     BOOL   bVisible;
3048 }
3049 alias CONSOLE_CURSOR_INFO *PCONSOLE_CURSOR_INFO;
3050
3051 enum
3052 {
3053     ENABLE_PROCESSED_INPUT = 0x0001,
3054     ENABLE_LINE_INPUT =      0x0002,
3055     ENABLE_ECHO_INPUT =      0x0004,
3056     ENABLE_WINDOW_INPUT =    0x0008,
3057     ENABLE_MOUSE_INPUT =     0x0010,
3058 }
3059
3060 enum
3061 {
3062     ENABLE_PROCESSED_OUTPUT =    0x0001,
3063     ENABLE_WRAP_AT_EOL_OUTPUT =  0x0002,
3064 }
3065
3066 BOOL PeekConsoleInputA(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead);
3067 BOOL PeekConsoleInputW(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead);
3068 BOOL ReadConsoleInputA(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead);
3069 BOOL ReadConsoleInputW(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead);
3070 BOOL WriteConsoleInputA(HANDLE hConsoleInput, in INPUT_RECORD *lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsWritten);
3071 BOOL WriteConsoleInputW(HANDLE hConsoleInput, in INPUT_RECORD *lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsWritten);
3072 BOOL ReadConsoleOutputA(HANDLE hConsoleOutput, PCHAR_INFO lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, PSMALL_RECT lpReadRegion);
3073 BOOL ReadConsoleOutputW(HANDLE hConsoleOutput, PCHAR_INFO lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, PSMALL_RECT lpReadRegion);
3074 BOOL WriteConsoleOutputA(HANDLE hConsoleOutput, in CHAR_INFO *lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, PSMALL_RECT lpWriteRegion);
3075 BOOL WriteConsoleOutputW(HANDLE hConsoleOutput, in CHAR_INFO *lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, PSMALL_RECT lpWriteRegion);
3076 BOOL ReadConsoleOutputCharacterA(HANDLE hConsoleOutput, LPSTR lpCharacter, DWORD nLength, COORD dwReadCoord, LPDWORD lpNumberOfCharsRead);
3077 BOOL ReadConsoleOutputCharacterW(HANDLE hConsoleOutput, LPWSTR lpCharacter, DWORD nLength, COORD dwReadCoord, LPDWORD lpNumberOfCharsRead);
3078 BOOL ReadConsoleOutputAttribute(HANDLE hConsoleOutput, LPWORD lpAttribute, DWORD nLength, COORD dwReadCoord, LPDWORD lpNumberOfAttrsRead);
3079 BOOL WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, LPCSTR lpCharacter, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten);
3080 BOOL WriteConsoleOutputCharacterW(HANDLE hConsoleOutput, LPCWSTR lpCharacter, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten);
3081 BOOL WriteConsoleOutputAttribute(HANDLE hConsoleOutput, in WORD *lpAttribute, DWORD nLength, COORD dwWriteCoord, LPDWORD lpNumberOfAttrsWritten);
3082 BOOL FillConsoleOutputCharacterA(HANDLE hConsoleOutput, CHAR cCharacter, DWORD  nLength, COORD  dwWriteCoord, LPDWORD lpNumberOfCharsWritten);
3083 BOOL FillConsoleOutputCharacterW(HANDLE hConsoleOutput, WCHAR cCharacter, DWORD  nLength, COORD  dwWriteCoord, LPDWORD lpNumberOfCharsWritten);
3084 BOOL FillConsoleOutputAttribute(HANDLE hConsoleOutput, WORD   wAttribute, DWORD  nLength, COORD  dwWriteCoord, LPDWORD lpNumberOfAttrsWritten);
3085 BOOL GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode);
3086 BOOL GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents);
3087 BOOL GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
3088 COORD GetLargestConsoleWindowSize( HANDLE hConsoleOutput);
3089 BOOL GetConsoleCursorInfo(HANDLE hConsoleOutput, PCONSOLE_CURSOR_INFO lpConsoleCursorInfo);
3090 BOOL GetNumberOfConsoleMouseButtons( LPDWORD lpNumberOfMouseButtons);
3091 BOOL SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode);
3092 BOOL SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput);
3093 BOOL FlushConsoleInputBuffer(HANDLE hConsoleInput);
3094 BOOL SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize);
3095 BOOL SetConsoleCursorPosition(HANDLE hConsoleOutput, COORD dwCursorPosition);
3096 BOOL SetConsoleCursorInfo(HANDLE hConsoleOutput, in CONSOLE_CURSOR_INFO *lpConsoleCursorInfo);
3097 BOOL ScrollConsoleScreenBufferA(HANDLE hConsoleOutput, in SMALL_RECT *lpScrollRectangle, in SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, in CHAR_INFO *lpFill);
3098 BOOL ScrollConsoleScreenBufferW(HANDLE hConsoleOutput, in SMALL_RECT *lpScrollRectangle, in SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, in CHAR_INFO *lpFill);
3099 BOOL SetConsoleWindowInfo(HANDLE hConsoleOutput, BOOL bAbsolute, in SMALL_RECT *lpConsoleWindow);
3100 BOOL SetConsoleTextAttribute(HANDLE hConsoleOutput, WORD wAttributes);
3101 alias BOOL(*PHANDLER_ROUTINE)(DWORD CtrlType);
3102 BOOL SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add);
3103 BOOL GenerateConsoleCtrlEvent( DWORD dwCtrlEvent, DWORD dwProcessGroupId);
3104 BOOL AllocConsole();
3105 BOOL FreeConsole();
3106 DWORD GetConsoleTitleA(LPSTR lpConsoleTitle, DWORD nSize);
3107 DWORD GetConsoleTitleW(LPWSTR lpConsoleTitle, DWORD nSize);
3108 BOOL SetConsoleTitleA(LPCSTR lpConsoleTitle);
3109 BOOL SetConsoleTitleW(LPCWSTR lpConsoleTitle);
3110 BOOL ReadConsoleA(HANDLE hConsoleInput, LPVOID lpBuffer, DWORD nNumberOfCharsToRead, LPDWORD lpNumberOfCharsRead, LPVOID lpReserved);
3111 BOOL ReadConsoleW(HANDLE hConsoleInput, LPVOID lpBuffer, DWORD nNumberOfCharsToRead, LPDWORD lpNumberOfCharsRead, LPVOID lpReserved);
3112 BOOL WriteConsoleA(HANDLE hConsoleOutput, in  void *lpBuffer, DWORD nNumberOfCharsToWrite, LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved);
3113 BOOL WriteConsoleW(HANDLE hConsoleOutput, in  void *lpBuffer, DWORD nNumberOfCharsToWrite, LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved);
3114 HANDLE CreateConsoleScreenBuffer(DWORD dwDesiredAccess, DWORD dwShareMode, in SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwFlags, LPVOID lpScreenBufferData);
3115 UINT GetConsoleCP();
3116 BOOL SetConsoleCP( UINT wCodePageID);
3117 UINT GetConsoleOutputCP();
3118 BOOL SetConsoleOutputCP(UINT wCodePageID);
3119
3120 enum
3121 {
3122     CONSOLE_TEXTMODE_BUFFER = 1,
3123 }
3124
3125 enum
3126 {
3127     SM_CXSCREEN =             0,
3128     SM_CYSCREEN =             1,
3129     SM_CXVSCROLL =            2,
3130     SM_CYHSCROLL =            3,
3131     SM_CYCAPTION =            4,
3132     SM_CXBORDER =             5,
3133     SM_CYBORDER =             6,
3134     SM_CXDLGFRAME =           7,
3135     SM_CYDLGFRAME =           8,
3136     SM_CYVTHUMB =             9,
3137     SM_CXHTHUMB =             10,
3138     SM_CXICON =               11,
3139     SM_CYICON =               12,
3140     SM_CXCURSOR =             13,
3141     SM_CYCURSOR =             14,
3142     SM_CYMENU =               15,
3143     SM_CXFULLSCREEN =         16,
3144     SM_CYFULLSCREEN =         17,
3145     SM_CYKANJIWINDOW =        18,
3146     SM_MOUSEPRESENT =         19,
3147     SM_CYVSCROLL =            20,
3148     SM_CXHSCROLL =            21,
3149     SM_DEBUG =                22,
3150     SM_SWAPBUTTON =           23,
3151     SM_RESERVED1 =            24,
3152     SM_RESERVED2 =            25,
3153     SM_RESERVED3 =            26,
3154     SM_RESERVED4 =            27,
3155     SM_CXMIN =                28,
3156     SM_CYMIN =                29,
3157     SM_CXSIZE =               30,
3158     SM_CYSIZE =               31,
3159     SM_CXFRAME =              32,
3160     SM_CYFRAME =              33,
3161     SM_CXMINTRACK =           34,
3162     SM_CYMINTRACK =           35,
3163     SM_CXDOUBLECLK =          36,
3164     SM_CYDOUBLECLK =          37,
3165     SM_CXICONSPACING =        38,
3166     SM_CYICONSPACING =        39,
3167     SM_MENUDROPALIGNMENT =    40,
3168     SM_PENWINDOWS =           41,
3169     SM_DBCSENABLED =          42,
3170     SM_CMOUSEBUTTONS =        43,
3171
3172
3173     SM_CXFIXEDFRAME =         SM_CXDLGFRAME,
3174     SM_CYFIXEDFRAME =         SM_CYDLGFRAME,
3175     SM_CXSIZEFRAME =          SM_CXFRAME,
3176     SM_CYSIZEFRAME =          SM_CYFRAME,
3177
3178     SM_SECURE =               44,
3179     SM_CXEDGE =               45,
3180     SM_CYEDGE =               46,
3181     SM_CXMINSPACING =         47,
3182     SM_CYMINSPACING =         48,
3183     SM_CXSMICON =             49,
3184     SM_CYSMICON =             50,
3185     SM_CYSMCAPTION =          51,
3186     SM_CXSMSIZE =             52,
3187     SM_CYSMSIZE =             53,
3188     SM_CXMENUSIZE =           54,
3189     SM_CYMENUSIZE =           55,
3190     SM_ARRANGE =              56,
3191     SM_CXMINIMIZED =          57,
3192     SM_CYMINIMIZED =          58,
3193     SM_CXMAXTRACK =           59,
3194     SM_CYMAXTRACK =           60,
3195     SM_CXMAXIMIZED =          61,
3196     SM_CYMAXIMIZED =          62,
3197     SM_NETWORK =              63,
3198     SM_CLEANBOOT =            67,
3199     SM_CXDRAG =               68,
3200     SM_CYDRAG =               69,
3201     SM_SHOWSOUNDS =           70,
3202     SM_CXMENUCHECK =          71,
3203     SM_CYMENUCHECK =          72,
3204     SM_SLOWMACHINE =          73,
3205     SM_MIDEASTENABLED =       74,
3206     SM_CMETRICS =             75,
3207 }
3208
3209 int GetSystemMetrics(int nIndex);
3210
3211 enum : DWORD
3212 {
3213     STILL_ACTIVE = (0x103),
3214 }
3215
3216 DWORD TlsAlloc();
3217 LPVOID TlsGetValue(DWORD);
3218 BOOL TlsSetValue(DWORD, LPVOID);
3219 BOOL TlsFree(DWORD);
3220
3221 }