module win32.winbase;

// Translated from Microsoft Platform SDK August 2001 Edition
// by Y.Tomino (demoonlit@inter7.jp)

import win32.windef;

// #ifndef _WINBASE_
// #define _WINBASE_

// #if _MSC_VER > 1000
// #pragma once
// #endif

// #ifdef _MAC
// #...
// #endif //_MAC

// #if !defined(_ADVAPI32_)
// #define WINADVAPI DECLSPEC_IMPORT
// #else
// #...
// #endif

// #if !defined(_KERNEL32_)
// #define WINBASEAPI DECLSPEC_IMPORT
// #else
// #...
// #endif

// #if !defined(_ZAWPROXY_)
// #define ZAWPROXYAPI DECLSPEC_IMPORT
// #else
// #...
// #endif

// #ifdef __cplusplus
// extern "C" {
// #endif

// #define DefineHandleTable(w) ((w),TRUE)
// #define LimitEmsPages(dw)
// #define SetSwapAreaSize(w) (w)
// #define LockSegment(w) GlobalFix((HANDLE)(w))
// #define UnlockSegment(w) GlobalUnfix((HANDLE)(w))
alias GetTickCount GetCurrentTime;

// #define Yield()

HANDLE INVALID_HANDLE_VALUE = cast(HANDLE)-1;
enum : uint { INVALID_FILE_SIZE = cast(DWORD)0xFFFFFFFF }
enum : uint { INVALID_SET_FILE_POINTER = cast(DWORD)-1 }
enum : uint { INVALID_FILE_ATTRIBUTES = cast(DWORD)-1 }

enum : uint { FILE_BEGIN = 0 }
enum : uint { FILE_CURRENT = 1 }
enum : uint { FILE_END = 2 }

enum : uint { TIME_ZONE_ID_INVALID = cast(DWORD)0xFFFFFFFF }

enum : uint { WAIT_FAILED = cast(DWORD)0xFFFFFFFF }
alias STATUS_WAIT_0 WAIT_OBJECT_0;

alias STATUS_ABANDONED_WAIT_0 WAIT_ABANDONED;
alias STATUS_ABANDONED_WAIT_0 WAIT_ABANDONED_0;

alias STATUS_USER_APC WAIT_IO_COMPLETION;
alias STATUS_PENDING STILL_ACTIVE;
alias STATUS_ACCESS_VIOLATION EXCEPTION_ACCESS_VIOLATION;
alias STATUS_DATATYPE_MISALIGNMENT EXCEPTION_DATATYPE_MISALIGNMENT;
alias STATUS_BREAKPOINT EXCEPTION_BREAKPOINT;
alias STATUS_SINGLE_STEP EXCEPTION_SINGLE_STEP;
alias STATUS_ARRAY_BOUNDS_EXCEEDED EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
alias STATUS_FLOAT_DENORMAL_OPERAND EXCEPTION_FLT_DENORMAL_OPERAND;
alias STATUS_FLOAT_DIVIDE_BY_ZERO EXCEPTION_FLT_DIVIDE_BY_ZERO;
alias STATUS_FLOAT_INEXACT_RESULT EXCEPTION_FLT_INEXACT_RESULT;
alias STATUS_FLOAT_INVALID_OPERATION EXCEPTION_FLT_INVALID_OPERATION;
alias STATUS_FLOAT_OVERFLOW EXCEPTION_FLT_OVERFLOW;
alias STATUS_FLOAT_STACK_CHECK EXCEPTION_FLT_STACK_CHECK;
alias STATUS_FLOAT_UNDERFLOW EXCEPTION_FLT_UNDERFLOW;
alias STATUS_INTEGER_DIVIDE_BY_ZERO EXCEPTION_INT_DIVIDE_BY_ZERO;
alias STATUS_INTEGER_OVERFLOW EXCEPTION_INT_OVERFLOW;
alias STATUS_PRIVILEGED_INSTRUCTION EXCEPTION_PRIV_INSTRUCTION;
alias STATUS_IN_PAGE_ERROR EXCEPTION_IN_PAGE_ERROR;
alias STATUS_ILLEGAL_INSTRUCTION EXCEPTION_ILLEGAL_INSTRUCTION;
alias STATUS_NONCONTINUABLE_EXCEPTION EXCEPTION_NONCONTINUABLE_EXCEPTION;
alias STATUS_STACK_OVERFLOW EXCEPTION_STACK_OVERFLOW;
alias STATUS_INVALID_DISPOSITION EXCEPTION_INVALID_DISPOSITION;
alias STATUS_GUARD_PAGE_VIOLATION EXCEPTION_GUARD_PAGE;
alias STATUS_INVALID_HANDLE EXCEPTION_INVALID_HANDLE;
alias STATUS_CONTROL_C_EXIT CONTROL_C_EXIT;
alias RtlMoveMemory MoveMemory;
alias RtlCopyMemory CopyMemory;
alias RtlFillMemory FillMemory;
alias RtlZeroMemory ZeroMemory;

enum : uint { FILE_FLAG_WRITE_THROUGH = 0x80000000 }
enum : uint { FILE_FLAG_OVERLAPPED = 0x40000000 }
enum : uint { FILE_FLAG_NO_BUFFERING = 0x20000000 }
enum : uint { FILE_FLAG_RANDOM_ACCESS = 0x10000000 }
enum : uint { FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000 }
enum : uint { FILE_FLAG_DELETE_ON_CLOSE = 0x04000000 }
enum : uint { FILE_FLAG_BACKUP_SEMANTICS = 0x02000000 }
enum : uint { FILE_FLAG_POSIX_SEMANTICS = 0x01000000 }
enum : uint { FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000 }
enum : uint { FILE_FLAG_OPEN_NO_RECALL = 0x00100000 }
enum : uint { FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000 }

enum : uint { CREATE_NEW = 1 }
enum : uint { CREATE_ALWAYS = 2 }
enum : uint { OPEN_EXISTING = 3 }
enum : uint { OPEN_ALWAYS = 4 }
enum : uint { TRUNCATE_EXISTING = 5 }

// #if(_WIN32_WINNT >= 0x0400)

enum : uint { PROGRESS_CONTINUE = 0 }
enum : uint { PROGRESS_CANCEL = 1 }
enum : uint { PROGRESS_STOP = 2 }
enum : uint { PROGRESS_QUIET = 3 }

enum : uint { CALLBACK_CHUNK_FINISHED = 0x00000000 }
enum : uint { CALLBACK_STREAM_SWITCH = 0x00000001 }

enum : uint { COPY_FILE_FAIL_IF_EXISTS = 0x00000001 }
enum : uint { COPY_FILE_RESTARTABLE = 0x00000002 }
enum : uint { COPY_FILE_OPEN_SOURCE_FOR_WRITE = 0x00000004 }
enum : uint { COPY_FILE_ALLOW_DECRYPTED_DESTINATION = 0x00000008 }
// #endif /* _WIN32_WINNT >= 0x0400 */

// #if (_WIN32_WINNT >= 0x0500)

enum : uint { REPLACEFILE_WRITE_THROUGH = 0x00000001 }
enum : uint { REPLACEFILE_IGNORE_MERGE_ERRORS = 0x00000002 }

// #endif // #if (_WIN32_WINNT >= 0x0500)

enum : uint { PIPE_ACCESS_INBOUND = 0x00000001 }
enum : uint { PIPE_ACCESS_OUTBOUND = 0x00000002 }
enum : uint { PIPE_ACCESS_DUPLEX = 0x00000003 }

enum : uint { PIPE_CLIENT_END = 0x00000000 }
enum : uint { PIPE_SERVER_END = 0x00000001 }

enum : uint { PIPE_WAIT = 0x00000000 }
enum : uint { PIPE_NOWAIT = 0x00000001 }
enum : uint { PIPE_READMODE_BYTE = 0x00000000 }
enum : uint { PIPE_READMODE_MESSAGE = 0x00000002 }
enum : uint { PIPE_TYPE_BYTE = 0x00000000 }
enum : uint { PIPE_TYPE_MESSAGE = 0x00000004 }

enum : uint { PIPE_UNLIMITED_INSTANCES = 255 }

enum : uint { SECURITY_ANONYMOUS =  SecurityAnonymous << 16  }
enum : uint { SECURITY_IDENTIFICATION =  SecurityIdentification << 16  }
enum : uint { SECURITY_IMPERSONATION =  SecurityImpersonation << 16  }
enum : uint { SECURITY_DELEGATION =  SecurityDelegation << 16  }

enum : uint { SECURITY_CONTEXT_TRACKING = 0x00040000 }
enum : uint { SECURITY_EFFECTIVE_ONLY = 0x00080000 }

enum : uint { SECURITY_SQOS_PRESENT = 0x00100000 }
enum : uint { SECURITY_VALID_SQOS_FLAGS = 0x001F0000 }

struct _OVERLAPPED {
  ULONG_PTR Internal;
  ULONG_PTR InternalHigh;
union {
struct {
  DWORD Offset;
  DWORD OffsetHigh;
}

  PVOID Pointer;
}

  HANDLE hEvent;
}
alias _OVERLAPPED OVERLAPPED;
alias _OVERLAPPED* LPOVERLAPPED;

struct _SECURITY_ATTRIBUTES {
  DWORD nLength;
  LPVOID lpSecurityDescriptor;
  BOOL bInheritHandle;
}
alias _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
alias _SECURITY_ATTRIBUTES* PSECURITY_ATTRIBUTES;
alias _SECURITY_ATTRIBUTES* LPSECURITY_ATTRIBUTES;

struct _PROCESS_INFORMATION {
  HANDLE hProcess;
  HANDLE hThread;
  DWORD dwProcessId;
  DWORD dwThreadId;
}
alias _PROCESS_INFORMATION PROCESS_INFORMATION;
alias _PROCESS_INFORMATION* PPROCESS_INFORMATION;
alias _PROCESS_INFORMATION* LPPROCESS_INFORMATION;

struct _FILETIME {
  DWORD dwLowDateTime;
  DWORD dwHighDateTime;
}
alias _FILETIME FILETIME;
alias _FILETIME* PFILETIME;
alias _FILETIME* LPFILETIME;

struct _SYSTEMTIME {
  WORD wYear;
  WORD wMonth;
  WORD wDayOfWeek;
  WORD wDay;
  WORD wHour;
  WORD wMinute;
  WORD wSecond;
  WORD wMilliseconds;
}
alias _SYSTEMTIME SYSTEMTIME;
alias _SYSTEMTIME* PSYSTEMTIME;
alias _SYSTEMTIME* LPSYSTEMTIME;

extern(Windows) alias DWORD function( LPVOID lpThreadParameter ) PTHREAD_START_ROUTINE;
alias PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;

// #if(_WIN32_WINNT >= 0x0400)
extern(Windows) alias VOID function( LPVOID lpFiberParameter ) PFIBER_START_ROUTINE;
alias PFIBER_START_ROUTINE LPFIBER_START_ROUTINE;
// #endif /* _WIN32_WINNT >= 0x0400 */

alias RTL_CRITICAL_SECTION CRITICAL_SECTION;
alias PRTL_CRITICAL_SECTION PCRITICAL_SECTION;
alias PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;

alias RTL_CRITICAL_SECTION_DEBUG CRITICAL_SECTION_DEBUG;
alias PRTL_CRITICAL_SECTION_DEBUG PCRITICAL_SECTION_DEBUG;
alias PRTL_CRITICAL_SECTION_DEBUG LPCRITICAL_SECTION_DEBUG;

// #if defined(_X86_)
alias PLDT_ENTRY LPLDT_ENTRY;
// #else
// ...
// #endif

alias MUTANT_QUERY_STATE MUTEX_MODIFY_STATE;
alias MUTANT_ALL_ACCESS MUTEX_ALL_ACCESS;

enum : uint { SP_SERIALCOMM = cast(DWORD)0x00000001 }

enum : uint { PST_UNSPECIFIED = cast(DWORD)0x00000000 }
enum : uint { PST_RS232 = cast(DWORD)0x00000001 }
enum : uint { PST_PARALLELPORT = cast(DWORD)0x00000002 }
enum : uint { PST_RS422 = cast(DWORD)0x00000003 }
enum : uint { PST_RS423 = cast(DWORD)0x00000004 }
enum : uint { PST_RS449 = cast(DWORD)0x00000005 }
enum : uint { PST_MODEM = cast(DWORD)0x00000006 }
enum : uint { PST_FAX = cast(DWORD)0x00000021 }
enum : uint { PST_SCANNER = cast(DWORD)0x00000022 }
enum : uint { PST_NETWORK_BRIDGE = cast(DWORD)0x00000100 }
enum : uint { PST_LAT = cast(DWORD)0x00000101 }
enum : uint { PST_TCPIP_TELNET = cast(DWORD)0x00000102 }
enum : uint { PST_X25 = cast(DWORD)0x00000103 }

enum : uint { PCF_DTRDSR = cast(DWORD)0x0001 }
enum : uint { PCF_RTSCTS = cast(DWORD)0x0002 }
enum : uint { PCF_RLSD = cast(DWORD)0x0004 }
enum : uint { PCF_PARITY_CHECK = cast(DWORD)0x0008 }
enum : uint { PCF_XONXOFF = cast(DWORD)0x0010 }
enum : uint { PCF_SETXCHAR = cast(DWORD)0x0020 }
enum : uint { PCF_TOTALTIMEOUTS = cast(DWORD)0x0040 }
enum : uint { PCF_INTTIMEOUTS = cast(DWORD)0x0080 }
enum : uint { PCF_SPECIALCHARS = cast(DWORD)0x0100 }
enum : uint { PCF_16BITMODE = cast(DWORD)0x0200 }

enum : uint { SP_PARITY = cast(DWORD)0x0001 }
enum : uint { SP_BAUD = cast(DWORD)0x0002 }
enum : uint { SP_DATABITS = cast(DWORD)0x0004 }
enum : uint { SP_STOPBITS = cast(DWORD)0x0008 }
enum : uint { SP_HANDSHAKING = cast(DWORD)0x0010 }
enum : uint { SP_PARITY_CHECK = cast(DWORD)0x0020 }
enum : uint { SP_RLSD = cast(DWORD)0x0040 }

enum : uint { BAUD_075 = cast(DWORD)0x00000001 }
enum : uint { BAUD_110 = cast(DWORD)0x00000002 }
enum : uint { BAUD_134_5 = cast(DWORD)0x00000004 }
enum : uint { BAUD_150 = cast(DWORD)0x00000008 }
enum : uint { BAUD_300 = cast(DWORD)0x00000010 }
enum : uint { BAUD_600 = cast(DWORD)0x00000020 }
enum : uint { BAUD_1200 = cast(DWORD)0x00000040 }
enum : uint { BAUD_1800 = cast(DWORD)0x00000080 }
enum : uint { BAUD_2400 = cast(DWORD)0x00000100 }
enum : uint { BAUD_4800 = cast(DWORD)0x00000200 }
enum : uint { BAUD_7200 = cast(DWORD)0x00000400 }
enum : uint { BAUD_9600 = cast(DWORD)0x00000800 }
enum : uint { BAUD_14400 = cast(DWORD)0x00001000 }
enum : uint { BAUD_19200 = cast(DWORD)0x00002000 }
enum : uint { BAUD_38400 = cast(DWORD)0x00004000 }
enum : uint { BAUD_56K = cast(DWORD)0x00008000 }
enum : uint { BAUD_128K = cast(DWORD)0x00010000 }
enum : uint { BAUD_115200 = cast(DWORD)0x00020000 }
enum : uint { BAUD_57600 = cast(DWORD)0x00040000 }
enum : uint { BAUD_USER = cast(DWORD)0x10000000 }

enum : uint { DATABITS_5 = cast(WORD)0x0001 }
enum : uint { DATABITS_6 = cast(WORD)0x0002 }
enum : uint { DATABITS_7 = cast(WORD)0x0004 }
enum : uint { DATABITS_8 = cast(WORD)0x0008 }
enum : uint { DATABITS_16 = cast(WORD)0x0010 }
enum : uint { DATABITS_16X = cast(WORD)0x0020 }

enum : uint { STOPBITS_10 = cast(WORD)0x0001 }
enum : uint { STOPBITS_15 = cast(WORD)0x0002 }
enum : uint { STOPBITS_20 = cast(WORD)0x0004 }
enum : uint { PARITY_NONE = cast(WORD)0x0100 }
enum : uint { PARITY_ODD = cast(WORD)0x0200 }
enum : uint { PARITY_EVEN = cast(WORD)0x0400 }
enum : uint { PARITY_MARK = cast(WORD)0x0800 }
enum : uint { PARITY_SPACE = cast(WORD)0x1000 }

struct _COMMPROP {
  WORD wPacketLength;
  WORD wPacketVersion;
  DWORD dwServiceMask;
  DWORD dwReserved1;
  DWORD dwMaxTxQueue;
  DWORD dwMaxRxQueue;
  DWORD dwMaxBaud;
  DWORD dwProvSubType;
  DWORD dwProvCapabilities;
  DWORD dwSettableParams;
  DWORD dwSettableBaud;
  WORD wSettableData;
  WORD wSettableStopParity;
  DWORD dwCurrentTxQueue;
  DWORD dwCurrentRxQueue;
  DWORD dwProvSpec1;
  DWORD dwProvSpec2;
  WCHAR wcProvChar[1];
}
alias _COMMPROP COMMPROP;
alias _COMMPROP* LPCOMMPROP;

enum : uint { COMMPROP_INITIALIZED = cast(DWORD)0xE73CF52E }

struct _COMSTAT {
// DWORD fCtsHold : 1;
// DWORD fDsrHold : 1;
// DWORD fRlsdHold : 1;
// DWORD fXoffHold : 1;
// DWORD fXoffSent : 1;
// DWORD fEof : 1;
// DWORD fTxim : 1;
// DWORD fReserved : 25;
  DWORD cbInQue;
  DWORD cbOutQue;
}
alias _COMSTAT COMSTAT;
alias _COMSTAT* LPCOMSTAT;

enum : uint { DTR_CONTROL_DISABLE = 0x00 }
enum : uint { DTR_CONTROL_ENABLE = 0x01 }
enum : uint { DTR_CONTROL_HANDSHAKE = 0x02 }

enum : uint { RTS_CONTROL_DISABLE = 0x00 }
enum : uint { RTS_CONTROL_ENABLE = 0x01 }
enum : uint { RTS_CONTROL_HANDSHAKE = 0x02 }
enum : uint { RTS_CONTROL_TOGGLE = 0x03 }

struct _DCB {
  DWORD DCBlength;
  DWORD BaudRate;
// DWORD fBinary: 1;
// DWORD fParity: 1;
// DWORD fOutxCtsFlow:1;
// DWORD fOutxDsrFlow:1;
// DWORD fDtrControl:2;
// DWORD fDsrSensitivity:1;
// DWORD fTXContinueOnXoff: 1;
// DWORD fOutX: 1;
// DWORD fInX: 1;
// DWORD fErrorChar: 1;
// DWORD fNull: 1;
// DWORD fRtsControl:2;
// DWORD fAbortOnError:1;
// DWORD fDummy2:17;
  WORD wReserved;
  WORD XonLim;
  WORD XoffLim;
  BYTE ByteSize;
  BYTE Parity;
  BYTE StopBits;
  char XonChar;
  char XoffChar;
  char ErrorChar;
  char EofChar;
  char EvtChar;
  WORD wReserved1;
}
alias _DCB DCB;
alias _DCB* LPDCB;

struct _COMMTIMEOUTS {
  DWORD ReadIntervalTimeout;
  DWORD ReadTotalTimeoutMultiplier;
  DWORD ReadTotalTimeoutConstant;
  DWORD WriteTotalTimeoutMultiplier;
  DWORD WriteTotalTimeoutConstant;
}
alias _COMMTIMEOUTS COMMTIMEOUTS;
alias _COMMTIMEOUTS* LPCOMMTIMEOUTS;

struct _COMMCONFIG {
  DWORD dwSize;
  WORD wVersion;
  WORD wReserved;
  DCB dcb;
  DWORD dwProviderSubType;
  DWORD dwProviderOffset;
  DWORD dwProviderSize;
  WCHAR wcProviderData[1];
}
alias _COMMCONFIG COMMCONFIG;
alias _COMMCONFIG* LPCOMMCONFIG;

struct _SYSTEM_INFO {
union {
  DWORD dwOemId;
struct {
  WORD wProcessorArchitecture;
  WORD wReserved;
}

}

  DWORD dwPageSize;
  LPVOID lpMinimumApplicationAddress;
  LPVOID lpMaximumApplicationAddress;
  DWORD_PTR dwActiveProcessorMask;
  DWORD dwNumberOfProcessors;
  DWORD dwProcessorType;
  DWORD dwAllocationGranularity;
  WORD wProcessorLevel;
  WORD wProcessorRevision;
}
alias _SYSTEM_INFO SYSTEM_INFO;
alias _SYSTEM_INFO* LPSYSTEM_INFO;

alias FreeLibrary FreeModule;
// #define MakeProcInstance(lpProc,hInstance) (lpProc)
// #define FreeProcInstance(lpProc) (lpProc)

enum : uint { GMEM_FIXED = 0x0000 }
enum : uint { GMEM_MOVEABLE = 0x0002 }
enum : uint { GMEM_NOCOMPACT = 0x0010 }
enum : uint { GMEM_NODISCARD = 0x0020 }
enum : uint { GMEM_ZEROINIT = 0x0040 }
enum : uint { GMEM_MODIFY = 0x0080 }
enum : uint { GMEM_DISCARDABLE = 0x0100 }
enum : uint { GMEM_NOT_BANKED = 0x1000 }
enum : uint { GMEM_SHARE = 0x2000 }
enum : uint { GMEM_DDESHARE = 0x2000 }
enum : uint { GMEM_NOTIFY = 0x4000 }
alias GMEM_NOT_BANKED GMEM_LOWER;
enum : uint { GMEM_VALID_FLAGS = 0x7F72 }
enum : uint { GMEM_INVALID_HANDLE = 0x8000 }

enum : uint { GHND = GMEM_MOVEABLE | GMEM_ZEROINIT }
enum : uint { GPTR = GMEM_FIXED | GMEM_ZEROINIT }

// #define GlobalLRUNewest( h ) ((HANDLE)(h))
// #define GlobalLRUOldest( h ) ((HANDLE)(h))
// #define GlobalDiscard( h ) GlobalReAlloc( (h), 0, GMEM_MOVEABLE )

enum : uint { GMEM_DISCARDED = 0x4000 }
enum : uint { GMEM_LOCKCOUNT = 0x00FF }

struct _MEMORYSTATUS {
  DWORD dwLength;
  DWORD dwMemoryLoad;
  SIZE_T dwTotalPhys;
  SIZE_T dwAvailPhys;
  SIZE_T dwTotalPageFile;
  SIZE_T dwAvailPageFile;
  SIZE_T dwTotalVirtual;
  SIZE_T dwAvailVirtual;
}
alias _MEMORYSTATUS MEMORYSTATUS;
alias _MEMORYSTATUS* LPMEMORYSTATUS;

enum : uint { LMEM_FIXED = 0x0000 }
enum : uint { LMEM_MOVEABLE = 0x0002 }
enum : uint { LMEM_NOCOMPACT = 0x0010 }
enum : uint { LMEM_NODISCARD = 0x0020 }
enum : uint { LMEM_ZEROINIT = 0x0040 }
enum : uint { LMEM_MODIFY = 0x0080 }
enum : uint { LMEM_DISCARDABLE = 0x0F00 }
enum : uint { LMEM_VALID_FLAGS = 0x0F72 }
enum : uint { LMEM_INVALID_HANDLE = 0x8000 }

enum : uint { LHND = LMEM_MOVEABLE | LMEM_ZEROINIT }
enum : uint { LPTR = LMEM_FIXED | LMEM_ZEROINIT }

enum : uint { NONZEROLHND = LMEM_MOVEABLE }
enum : uint { NONZEROLPTR = LMEM_FIXED }

// #define LocalDiscard( h ) LocalReAlloc( (h), 0, LMEM_MOVEABLE )

enum : uint { LMEM_DISCARDED = 0x4000 }
enum : uint { LMEM_LOCKCOUNT = 0x00FF }

enum : uint { DEBUG_PROCESS = 0x00000001 }
enum : uint { DEBUG_ONLY_THIS_PROCESS = 0x00000002 }

enum : uint { CREATE_SUSPENDED = 0x00000004 }

enum : uint { DETACHED_PROCESS = 0x00000008 }

enum : uint { CREATE_NEW_CONSOLE = 0x00000010 }

enum : uint { NORMAL_PRIORITY_CLASS = 0x00000020 }
enum : uint { IDLE_PRIORITY_CLASS = 0x00000040 }
enum : uint { HIGH_PRIORITY_CLASS = 0x00000080 }
enum : uint { REALTIME_PRIORITY_CLASS = 0x00000100 }

enum : uint { CREATE_NEW_PROCESS_GROUP = 0x00000200 }
enum : uint { CREATE_UNICODE_ENVIRONMENT = 0x00000400 }

enum : uint { CREATE_SEPARATE_WOW_VDM = 0x00000800 }
enum : uint { CREATE_SHARED_WOW_VDM = 0x00001000 }
enum : uint { CREATE_FORCEDOS = 0x00002000 }

enum : uint { BELOW_NORMAL_PRIORITY_CLASS = 0x00004000 }
enum : uint { ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000 }
enum : uint { STACK_SIZE_PARAM_IS_A_RESERVATION = 0x00010000 }

enum : uint { CREATE_BREAKAWAY_FROM_JOB = 0x01000000 }
enum : uint { CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000 }

enum : uint { CREATE_DEFAULT_ERROR_MODE = 0x04000000 }
enum : uint { CREATE_NO_WINDOW = 0x08000000 }

enum : uint { PROFILE_USER = 0x10000000 }
enum : uint { PROFILE_KERNEL = 0x20000000 }
enum : uint { PROFILE_SERVER = 0x40000000 }

enum : uint { CREATE_IGNORE_SYSTEM_DEFAULT = 0x80000000 }

alias THREAD_BASE_PRIORITY_MIN THREAD_PRIORITY_LOWEST;
enum : uint { THREAD_PRIORITY_BELOW_NORMAL = THREAD_PRIORITY_LOWEST+1 }
enum : uint { THREAD_PRIORITY_NORMAL = 0 }
alias THREAD_BASE_PRIORITY_MAX THREAD_PRIORITY_HIGHEST;
enum : uint { THREAD_PRIORITY_ABOVE_NORMAL = THREAD_PRIORITY_HIGHEST-1 }
enum : uint { THREAD_PRIORITY_ERROR_RETURN = MAXLONG }

alias THREAD_BASE_PRIORITY_LOWRT THREAD_PRIORITY_TIME_CRITICAL;
alias THREAD_BASE_PRIORITY_IDLE THREAD_PRIORITY_IDLE;

enum : uint { EXCEPTION_DEBUG_EVENT = 1 }
enum : uint { CREATE_THREAD_DEBUG_EVENT = 2 }
enum : uint { CREATE_PROCESS_DEBUG_EVENT = 3 }
enum : uint { EXIT_THREAD_DEBUG_EVENT = 4 }
enum : uint { EXIT_PROCESS_DEBUG_EVENT = 5 }
enum : uint { LOAD_DLL_DEBUG_EVENT = 6 }
enum : uint { UNLOAD_DLL_DEBUG_EVENT = 7 }
enum : uint { OUTPUT_DEBUG_STRING_EVENT = 8 }
enum : uint { RIP_EVENT = 9 }

struct _EXCEPTION_DEBUG_INFO {
  EXCEPTION_RECORD ExceptionRecord;
  DWORD dwFirstChance;
}
alias _EXCEPTION_DEBUG_INFO EXCEPTION_DEBUG_INFO;
alias _EXCEPTION_DEBUG_INFO* LPEXCEPTION_DEBUG_INFO;

struct _CREATE_THREAD_DEBUG_INFO {
  HANDLE hThread;
  LPVOID lpThreadLocalBase;
  LPTHREAD_START_ROUTINE lpStartAddress;
}
alias _CREATE_THREAD_DEBUG_INFO CREATE_THREAD_DEBUG_INFO;
alias _CREATE_THREAD_DEBUG_INFO* LPCREATE_THREAD_DEBUG_INFO;

struct _CREATE_PROCESS_DEBUG_INFO {
  HANDLE hFile;
  HANDLE hProcess;
  HANDLE hThread;
  LPVOID lpBaseOfImage;
  DWORD dwDebugInfoFileOffset;
  DWORD nDebugInfoSize;
  LPVOID lpThreadLocalBase;
  LPTHREAD_START_ROUTINE lpStartAddress;
  LPVOID lpImageName;
  WORD fUnicode;
}
alias _CREATE_PROCESS_DEBUG_INFO CREATE_PROCESS_DEBUG_INFO;
alias _CREATE_PROCESS_DEBUG_INFO* LPCREATE_PROCESS_DEBUG_INFO;

struct _EXIT_THREAD_DEBUG_INFO {
  DWORD dwExitCode;
}
alias _EXIT_THREAD_DEBUG_INFO EXIT_THREAD_DEBUG_INFO;
alias _EXIT_THREAD_DEBUG_INFO* LPEXIT_THREAD_DEBUG_INFO;

struct _EXIT_PROCESS_DEBUG_INFO {
  DWORD dwExitCode;
}
alias _EXIT_PROCESS_DEBUG_INFO EXIT_PROCESS_DEBUG_INFO;
alias _EXIT_PROCESS_DEBUG_INFO* LPEXIT_PROCESS_DEBUG_INFO;

struct _LOAD_DLL_DEBUG_INFO {
  HANDLE hFile;
  LPVOID lpBaseOfDll;
  DWORD dwDebugInfoFileOffset;
  DWORD nDebugInfoSize;
  LPVOID lpImageName;
  WORD fUnicode;
}
alias _LOAD_DLL_DEBUG_INFO LOAD_DLL_DEBUG_INFO;
alias _LOAD_DLL_DEBUG_INFO* LPLOAD_DLL_DEBUG_INFO;

struct _UNLOAD_DLL_DEBUG_INFO {
  LPVOID lpBaseOfDll;
}
alias _UNLOAD_DLL_DEBUG_INFO UNLOAD_DLL_DEBUG_INFO;
alias _UNLOAD_DLL_DEBUG_INFO* LPUNLOAD_DLL_DEBUG_INFO;

struct _OUTPUT_DEBUG_STRING_INFO {
  LPSTR lpDebugStringData;
  WORD fUnicode;
  WORD nDebugStringLength;
}
alias _OUTPUT_DEBUG_STRING_INFO OUTPUT_DEBUG_STRING_INFO;
alias _OUTPUT_DEBUG_STRING_INFO* LPOUTPUT_DEBUG_STRING_INFO;

struct _RIP_INFO {
  DWORD dwError;
  DWORD dwType;
}
alias _RIP_INFO RIP_INFO;
alias _RIP_INFO* LPRIP_INFO;

struct _DEBUG_EVENT {
  DWORD dwDebugEventCode;
  DWORD dwProcessId;
  DWORD dwThreadId;
union {
  EXCEPTION_DEBUG_INFO Exception;
  CREATE_THREAD_DEBUG_INFO CreateThread;
  CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
  EXIT_THREAD_DEBUG_INFO ExitThread;
  EXIT_PROCESS_DEBUG_INFO ExitProcess;
  LOAD_DLL_DEBUG_INFO LoadDll;
  UNLOAD_DLL_DEBUG_INFO UnloadDll;
  OUTPUT_DEBUG_STRING_INFO DebugString;
  RIP_INFO RipInfo;
}

}
alias _DEBUG_EVENT DEBUG_EVENT;
alias _DEBUG_EVENT* LPDEBUG_EVENT;

// #if !defined(MIDL_PASS)
alias PCONTEXT LPCONTEXT;
alias PEXCEPTION_RECORD LPEXCEPTION_RECORD;
alias PEXCEPTION_POINTERS LPEXCEPTION_POINTERS;
// #endif

enum : uint { DRIVE_UNKNOWN = 0 }
enum : uint { DRIVE_NO_ROOT_DIR = 1 }
enum : uint { DRIVE_REMOVABLE = 2 }
enum : uint { DRIVE_FIXED = 3 }
enum : uint { DRIVE_REMOTE = 4 }
enum : uint { DRIVE_CDROM = 5 }
enum : uint { DRIVE_RAMDISK = 6 }

// #ifndef _MAC
// #define GetFreeSpace(w) (0x100000L)
// #else
// ...
// #endif

enum : uint { FILE_TYPE_UNKNOWN = 0x0000 }
enum : uint { FILE_TYPE_DISK = 0x0001 }
enum : uint { FILE_TYPE_CHAR = 0x0002 }
enum : uint { FILE_TYPE_PIPE = 0x0003 }
enum : uint { FILE_TYPE_REMOTE = 0x8000 }

enum : uint { STD_INPUT_HANDLE = cast(DWORD)-10 }
enum : uint { STD_OUTPUT_HANDLE = cast(DWORD)-11 }
enum : uint { STD_ERROR_HANDLE = cast(DWORD)-12 }

enum : uint { NOPARITY = 0 }
enum : uint { ODDPARITY = 1 }
enum : uint { EVENPARITY = 2 }
enum : uint { MARKPARITY = 3 }
enum : uint { SPACEPARITY = 4 }

enum : uint { ONESTOPBIT = 0 }
enum : uint { ONE5STOPBITS = 1 }
enum : uint { TWOSTOPBITS = 2 }

enum : uint { IGNORE = 0 }
enum : uint { INFINITE = 0xFFFFFFFF }

enum : uint { CBR_110 = 110 }
enum : uint { CBR_300 = 300 }
enum : uint { CBR_600 = 600 }
enum : uint { CBR_1200 = 1200 }
enum : uint { CBR_2400 = 2400 }
enum : uint { CBR_4800 = 4800 }
enum : uint { CBR_9600 = 9600 }
enum : uint { CBR_14400 = 14400 }
enum : uint { CBR_19200 = 19200 }
enum : uint { CBR_38400 = 38400 }
enum : uint { CBR_56000 = 56000 }
enum : uint { CBR_57600 = 57600 }
enum : uint { CBR_115200 = 115200 }
enum : uint { CBR_128000 = 128000 }
enum : uint { CBR_256000 = 256000 }

enum : uint { CE_RXOVER = 0x0001 }
enum : uint { CE_OVERRUN = 0x0002 }
enum : uint { CE_RXPARITY = 0x0004 }
enum : uint { CE_FRAME = 0x0008 }
enum : uint { CE_BREAK = 0x0010 }
enum : uint { CE_TXFULL = 0x0100 }
enum : uint { CE_PTO = 0x0200 }
enum : uint { CE_IOE = 0x0400 }
enum : uint { CE_DNS = 0x0800 }
enum : uint { CE_OOP = 0x1000 }
enum : uint { CE_MODE = 0x8000 }

enum { IE_BADID = -1 }
enum { IE_OPEN = -2 }
enum { IE_NOPEN = -3 }
enum { IE_MEMORY = -4 }
enum { IE_DEFAULT = -5 }
enum { IE_HARDWARE = -10 }
enum { IE_BYTESIZE = -11 }
enum { IE_BAUDRATE = -12 }

enum : uint { EV_RXCHAR = 0x0001 }
enum : uint { EV_RXFLAG = 0x0002 }
enum : uint { EV_TXEMPTY = 0x0004 }
enum : uint { EV_CTS = 0x0008 }
enum : uint { EV_DSR = 0x0010 }
enum : uint { EV_RLSD = 0x0020 }
enum : uint { EV_BREAK = 0x0040 }
enum : uint { EV_ERR = 0x0080 }
enum : uint { EV_RING = 0x0100 }
enum : uint { EV_PERR = 0x0200 }
enum : uint { EV_RX80FULL = 0x0400 }
enum : uint { EV_EVENT1 = 0x0800 }
enum : uint { EV_EVENT2 = 0x1000 }

enum : uint { SETXOFF = 1 }
enum : uint { SETXON = 2 }
enum : uint { SETRTS = 3 }
enum : uint { CLRRTS = 4 }
enum : uint { SETDTR = 5 }
enum : uint { CLRDTR = 6 }
enum : uint { RESETDEV = 7 }
enum : uint { SETBREAK = 8 }
enum : uint { CLRBREAK = 9 }

enum : uint { PURGE_TXABORT = 0x0001 }
enum : uint { PURGE_RXABORT = 0x0002 }
enum : uint { PURGE_TXCLEAR = 0x0004 }
enum : uint { PURGE_RXCLEAR = 0x0008 }

enum : uint { LPTx = 0x80 }

enum : uint { MS_CTS_ON = cast(DWORD)0x0010 }
enum : uint { MS_DSR_ON = cast(DWORD)0x0020 }
enum : uint { MS_RING_ON = cast(DWORD)0x0040 }
enum : uint { MS_RLSD_ON = cast(DWORD)0x0080 }

enum : uint { S_QUEUEEMPTY = 0 }
enum : uint { S_THRESHOLD = 1 }
enum : uint { S_ALLTHRESHOLD = 2 }

enum : uint { S_NORMAL = 0 }
enum : uint { S_LEGATO = 1 }
enum : uint { S_STACCATO = 2 }

enum : uint { S_PERIOD512 = 0 }
enum : uint { S_PERIOD1024 = 1 }
enum : uint { S_PERIOD2048 = 2 }
enum : uint { S_PERIODVOICE = 3 }
enum : uint { S_WHITE512 = 4 }
enum : uint { S_WHITE1024 = 5 }
enum : uint { S_WHITE2048 = 6 }
enum : uint { S_WHITEVOICE = 7 }

enum { S_SERDVNA = -1 }
enum { S_SEROFM = -2 }
enum { S_SERMACT = -3 }
enum { S_SERQFUL = -4 }
enum { S_SERBDNT = -5 }
enum { S_SERDLN = -6 }
enum { S_SERDCC = -7 }
enum { S_SERDTP = -8 }
enum { S_SERDVL = -9 }
enum { S_SERDMD = -10 }
enum { S_SERDSH = -11 }
enum { S_SERDPT = -12 }
enum { S_SERDFQ = -13 }
enum { S_SERDDR = -14 }
enum { S_SERDSR = -15 }
enum { S_SERDST = -16 }

enum : uint { NMPWAIT_WAIT_FOREVER = 0xffffffff }
enum : uint { NMPWAIT_NOWAIT = 0x00000001 }
enum : uint { NMPWAIT_USE_DEFAULT_WAIT = 0x00000000 }

alias FILE_CASE_PRESERVED_NAMES FS_CASE_IS_PRESERVED;
alias FILE_CASE_SENSITIVE_SEARCH FS_CASE_SENSITIVE;
alias FILE_UNICODE_ON_DISK FS_UNICODE_STORED_ON_DISK;
alias FILE_PERSISTENT_ACLS FS_PERSISTENT_ACLS;
alias FILE_VOLUME_IS_COMPRESSED FS_VOL_IS_COMPRESSED;
alias FILE_FILE_COMPRESSION FS_FILE_COMPRESSION;
alias FILE_SUPPORTS_ENCRYPTION FS_FILE_ENCRYPTION;

alias SECTION_QUERY FILE_MAP_COPY;
alias SECTION_MAP_WRITE FILE_MAP_WRITE;
alias SECTION_MAP_READ FILE_MAP_READ;
alias SECTION_ALL_ACCESS FILE_MAP_ALL_ACCESS;

enum : uint { OF_READ = 0x00000000 }
enum : uint { OF_WRITE = 0x00000001 }
enum : uint { OF_READWRITE = 0x00000002 }
enum : uint { OF_SHARE_COMPAT = 0x00000000 }
enum : uint { OF_SHARE_EXCLUSIVE = 0x00000010 }
enum : uint { OF_SHARE_DENY_WRITE = 0x00000020 }
enum : uint { OF_SHARE_DENY_READ = 0x00000030 }
enum : uint { OF_SHARE_DENY_NONE = 0x00000040 }
enum : uint { OF_PARSE = 0x00000100 }
enum : uint { OF_DELETE = 0x00000200 }
enum : uint { OF_VERIFY = 0x00000400 }
enum : uint { OF_CANCEL = 0x00000800 }
enum : uint { OF_CREATE = 0x00001000 }
enum : uint { OF_PROMPT = 0x00002000 }
enum : uint { OF_EXIST = 0x00004000 }
enum : uint { OF_REOPEN = 0x00008000 }

enum : uint { OFS_MAXPATHNAME = 128 }
struct _OFSTRUCT {
  BYTE cBytes;
  BYTE fFixedDisk;
  WORD nErrCode;
  WORD Reserved1;
  WORD Reserved2;
  CHAR szPathName[OFS_MAXPATHNAME];
}
alias _OFSTRUCT OFSTRUCT;
alias _OFSTRUCT* LPOFSTRUCT;
alias _OFSTRUCT* POFSTRUCT;

// #ifndef NOWINBASEINTERLOCK

// #ifndef _NTOS_

// #if defined(_M_IA64) && !defined(RC_INVOKED)

// #...
// #...
// #...
// #...
// #...
// #...
// #...

// ...

// ...

// ...

// ...

// ...

// ...

// ...

// #...
// #...
// #...
// #...
// #...
// #...
// #...

// #elif defined(_M_AMD64) && !defined(RC_INVOKED)

// #...
// #...
// #...
// #...
// #...
// #...
// #...

// ...

// ...

// ...

// ...

// ...

// ...

// ...

// #...
// #...
// #...
// #...
// #...
// #...
// #...

// #else           // X86 interlocked definitions

extern(Windows) export LONG InterlockedIncrement(
  LONG *lpAddend);

extern(Windows) export LONG InterlockedDecrement(
  LONG *lpAddend);

extern(Windows) export LONG InterlockedExchange(
  LONG *Target,
  LONG Value);

void* InterlockedExchangePointer(void** t, void* v){ return cast(void*)InterlockedExchange(cast(PLONG)t, cast(LONG)v); }

extern(Windows) export LONG InterlockedExchangeAdd(
  LONG *Addend,
  LONG Value);

extern(Windows) export LONG InterlockedCompareExchange(
  LONG *Destination,
  LONG Exchange,
  LONG Comperand);

// #ifdef __cplusplus

PVOID __InlineInterlockedCompareExchangePointer(PVOID* Destination, PVOID ExChange, PVOID Comperand){ return(cast(PVOID)cast(LONG_PTR)InterlockedCompareExchange(cast(LONG*)Destination, cast(LONG)cast(LONG_PTR)ExChange, cast(LONG)cast(LONG_PTR)Comperand)); }
alias __InlineInterlockedCompareExchangePointer InterlockedCompareExchangePointer;

// #else

// #...
// ...

// #endif /* __cplusplus */

// #endif /* X86 | IA64 */

// #if defined(_SLIST_HEADER_) && !defined(_NTOSP_)

// ...

// ...

// ...

// ...

// ...

// #endif /* _SLIST_HEADER_ */
// #endif /* _NTOS_ */

// #endif /* NOWINBASEINTERLOCK */

extern(Windows) export BOOL FreeResource(
  HGLOBAL hResData);

extern(Windows) export LPVOID LockResource(
  HGLOBAL hResData);

// #define UnlockResource(hResData) ((hResData), 0)
enum : uint { MAXINTATOM = 0xC000 }
// #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i)))
enum : ATOM { INVALID_ATOM = 0 }

// #ifndef _MAC
// ???
// ???
// #else
// ...
// #endif
// WinMain

extern(Windows) export BOOL FreeLibrary(
  HMODULE hLibModule);

extern(Windows) export VOID FreeLibraryAndExitThread(
  HMODULE hLibModule,
  DWORD dwExitCode);

extern(Windows) export BOOL DisableThreadLibraryCalls(
  HMODULE hLibModule);

extern(Windows) export FARPROC GetProcAddress(
  HMODULE hModule,
  LPCSTR lpProcName);

extern(Windows) export DWORD GetVersion();

extern(Windows) export HGLOBAL GlobalAlloc(
  UINT uFlags,
  SIZE_T dwBytes);

extern(Windows) export HGLOBAL GlobalReAlloc(
  HGLOBAL hMem,
  SIZE_T dwBytes,
  UINT uFlags);

extern(Windows) export SIZE_T GlobalSize(
  HGLOBAL hMem);

extern(Windows) export UINT GlobalFlags(
  HGLOBAL hMem);

extern(Windows) export LPVOID GlobalLock(
  HGLOBAL hMem);

extern(Windows) export HGLOBAL GlobalHandle(
  LPCVOID pMem);

extern(Windows) export BOOL GlobalUnlock(
  HGLOBAL hMem);

extern(Windows) export HGLOBAL GlobalFree(
  HGLOBAL hMem);

extern(Windows) export SIZE_T GlobalCompact(
  DWORD dwMinFree);

extern(Windows) export VOID GlobalFix(
  HGLOBAL hMem);

extern(Windows) export VOID GlobalUnfix(
  HGLOBAL hMem);

extern(Windows) export LPVOID GlobalWire(
  HGLOBAL hMem);

extern(Windows) export BOOL GlobalUnWire(
  HGLOBAL hMem);

extern(Windows) export VOID GlobalMemoryStatus(
  LPMEMORYSTATUS lpBuffer);

struct _MEMORYSTATUSEX {
  DWORD dwLength;
  DWORD dwMemoryLoad;
  DWORDLONG ullTotalPhys;
  DWORDLONG ullAvailPhys;
  DWORDLONG ullTotalPageFile;
  DWORDLONG ullAvailPageFile;
  DWORDLONG ullTotalVirtual;
  DWORDLONG ullAvailVirtual;
  DWORDLONG ullAvailExtendedVirtual;
}
alias _MEMORYSTATUSEX MEMORYSTATUSEX;
alias _MEMORYSTATUSEX* LPMEMORYSTATUSEX;

extern(Windows) export BOOL GlobalMemoryStatusEx(
  LPMEMORYSTATUSEX lpBuffer);

extern(Windows) export HLOCAL LocalAlloc(
  UINT uFlags,
  SIZE_T uBytes);

extern(Windows) export HLOCAL LocalReAlloc(
  HLOCAL hMem,
  SIZE_T uBytes,
  UINT uFlags);

extern(Windows) export LPVOID LocalLock(
  HLOCAL hMem);

extern(Windows) export HLOCAL LocalHandle(
  LPCVOID pMem);

extern(Windows) export BOOL LocalUnlock(
  HLOCAL hMem);

extern(Windows) export SIZE_T LocalSize(
  HLOCAL hMem);

extern(Windows) export UINT LocalFlags(
  HLOCAL hMem);

extern(Windows) export HLOCAL LocalFree(
  HLOCAL hMem);

extern(Windows) export SIZE_T LocalShrink(
  HLOCAL hMem,
  UINT cbNewSize);

extern(Windows) export SIZE_T LocalCompact(
  UINT uMinFree);

extern(Windows) export BOOL FlushInstructionCache(
  HANDLE hProcess,
  LPCVOID lpBaseAddress,
  SIZE_T dwSize);

extern(Windows) export LPVOID VirtualAlloc(
  LPVOID lpAddress,
  SIZE_T dwSize,
  DWORD flAllocationType,
  DWORD flProtect);

extern(Windows) export BOOL VirtualFree(
  LPVOID lpAddress,
  SIZE_T dwSize,
  DWORD dwFreeType);

extern(Windows) export BOOL VirtualProtect(
  LPVOID lpAddress,
  SIZE_T dwSize,
  DWORD flNewProtect,
  PDWORD lpflOldProtect);

extern(Windows) export SIZE_T VirtualQuery(
  LPCVOID lpAddress,
  PMEMORY_BASIC_INFORMATION lpBuffer,
  SIZE_T dwLength);

extern(Windows) export LPVOID VirtualAllocEx(
  HANDLE hProcess,
  LPVOID lpAddress,
  SIZE_T dwSize,
  DWORD flAllocationType,
  DWORD flProtect);

extern(Windows) export UINT GetWriteWatch(
  DWORD dwFlags,
  PVOID lpBaseAddress,
  SIZE_T dwRegionSize,
  PVOID *lpAddresses,
  PULONG_PTR lpdwCount,
  PULONG lpdwGranularity);

extern(Windows) export UINT ResetWriteWatch(
  LPVOID lpBaseAddress,
  SIZE_T dwRegionSize);

extern(Windows) export BOOL VirtualFreeEx(
  HANDLE hProcess,
  LPVOID lpAddress,
  SIZE_T dwSize,
  DWORD dwFreeType);

extern(Windows) export BOOL VirtualProtectEx(
  HANDLE hProcess,
  LPVOID lpAddress,
  SIZE_T dwSize,
  DWORD flNewProtect,
  PDWORD lpflOldProtect);

extern(Windows) export SIZE_T VirtualQueryEx(
  HANDLE hProcess,
  LPCVOID lpAddress,
  PMEMORY_BASIC_INFORMATION lpBuffer,
  SIZE_T dwLength);

extern(Windows) export HANDLE HeapCreate(
  DWORD flOptions,
  SIZE_T dwInitialSize,
  SIZE_T dwMaximumSize);

extern(Windows) export BOOL HeapDestroy(
  HANDLE hHeap);

extern(Windows) export LPVOID HeapAlloc(
  HANDLE hHeap,
  DWORD dwFlags,
  SIZE_T dwBytes);

extern(Windows) export LPVOID HeapReAlloc(
  HANDLE hHeap,
  DWORD dwFlags,
  LPVOID lpMem,
  SIZE_T dwBytes);

extern(Windows) export BOOL HeapFree(
  HANDLE hHeap,
  DWORD dwFlags,
  LPVOID lpMem);

extern(Windows) export SIZE_T HeapSize(
  HANDLE hHeap,
  DWORD dwFlags,
  LPCVOID lpMem);

extern(Windows) export BOOL HeapValidate(
  HANDLE hHeap,
  DWORD dwFlags,
  LPCVOID lpMem);

extern(Windows) export SIZE_T HeapCompact(
  HANDLE hHeap,
  DWORD dwFlags);

extern(Windows) export HANDLE GetProcessHeap();

extern(Windows) export DWORD GetProcessHeaps(
  DWORD NumberOfHeaps,
  PHANDLE ProcessHeaps);

struct _PROCESS_HEAP_ENTRY {
  PVOID lpData;
  DWORD cbData;
  BYTE cbOverhead;
  BYTE iRegionIndex;
  WORD wFlags;
union {
struct {
  HANDLE hMem;
  DWORD dwReserved[ 3 ];
}

struct {
  DWORD dwCommittedSize;
  DWORD dwUnCommittedSize;
  LPVOID lpFirstBlock;
  LPVOID lpLastBlock;
}

}

}
alias _PROCESS_HEAP_ENTRY PROCESS_HEAP_ENTRY;
alias _PROCESS_HEAP_ENTRY* LPPROCESS_HEAP_ENTRY;
alias _PROCESS_HEAP_ENTRY* PPROCESS_HEAP_ENTRY;

enum : uint { PROCESS_HEAP_REGION = 0x0001 }
enum : uint { PROCESS_HEAP_UNCOMMITTED_RANGE = 0x0002 }
enum : uint { PROCESS_HEAP_ENTRY_BUSY = 0x0004 }
enum : uint { PROCESS_HEAP_ENTRY_MOVEABLE = 0x0010 }
enum : uint { PROCESS_HEAP_ENTRY_DDESHARE = 0x0020 }

extern(Windows) export BOOL HeapLock(
  HANDLE hHeap);

extern(Windows) export BOOL HeapUnlock(
  HANDLE hHeap);

extern(Windows) export BOOL HeapWalk(
  HANDLE hHeap,
  LPPROCESS_HEAP_ENTRY lpEntry);

extern(Windows) export BOOL HeapSetInformation(
  PVOID HeapHandle, 
  HEAP_INFORMATION_CLASS HeapInformationClass,
  PVOID HeapInformation ,
  SIZE_T HeapInformationLength );

extern(Windows) export BOOL HeapQueryInformation(
  PVOID HeapHandle, 
  HEAP_INFORMATION_CLASS HeapInformationClass,
  PVOID HeapInformation ,
  SIZE_T HeapInformationLength ,
  PSIZE_T ReturnLength );

enum : uint { SCS_32BIT_BINARY = 0 }
enum : uint { SCS_DOS_BINARY = 1 }
enum : uint { SCS_WOW_BINARY = 2 }
enum : uint { SCS_PIF_BINARY = 3 }
enum : uint { SCS_POSIX_BINARY = 4 }
enum : uint { SCS_OS216_BINARY = 5 }
enum : uint { SCS_64BIT_BINARY = 6 }

// #if defined(_WIN64)
// #...
// #else
alias SCS_32BIT_BINARY SCS_THIS_PLATFORM_BINARY;
// #endif

extern(Windows) export BOOL GetBinaryTypeA(
  LPCSTR lpApplicationName,
  LPDWORD lpBinaryType);
extern(Windows) export BOOL GetBinaryTypeW(
  LPCWSTR lpApplicationName,
  LPDWORD lpBinaryType);
// #ifdef UNICODE
alias GetBinaryTypeW GetBinaryType;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetShortPathNameA(
  LPCSTR lpszLongPath,
  LPSTR lpszShortPath,
  DWORD cchBuffer);
extern(Windows) export DWORD GetShortPathNameW(
  LPCWSTR lpszLongPath,
  LPWSTR lpszShortPath,
  DWORD cchBuffer);
// #ifdef UNICODE
alias GetShortPathNameW GetShortPathName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetLongPathNameA(
  LPCSTR lpszShortPath,
  LPSTR lpszLongPath,
  DWORD cchBuffer);
extern(Windows) export DWORD GetLongPathNameW(
  LPCWSTR lpszShortPath,
  LPWSTR lpszLongPath,
  DWORD cchBuffer);
// #ifdef UNICODE
alias GetLongPathNameW GetLongPathName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetProcessAffinityMask(
  HANDLE hProcess,
  PDWORD_PTR lpProcessAffinityMask,
  PDWORD_PTR lpSystemAffinityMask);

extern(Windows) export BOOL SetProcessAffinityMask(
  HANDLE hProcess,
  DWORD_PTR dwProcessAffinityMask);

extern(Windows) export BOOL GetProcessTimes(
  HANDLE hProcess,
  LPFILETIME lpCreationTime,
  LPFILETIME lpExitTime,
  LPFILETIME lpKernelTime,
  LPFILETIME lpUserTime);

extern(Windows) export BOOL GetProcessIoCounters(
  HANDLE hProcess,
  PIO_COUNTERS lpIoCounters);

extern(Windows) export BOOL GetProcessWorkingSetSize(
  HANDLE hProcess,
  PSIZE_T lpMinimumWorkingSetSize,
  PSIZE_T lpMaximumWorkingSetSize);

extern(Windows) export BOOL SetProcessWorkingSetSize(
  HANDLE hProcess,
  SIZE_T dwMinimumWorkingSetSize,
  SIZE_T dwMaximumWorkingSetSize);

extern(Windows) export HANDLE OpenProcess(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  DWORD dwProcessId);

extern(Windows) export HANDLE GetCurrentProcess();

extern(Windows) export DWORD GetCurrentProcessId();

extern(Windows) export VOID ExitProcess(
  UINT uExitCode);

extern(Windows) export BOOL TerminateProcess(
  HANDLE hProcess,
  UINT uExitCode);

extern(Windows) export BOOL GetExitCodeProcess(
  HANDLE hProcess,
  LPDWORD lpExitCode);

extern(Windows) export VOID FatalExit(
  int ExitCode);

extern(Windows) export LPSTR GetEnvironmentStrings();

extern(Windows) export LPWSTR GetEnvironmentStringsW();

// #ifdef UNICODE
alias GetEnvironmentStringsW GetEnvironmentStrings;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL FreeEnvironmentStringsA(
  LPSTR);
extern(Windows) export BOOL FreeEnvironmentStringsW(
  LPWSTR);
// #ifdef UNICODE
alias FreeEnvironmentStringsW FreeEnvironmentStrings;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export VOID RaiseException(
  DWORD dwExceptionCode,
  DWORD dwExceptionFlags,
  DWORD nNumberOfArguments,
  ULONG_PTR *lpArguments);

extern(Windows) export LONG UnhandledExceptionFilter(
  _EXCEPTION_POINTERS *ExceptionInfo);

extern(Windows) alias LONG function(  _EXCEPTION_POINTERS *ExceptionInfo ) PTOP_LEVEL_EXCEPTION_FILTER;
alias PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;

extern(Windows) export LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(
  LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);

// #if(_WIN32_WINNT >= 0x0400)

extern(Windows) export LPVOID CreateFiber(
  SIZE_T dwStackSize,
  LPFIBER_START_ROUTINE lpStartAddress,
  LPVOID lpParameter);

extern(Windows) export LPVOID CreateFiberEx(
  SIZE_T dwStackCommitSize,
  SIZE_T dwStackReserveSize,
  DWORD dwFlags,
  LPFIBER_START_ROUTINE lpStartAddress,
  LPVOID lpParameter);

extern(Windows) export VOID DeleteFiber(
  LPVOID lpFiber);

extern(Windows) export LPVOID ConvertThreadToFiber(
  LPVOID lpParameter);

extern(Windows) export BOOL ConvertFiberToThread();

extern(Windows) export VOID SwitchToFiber(
  LPVOID lpFiber);

extern(Windows) export BOOL SwitchToThread();
// #endif /* _WIN32_WINNT >= 0x0400 */

extern(Windows) export HANDLE CreateThread(
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  SIZE_T dwStackSize,
  LPTHREAD_START_ROUTINE lpStartAddress,
  LPVOID lpParameter,
  DWORD dwCreationFlags,
  LPDWORD lpThreadId);

extern(Windows) export HANDLE CreateRemoteThread(
  HANDLE hProcess,
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  SIZE_T dwStackSize,
  LPTHREAD_START_ROUTINE lpStartAddress,
  LPVOID lpParameter,
  DWORD dwCreationFlags,
  LPDWORD lpThreadId);

extern(Windows) export HANDLE GetCurrentThread();

extern(Windows) export DWORD GetCurrentThreadId();

extern(Windows) export DWORD_PTR SetThreadAffinityMask(
  HANDLE hThread,
  DWORD_PTR dwThreadAffinityMask);

// #if(_WIN32_WINNT >= 0x0400)
extern(Windows) export DWORD SetThreadIdealProcessor(
  HANDLE hThread,
  DWORD dwIdealProcessor);
// #endif /* _WIN32_WINNT >= 0x0400 */

extern(Windows) export BOOL SetProcessPriorityBoost(
  HANDLE hProcess,
  BOOL bDisablePriorityBoost);

extern(Windows) export BOOL GetProcessPriorityBoost(
  HANDLE hProcess,
  PBOOL pDisablePriorityBoost);

extern(Windows) export BOOL RequestWakeupLatency(
  LATENCY_TIME latency);

extern(Windows) export BOOL IsSystemResumeAutomatic();

extern(Windows) export HANDLE OpenThread(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  DWORD dwThreadId);

extern(Windows) export BOOL SetThreadPriority(
  HANDLE hThread,
  int nPriority);

extern(Windows) export BOOL SetThreadPriorityBoost(
  HANDLE hThread,
  BOOL bDisablePriorityBoost);

extern(Windows) export BOOL GetThreadPriorityBoost(
  HANDLE hThread,
  PBOOL pDisablePriorityBoost);

extern(Windows) export int GetThreadPriority(
  HANDLE hThread);

extern(Windows) export BOOL GetThreadTimes(
  HANDLE hThread,
  LPFILETIME lpCreationTime,
  LPFILETIME lpExitTime,
  LPFILETIME lpKernelTime,
  LPFILETIME lpUserTime);

extern(Windows) export VOID ExitThread(
  DWORD dwExitCode);

extern(Windows) export BOOL TerminateThread(
  HANDLE hThread,
  DWORD dwExitCode);

extern(Windows) export BOOL GetExitCodeThread(
  HANDLE hThread,
  LPDWORD lpExitCode);

extern(Windows) export BOOL GetThreadSelectorEntry(
  HANDLE hThread,
  DWORD dwSelector,
  LPLDT_ENTRY lpSelectorEntry);

extern(Windows) export EXECUTION_STATE SetThreadExecutionState(
  EXECUTION_STATE esFlags);

extern(Windows) export DWORD GetLastError();

extern(Windows) export VOID SetLastError(
  DWORD dwErrCode);

// #if !defined(RC_INVOKED) // RC warns because "WINBASE_DECLARE_RESTORE_LAST_ERROR" is a bit long.

// #if defined(WINBASE_DECLARE_RESTORE_LAST_ERROR)

// ...

// ...
// #...
// #...
// #...

// #endif
// #endif

bit HasOverlappedIoCompleted(LPOVERLAPPED lpOverlapped){ return (*lpOverlapped).Internal != STATUS_PENDING; }

extern(Windows) export BOOL GetOverlappedResult(
  HANDLE hFile,
  LPOVERLAPPED lpOverlapped,
  LPDWORD lpNumberOfBytesTransferred,
  BOOL bWait);

extern(Windows) export HANDLE CreateIoCompletionPort(
  HANDLE FileHandle,
  HANDLE ExistingCompletionPort,
  ULONG_PTR CompletionKey,
  DWORD NumberOfConcurrentThreads);

extern(Windows) export BOOL GetQueuedCompletionStatus(
  HANDLE CompletionPort,
  LPDWORD lpNumberOfBytesTransferred,
  PULONG_PTR lpCompletionKey,
  LPOVERLAPPED *lpOverlapped,
  DWORD dwMilliseconds);

extern(Windows) export BOOL PostQueuedCompletionStatus(
  HANDLE CompletionPort,
  DWORD dwNumberOfBytesTransferred,
  ULONG_PTR dwCompletionKey,
  LPOVERLAPPED lpOverlapped);

enum : uint { SEM_FAILCRITICALERRORS = 0x0001 }
enum : uint { SEM_NOGPFAULTERRORBOX = 0x0002 }
enum : uint { SEM_NOALIGNMENTFAULTEXCEPT = 0x0004 }
enum : uint { SEM_NOOPENFILEERRORBOX = 0x8000 }

extern(Windows) export UINT SetErrorMode(
  UINT uMode);

extern(Windows) export BOOL ReadProcessMemory(
  HANDLE hProcess,
  LPCVOID lpBaseAddress,
  LPVOID lpBuffer,
  SIZE_T nSize,
  SIZE_T * lpNumberOfBytesRead);

extern(Windows) export BOOL WriteProcessMemory(
  HANDLE hProcess,
  LPVOID lpBaseAddress,
  LPCVOID lpBuffer,
  SIZE_T nSize,
  SIZE_T * lpNumberOfBytesWritten);

// #if !defined(MIDL_PASS)
extern(Windows) export BOOL GetThreadContext(
  HANDLE hThread,
  LPCONTEXT lpContext);

extern(Windows) export BOOL SetThreadContext(
  HANDLE hThread,
  CONTEXT *lpContext);
// #endif

extern(Windows) export DWORD SuspendThread(
  HANDLE hThread);

extern(Windows) export DWORD ResumeThread(
  HANDLE hThread);

// #if(_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)

// ...

// ...

// #endif /* _WIN32_WINNT >= 0x0400 || _WIN32_WINDOWS > 0x0400 */

// #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
extern(Windows) export BOOL IsDebuggerPresent();
// #endif

extern(Windows) export VOID DebugBreak();

extern(Windows) export BOOL WaitForDebugEvent(
  LPDEBUG_EVENT lpDebugEvent,
  DWORD dwMilliseconds);

extern(Windows) export BOOL ContinueDebugEvent(
  DWORD dwProcessId,
  DWORD dwThreadId,
  DWORD dwContinueStatus);

extern(Windows) export BOOL DebugActiveProcess(
  DWORD dwProcessId);

extern(Windows) export BOOL DebugActiveProcessStop(
  DWORD dwProcessId);

extern(Windows) export BOOL DebugSetProcessKillOnExit(
  BOOL KillOnExit);

extern(Windows) export BOOL DebugBreakProcess(
  HANDLE Process);

extern(Windows) export VOID InitializeCriticalSection(
  LPCRITICAL_SECTION lpCriticalSection);

extern(Windows) export VOID EnterCriticalSection(
  LPCRITICAL_SECTION lpCriticalSection);

extern(Windows) export VOID LeaveCriticalSection(
  LPCRITICAL_SECTION lpCriticalSection);

// #if (_WIN32_WINNT >= 0x0403)
extern(Windows) export BOOL InitializeCriticalSectionAndSpinCount(
  LPCRITICAL_SECTION lpCriticalSection,
  DWORD dwSpinCount);

extern(Windows) export DWORD SetCriticalSectionSpinCount(
  LPCRITICAL_SECTION lpCriticalSection,
  DWORD dwSpinCount);
// #endif

// #if(_WIN32_WINNT >= 0x0400)
extern(Windows) export BOOL TryEnterCriticalSection(
  LPCRITICAL_SECTION lpCriticalSection);
// #endif /* _WIN32_WINNT >= 0x0400 */

extern(Windows) export VOID DeleteCriticalSection(
  LPCRITICAL_SECTION lpCriticalSection);

extern(Windows) export BOOL SetEvent(
  HANDLE hEvent);

extern(Windows) export BOOL ResetEvent(
  HANDLE hEvent);

extern(Windows) export BOOL PulseEvent(
  HANDLE hEvent);

extern(Windows) export BOOL ReleaseSemaphore(
  HANDLE hSemaphore,
  LONG lReleaseCount,
  LPLONG lpPreviousCount);

extern(Windows) export BOOL ReleaseMutex(
  HANDLE hMutex);

extern(Windows) export DWORD WaitForSingleObject(
  HANDLE hHandle,
  DWORD dwMilliseconds);

extern(Windows) export DWORD WaitForMultipleObjects(
  DWORD nCount,
  HANDLE *lpHandles,
  BOOL bWaitAll,
  DWORD dwMilliseconds);

extern(Windows) export VOID Sleep(
  DWORD dwMilliseconds);

extern(Windows) export HGLOBAL LoadResource(
  HMODULE hModule,
  HRSRC hResInfo);

extern(Windows) export DWORD SizeofResource(
  HMODULE hModule,
  HRSRC hResInfo);

extern(Windows) export ATOM GlobalDeleteAtom(
  ATOM nAtom);

extern(Windows) export BOOL InitAtomTable(
  DWORD nSize);

extern(Windows) export ATOM DeleteAtom(
  ATOM nAtom);

extern(Windows) export UINT SetHandleCount(
  UINT uNumber);

extern(Windows) export DWORD GetLogicalDrives();

extern(Windows) export BOOL LockFile(
  HANDLE hFile,
  DWORD dwFileOffsetLow,
  DWORD dwFileOffsetHigh,
  DWORD nNumberOfBytesToLockLow,
  DWORD nNumberOfBytesToLockHigh);

extern(Windows) export BOOL UnlockFile(
  HANDLE hFile,
  DWORD dwFileOffsetLow,
  DWORD dwFileOffsetHigh,
  DWORD nNumberOfBytesToUnlockLow,
  DWORD nNumberOfBytesToUnlockHigh);

extern(Windows) export BOOL LockFileEx(
  HANDLE hFile,
  DWORD dwFlags,
  DWORD dwReserved,
  DWORD nNumberOfBytesToLockLow,
  DWORD nNumberOfBytesToLockHigh,
  LPOVERLAPPED lpOverlapped);

enum : uint { LOCKFILE_FAIL_IMMEDIATELY = 0x00000001 }
enum : uint { LOCKFILE_EXCLUSIVE_LOCK = 0x00000002 }

extern(Windows) export BOOL UnlockFileEx(
  HANDLE hFile,
  DWORD dwReserved,
  DWORD nNumberOfBytesToUnlockLow,
  DWORD nNumberOfBytesToUnlockHigh,
  LPOVERLAPPED lpOverlapped);

struct _BY_HANDLE_FILE_INFORMATION {
  DWORD dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD dwVolumeSerialNumber;
  DWORD nFileSizeHigh;
  DWORD nFileSizeLow;
  DWORD nNumberOfLinks;
  DWORD nFileIndexHigh;
  DWORD nFileIndexLow;
}
alias _BY_HANDLE_FILE_INFORMATION BY_HANDLE_FILE_INFORMATION;
alias _BY_HANDLE_FILE_INFORMATION* PBY_HANDLE_FILE_INFORMATION;
alias _BY_HANDLE_FILE_INFORMATION* LPBY_HANDLE_FILE_INFORMATION;

extern(Windows) export BOOL GetFileInformationByHandle(
  HANDLE hFile,
  LPBY_HANDLE_FILE_INFORMATION lpFileInformation);

extern(Windows) export DWORD GetFileType(
  HANDLE hFile);

extern(Windows) export DWORD GetFileSize(
  HANDLE hFile,
  LPDWORD lpFileSizeHigh);

extern(Windows) export BOOL GetFileSizeEx(
  HANDLE hFile,
  PLARGE_INTEGER lpFileSize);

extern(Windows) export HANDLE GetStdHandle(
  DWORD nStdHandle);

extern(Windows) export BOOL SetStdHandle(
  DWORD nStdHandle,
  HANDLE hHandle);

extern(Windows) export BOOL WriteFile(
  HANDLE hFile,
  LPCVOID lpBuffer,
  DWORD nNumberOfBytesToWrite,
  LPDWORD lpNumberOfBytesWritten,
  LPOVERLAPPED lpOverlapped);

extern(Windows) export BOOL ReadFile(
  HANDLE hFile,
  LPVOID lpBuffer,
  DWORD nNumberOfBytesToRead,
  LPDWORD lpNumberOfBytesRead,
  LPOVERLAPPED lpOverlapped);

extern(Windows) export BOOL FlushFileBuffers(
  HANDLE hFile);

extern(Windows) export BOOL DeviceIoControl(
  HANDLE hDevice,
  DWORD dwIoControlCode,
  LPVOID lpInBuffer,
  DWORD nInBufferSize,
  LPVOID lpOutBuffer,
  DWORD nOutBufferSize,
  LPDWORD lpBytesReturned,
  LPOVERLAPPED lpOverlapped);

extern(Windows) export BOOL RequestDeviceWakeup(
  HANDLE hDevice);

extern(Windows) export BOOL CancelDeviceWakeupRequest(
  HANDLE hDevice);

extern(Windows) export BOOL GetDevicePowerState(
  HANDLE hDevice,
  BOOL *pfOn);

extern(Windows) export BOOL SetMessageWaitingIndicator(
  HANDLE hMsgIndicator,
  ULONG ulMsgCount);

extern(Windows) export BOOL SetEndOfFile(
  HANDLE hFile);

extern(Windows) export DWORD SetFilePointer(
  HANDLE hFile,
  LONG lDistanceToMove,
  PLONG lpDistanceToMoveHigh,
  DWORD dwMoveMethod);

extern(Windows) export BOOL SetFilePointerEx(
  HANDLE hFile,
  LARGE_INTEGER liDistanceToMove,
  PLARGE_INTEGER lpNewFilePointer,
  DWORD dwMoveMethod);

extern(Windows) export BOOL FindClose(
  HANDLE hFindFile);

extern(Windows) export BOOL GetFileTime(
  HANDLE hFile,
  LPFILETIME lpCreationTime,
  LPFILETIME lpLastAccessTime,
  LPFILETIME lpLastWriteTime);

extern(Windows) export BOOL SetFileTime(
  HANDLE hFile,
  FILETIME *lpCreationTime,
  FILETIME *lpLastAccessTime,
  FILETIME *lpLastWriteTime);

extern(Windows) export BOOL SetFileValidData(
  HANDLE hFile,
  LONGLONG ValidDataLength);

extern(Windows) export BOOL SetFileShortNameA(
  HANDLE hFile,
  LPCSTR lpShortName);
extern(Windows) export BOOL SetFileShortNameW(
  HANDLE hFile,
  LPCWSTR lpShortName);
// #ifdef UNICODE
alias SetFileShortNameW SetFileShortName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL CloseHandle(
  HANDLE hObject);

extern(Windows) export BOOL DuplicateHandle(
  HANDLE hSourceProcessHandle,
  HANDLE hSourceHandle,
  HANDLE hTargetProcessHandle,
  LPHANDLE lpTargetHandle,
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  DWORD dwOptions);

extern(Windows) export BOOL GetHandleInformation(
  HANDLE hObject,
  LPDWORD lpdwFlags);

extern(Windows) export BOOL SetHandleInformation(
  HANDLE hObject,
  DWORD dwMask,
  DWORD dwFlags);

enum : uint { HANDLE_FLAG_INHERIT = 0x00000001 }
enum : uint { HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002 }

enum : uint { HINSTANCE_ERROR = 32 }

extern(Windows) export DWORD LoadModule(
  LPCSTR lpModuleName,
  LPVOID lpParameterBlock);

extern(Windows) export UINT WinExec(
  LPCSTR lpCmdLine,
  UINT uCmdShow);

extern(Windows) export BOOL ClearCommBreak(
  HANDLE hFile);

extern(Windows) export BOOL ClearCommError(
  HANDLE hFile,
  LPDWORD lpErrors,
  LPCOMSTAT lpStat);

extern(Windows) export BOOL SetupComm(
  HANDLE hFile,
  DWORD dwInQueue,
  DWORD dwOutQueue);

extern(Windows) export BOOL EscapeCommFunction(
  HANDLE hFile,
  DWORD dwFunc);

extern(Windows) export BOOL GetCommConfig(
  HANDLE hCommDev,
  LPCOMMCONFIG lpCC,
  LPDWORD lpdwSize);

extern(Windows) export BOOL GetCommMask(
  HANDLE hFile,
  LPDWORD lpEvtMask);

extern(Windows) export BOOL GetCommProperties(
  HANDLE hFile,
  LPCOMMPROP lpCommProp);

extern(Windows) export BOOL GetCommModemStatus(
  HANDLE hFile,
  LPDWORD lpModemStat);

extern(Windows) export BOOL GetCommState(
  HANDLE hFile,
  LPDCB lpDCB);

extern(Windows) export BOOL GetCommTimeouts(
  HANDLE hFile,
  LPCOMMTIMEOUTS lpCommTimeouts);

extern(Windows) export BOOL PurgeComm(
  HANDLE hFile,
  DWORD dwFlags);

extern(Windows) export BOOL SetCommBreak(
  HANDLE hFile);

extern(Windows) export BOOL SetCommConfig(
  HANDLE hCommDev,
  LPCOMMCONFIG lpCC,
  DWORD dwSize);

extern(Windows) export BOOL SetCommMask(
  HANDLE hFile,
  DWORD dwEvtMask);

extern(Windows) export BOOL SetCommState(
  HANDLE hFile,
  LPDCB lpDCB);

extern(Windows) export BOOL SetCommTimeouts(
  HANDLE hFile,
  LPCOMMTIMEOUTS lpCommTimeouts);

extern(Windows) export BOOL TransmitCommChar(
  HANDLE hFile,
  char cChar);

extern(Windows) export BOOL WaitCommEvent(
  HANDLE hFile,
  LPDWORD lpEvtMask,
  LPOVERLAPPED lpOverlapped);

extern(Windows) export DWORD SetTapePosition(
  HANDLE hDevice,
  DWORD dwPositionMethod,
  DWORD dwPartition,
  DWORD dwOffsetLow,
  DWORD dwOffsetHigh,
  BOOL bImmediate);

extern(Windows) export DWORD GetTapePosition(
  HANDLE hDevice,
  DWORD dwPositionType,
  LPDWORD lpdwPartition,
  LPDWORD lpdwOffsetLow,
  LPDWORD lpdwOffsetHigh);

extern(Windows) export DWORD PrepareTape(
  HANDLE hDevice,
  DWORD dwOperation,
  BOOL bImmediate);

extern(Windows) export DWORD EraseTape(
  HANDLE hDevice,
  DWORD dwEraseType,
  BOOL bImmediate);

extern(Windows) export DWORD CreateTapePartition(
  HANDLE hDevice,
  DWORD dwPartitionMethod,
  DWORD dwCount,
  DWORD dwSize);

extern(Windows) export DWORD WriteTapemark(
  HANDLE hDevice,
  DWORD dwTapemarkType,
  DWORD dwTapemarkCount,
  BOOL bImmediate);

extern(Windows) export DWORD GetTapeStatus(
  HANDLE hDevice);

extern(Windows) export DWORD GetTapeParameters(
  HANDLE hDevice,
  DWORD dwOperation,
  LPDWORD lpdwSize,
  LPVOID lpTapeInformation);

enum : uint { GET_TAPE_MEDIA_INFORMATION = 0 }
enum : uint { GET_TAPE_DRIVE_INFORMATION = 1 }

extern(Windows) export DWORD SetTapeParameters(
  HANDLE hDevice,
  DWORD dwOperation,
  LPVOID lpTapeInformation);

enum : uint { SET_TAPE_MEDIA_INFORMATION = 0 }
enum : uint { SET_TAPE_DRIVE_INFORMATION = 1 }

extern(Windows) export BOOL Beep(
  DWORD dwFreq,
  DWORD dwDuration);

extern(Windows) export int MulDiv(
  int nNumber,
  int nNumerator,
  int nDenominator);

extern(Windows) export VOID GetSystemTime(
  LPSYSTEMTIME lpSystemTime);

extern(Windows) export VOID GetSystemTimeAsFileTime(
  LPFILETIME lpSystemTimeAsFileTime);

extern(Windows) export BOOL SetSystemTime(
  SYSTEMTIME *lpSystemTime);

extern(Windows) export VOID GetLocalTime(
  LPSYSTEMTIME lpSystemTime);

extern(Windows) export BOOL SetLocalTime(
  SYSTEMTIME *lpSystemTime);

extern(Windows) export VOID GetSystemInfo(
  LPSYSTEM_INFO lpSystemInfo);

// #if _WIN32_WINNT >= 0x0501
extern(Windows) export VOID GetNativeSystemInfo(
  LPSYSTEM_INFO lpSystemInfo);
// #endif

extern(Windows) export BOOL IsProcessorFeaturePresent(
  DWORD ProcessorFeature);

struct _TIME_ZONE_INFORMATION {
  LONG Bias;
  WCHAR StandardName[ 32 ];
  SYSTEMTIME StandardDate;
  LONG StandardBias;
  WCHAR DaylightName[ 32 ];
  SYSTEMTIME DaylightDate;
  LONG DaylightBias;
}
alias _TIME_ZONE_INFORMATION TIME_ZONE_INFORMATION;
alias _TIME_ZONE_INFORMATION* PTIME_ZONE_INFORMATION;
alias _TIME_ZONE_INFORMATION* LPTIME_ZONE_INFORMATION;

extern(Windows) export BOOL SystemTimeToTzSpecificLocalTime(
  LPTIME_ZONE_INFORMATION lpTimeZoneInformation,
  LPSYSTEMTIME lpUniversalTime,
  LPSYSTEMTIME lpLocalTime);

extern(Windows) export BOOL TzSpecificLocalTimeToSystemTime(
  LPTIME_ZONE_INFORMATION lpTimeZoneInformation,
  LPSYSTEMTIME lpLocalTime,
  LPSYSTEMTIME lpUniversalTime);

extern(Windows) export DWORD GetTimeZoneInformation(
  LPTIME_ZONE_INFORMATION lpTimeZoneInformation);

extern(Windows) export BOOL SetTimeZoneInformation(
  TIME_ZONE_INFORMATION *lpTimeZoneInformation);

extern(Windows) export BOOL SystemTimeToFileTime(
  SYSTEMTIME *lpSystemTime,
  LPFILETIME lpFileTime);

extern(Windows) export BOOL FileTimeToLocalFileTime(
  FILETIME *lpFileTime,
  LPFILETIME lpLocalFileTime);

extern(Windows) export BOOL LocalFileTimeToFileTime(
  FILETIME *lpLocalFileTime,
  LPFILETIME lpFileTime);

extern(Windows) export BOOL FileTimeToSystemTime(
  FILETIME *lpFileTime,
  LPSYSTEMTIME lpSystemTime);

extern(Windows) export LONG CompareFileTime(
  FILETIME *lpFileTime1,
  FILETIME *lpFileTime2);

extern(Windows) export BOOL FileTimeToDosDateTime(
  FILETIME *lpFileTime,
  LPWORD lpFatDate,
  LPWORD lpFatTime);

extern(Windows) export BOOL DosDateTimeToFileTime(
  WORD wFatDate,
  WORD wFatTime,
  LPFILETIME lpFileTime);

extern(Windows) export DWORD GetTickCount();

extern(Windows) export BOOL SetSystemTimeAdjustment(
  DWORD dwTimeAdjustment,
  BOOL bTimeAdjustmentDisabled);

extern(Windows) export BOOL GetSystemTimeAdjustment(
  PDWORD lpTimeAdjustment,
  PDWORD lpTimeIncrement,
  PBOOL lpTimeAdjustmentDisabled);

// #if !defined(MIDL_PASS)
extern(Windows) export DWORD FormatMessageA(
  DWORD dwFlags,
  LPCVOID lpSource,
  DWORD dwMessageId,
  DWORD dwLanguageId,
  LPSTR lpBuffer,
  DWORD nSize,
  va_list *Arguments);
extern(Windows) export DWORD FormatMessageW(
  DWORD dwFlags,
  LPCVOID lpSource,
  DWORD dwMessageId,
  DWORD dwLanguageId,
  LPWSTR lpBuffer,
  DWORD nSize,
  va_list *Arguments);
// #ifdef UNICODE
alias FormatMessageW FormatMessage;
// #else
// #...
// #endif // !UNICODE
// #endif

enum : uint { FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100 }
enum : uint { FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200 }
enum : uint { FORMAT_MESSAGE_FROM_STRING = 0x00000400 }
enum : uint { FORMAT_MESSAGE_FROM_HMODULE = 0x00000800 }
enum : uint { FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 }
enum : uint { FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000 }
enum : uint { FORMAT_MESSAGE_MAX_WIDTH_MASK = 0x000000FF }

extern(Windows) export BOOL CreatePipe(
  PHANDLE hReadPipe,
  PHANDLE hWritePipe,
  LPSECURITY_ATTRIBUTES lpPipeAttributes,
  DWORD nSize);

extern(Windows) export BOOL ConnectNamedPipe(
  HANDLE hNamedPipe,
  LPOVERLAPPED lpOverlapped);

extern(Windows) export BOOL DisconnectNamedPipe(
  HANDLE hNamedPipe);

extern(Windows) export BOOL SetNamedPipeHandleState(
  HANDLE hNamedPipe,
  LPDWORD lpMode,
  LPDWORD lpMaxCollectionCount,
  LPDWORD lpCollectDataTimeout);

extern(Windows) export BOOL GetNamedPipeInfo(
  HANDLE hNamedPipe,
  LPDWORD lpFlags,
  LPDWORD lpOutBufferSize,
  LPDWORD lpInBufferSize,
  LPDWORD lpMaxInstances);

extern(Windows) export BOOL PeekNamedPipe(
  HANDLE hNamedPipe,
  LPVOID lpBuffer,
  DWORD nBufferSize,
  LPDWORD lpBytesRead,
  LPDWORD lpTotalBytesAvail,
  LPDWORD lpBytesLeftThisMessage);

extern(Windows) export BOOL TransactNamedPipe(
  HANDLE hNamedPipe,
  LPVOID lpInBuffer,
  DWORD nInBufferSize,
  LPVOID lpOutBuffer,
  DWORD nOutBufferSize,
  LPDWORD lpBytesRead,
  LPOVERLAPPED lpOverlapped);

extern(Windows) export HANDLE CreateMailslotA(
  LPCSTR lpName,
  DWORD nMaxMessageSize,
  DWORD lReadTimeout,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
extern(Windows) export HANDLE CreateMailslotW(
  LPCWSTR lpName,
  DWORD nMaxMessageSize,
  DWORD lReadTimeout,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
// #ifdef UNICODE
alias CreateMailslotW CreateMailslot;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetMailslotInfo(
  HANDLE hMailslot,
  LPDWORD lpMaxMessageSize,
  LPDWORD lpNextSize,
  LPDWORD lpMessageCount,
  LPDWORD lpReadTimeout);

extern(Windows) export BOOL SetMailslotInfo(
  HANDLE hMailslot,
  DWORD lReadTimeout);

extern(Windows) export LPVOID MapViewOfFile(
  HANDLE hFileMappingObject,
  DWORD dwDesiredAccess,
  DWORD dwFileOffsetHigh,
  DWORD dwFileOffsetLow,
  SIZE_T dwNumberOfBytesToMap);

extern(Windows) export BOOL FlushViewOfFile(
  LPCVOID lpBaseAddress,
  SIZE_T dwNumberOfBytesToFlush);

extern(Windows) export BOOL UnmapViewOfFile(
  LPCVOID lpBaseAddress);

extern(Windows) export BOOL EncryptFileA(
  LPCSTR lpFileName);
extern(Windows) export BOOL EncryptFileW(
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias EncryptFileW EncryptFile;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL DecryptFileA(
  LPCSTR lpFileName,
  DWORD dwReserved);
extern(Windows) export BOOL DecryptFileW(
  LPCWSTR lpFileName,
  DWORD dwReserved);
// #ifdef UNICODE
alias DecryptFileW DecryptFile;
// #else
// #...
// #endif // !UNICODE

enum : uint { FILE_ENCRYPTABLE = 0 }
enum : uint { FILE_IS_ENCRYPTED = 1 }
enum : uint { FILE_SYSTEM_ATTR = 2 }
enum : uint { FILE_ROOT_DIR = 3 }
enum : uint { FILE_SYSTEM_DIR = 4 }
enum : uint { FILE_UNKNOWN = 5 }
enum : uint { FILE_SYSTEM_NOT_SUPPORT = 6 }
enum : uint { FILE_USER_DISALLOWED = 7 }
enum : uint { FILE_READ_ONLY = 8 }
enum : uint { FILE_DIR_DISALLOWED = 9 }

extern(Windows) export BOOL FileEncryptionStatusA(
  LPCSTR lpFileName,
  LPDWORD lpStatus);
extern(Windows) export BOOL FileEncryptionStatusW(
  LPCWSTR lpFileName,
  LPDWORD lpStatus);
// #ifdef UNICODE
alias FileEncryptionStatusW FileEncryptionStatus;
// #else
// #...
// #endif // !UNICODE

enum : uint { EFS_USE_RECOVERY_KEYS = 0x1 }

extern(Windows) alias DWORD function( PBYTE pbData, PVOID pvCallbackContext, ULONG ulLength ) PFE_EXPORT_FUNC;

extern(Windows) alias DWORD function( PBYTE pbData, PVOID pvCallbackContext, PULONG ulLength ) PFE_IMPORT_FUNC;

enum : uint { CREATE_FOR_IMPORT = 1 }
enum : uint { CREATE_FOR_DIR = 2 }
enum : uint { OVERWRITE_HIDDEN = 4 }

extern(Windows) export DWORD OpenEncryptedFileRawA(
  LPCSTR lpFileName,
  ULONG ulFlags,
  PVOID * pvContext);
extern(Windows) export DWORD OpenEncryptedFileRawW(
  LPCWSTR lpFileName,
  ULONG ulFlags,
  PVOID * pvContext);
// #ifdef UNICODE
alias OpenEncryptedFileRawW OpenEncryptedFileRaw;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD ReadEncryptedFileRaw(
  PFE_EXPORT_FUNC pfExportCallback,
  PVOID pvCallbackContext,
  PVOID pvContext);

extern(Windows) export DWORD WriteEncryptedFileRaw(
  PFE_IMPORT_FUNC pfImportCallback,
  PVOID pvCallbackContext,
  PVOID pvContext);

extern(Windows) export VOID CloseEncryptedFileRaw(
  PVOID pvContext);

extern(Windows) export int lstrcmpA(
  LPCSTR lpString1,
  LPCSTR lpString2);
extern(Windows) export int lstrcmpW(
  LPCWSTR lpString1,
  LPCWSTR lpString2);
// #ifdef UNICODE
alias lstrcmpW lstrcmp;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export int lstrcmpiA(
  LPCSTR lpString1,
  LPCSTR lpString2);
extern(Windows) export int lstrcmpiW(
  LPCWSTR lpString1,
  LPCWSTR lpString2);
// #ifdef UNICODE
alias lstrcmpiW lstrcmpi;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export LPSTR lstrcpynA(
  LPSTR lpString1,
  LPCSTR lpString2,
  int iMaxLength);
extern(Windows) export LPWSTR lstrcpynW(
  LPWSTR lpString1,
  LPCWSTR lpString2,
  int iMaxLength);
// #ifdef UNICODE
alias lstrcpynW lstrcpyn;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export LPSTR lstrcpyA(
  LPSTR lpString1,
  LPCSTR lpString2);
extern(Windows) export LPWSTR lstrcpyW(
  LPWSTR lpString1,
  LPCWSTR lpString2);
// #ifdef UNICODE
alias lstrcpyW lstrcpy;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export LPSTR lstrcatA(
  LPSTR lpString1,
  LPCSTR lpString2);
extern(Windows) export LPWSTR lstrcatW(
  LPWSTR lpString1,
  LPCWSTR lpString2);
// #ifdef UNICODE
alias lstrcatW lstrcat;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export int lstrlenA(
  LPCSTR lpString);
extern(Windows) export int lstrlenW(
  LPCWSTR lpString);
// #ifdef UNICODE
alias lstrlenW lstrlen;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HFILE OpenFile(
  LPCSTR lpFileName,
  LPOFSTRUCT lpReOpenBuff,
  UINT uStyle);

extern(Windows) export HFILE _lopen(
  LPCSTR lpPathName,
  int iReadWrite);

extern(Windows) export HFILE _lcreat(
  LPCSTR lpPathName,
  int iAttribute);

extern(Windows) export UINT _lread(
  HFILE hFile,
  LPVOID lpBuffer,
  UINT uBytes);

extern(Windows) export UINT _lwrite(
  HFILE hFile,
  LPCSTR lpBuffer,
  UINT uBytes);

extern(Windows) export int _hread(
  HFILE hFile,
  LPVOID lpBuffer,
  int lBytes);

extern(Windows) export int _hwrite(
  HFILE hFile,
  LPCSTR lpBuffer,
  int lBytes);

extern(Windows) export HFILE _lclose(
  HFILE hFile);

extern(Windows) export LONG _llseek(
  HFILE hFile,
  LONG lOffset,
  int iOrigin);

extern(Windows) export BOOL IsTextUnicode(
  VOID* lpBuffer,
  int cb,
  LPINT lpi);

extern(Windows) export DWORD TlsAlloc();

enum : uint { TLS_OUT_OF_INDEXES = cast(DWORD)0xFFFFFFFF }

extern(Windows) export LPVOID TlsGetValue(
  DWORD dwTlsIndex);

extern(Windows) export BOOL TlsSetValue(
  DWORD dwTlsIndex,
  LPVOID lpTlsValue);

extern(Windows) export BOOL TlsFree(
  DWORD dwTlsIndex);

extern(Windows) alias VOID function( DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped ) LPOVERLAPPED_COMPLETION_ROUTINE;

extern(Windows) export DWORD SleepEx(
  DWORD dwMilliseconds,
  BOOL bAlertable);

extern(Windows) export DWORD WaitForSingleObjectEx(
  HANDLE hHandle,
  DWORD dwMilliseconds,
  BOOL bAlertable);

extern(Windows) export DWORD WaitForMultipleObjectsEx(
  DWORD nCount,
  HANDLE *lpHandles,
  BOOL bWaitAll,
  DWORD dwMilliseconds,
  BOOL bAlertable);

// #if(_WIN32_WINNT >= 0x0400)
extern(Windows) export DWORD SignalObjectAndWait(
  HANDLE hObjectToSignal,
  HANDLE hObjectToWaitOn,
  DWORD dwMilliseconds,
  BOOL bAlertable);
// #endif /* _WIN32_WINNT >= 0x0400 */

extern(Windows) export BOOL ReadFileEx(
  HANDLE hFile,
  LPVOID lpBuffer,
  DWORD nNumberOfBytesToRead,
  LPOVERLAPPED lpOverlapped,
  LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);

extern(Windows) export BOOL WriteFileEx(
  HANDLE hFile,
  LPCVOID lpBuffer,
  DWORD nNumberOfBytesToWrite,
  LPOVERLAPPED lpOverlapped,
  LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);

extern(Windows) export BOOL BackupRead(
  HANDLE hFile,
  LPBYTE lpBuffer,
  DWORD nNumberOfBytesToRead,
  LPDWORD lpNumberOfBytesRead,
  BOOL bAbort,
  BOOL bProcessSecurity,
  LPVOID *lpContext);

extern(Windows) export BOOL BackupSeek(
  HANDLE hFile,
  DWORD dwLowBytesToSeek,
  DWORD dwHighBytesToSeek,
  LPDWORD lpdwLowByteSeeked,
  LPDWORD lpdwHighByteSeeked,
  LPVOID *lpContext);

extern(Windows) export BOOL BackupWrite(
  HANDLE hFile,
  LPBYTE lpBuffer,
  DWORD nNumberOfBytesToWrite,
  LPDWORD lpNumberOfBytesWritten,
  BOOL bAbort,
  BOOL bProcessSecurity,
  LPVOID *lpContext);

struct _WIN32_STREAM_ID {
  DWORD dwStreamId ;
  DWORD dwStreamAttributes ;
  LARGE_INTEGER Size ;
  DWORD dwStreamNameSize ;
  WCHAR cStreamName[ ANYSIZE_ARRAY ] ;
}
alias _WIN32_STREAM_ID WIN32_STREAM_ID;
alias _WIN32_STREAM_ID* LPWIN32_STREAM_ID;

enum : uint { BACKUP_INVALID = 0x00000000 }
enum : uint { BACKUP_DATA = 0x00000001 }
enum : uint { BACKUP_EA_DATA = 0x00000002 }
enum : uint { BACKUP_SECURITY_DATA = 0x00000003 }
enum : uint { BACKUP_ALTERNATE_DATA = 0x00000004 }
enum : uint { BACKUP_LINK = 0x00000005 }
enum : uint { BACKUP_PROPERTY_DATA = 0x00000006 }
enum : uint { BACKUP_OBJECT_ID = 0x00000007 }
enum : uint { BACKUP_REPARSE_DATA = 0x00000008 }
enum : uint { BACKUP_SPARSE_BLOCK = 0x00000009 }

enum : uint { STREAM_NORMAL_ATTRIBUTE = 0x00000000 }
enum : uint { STREAM_MODIFIED_WHEN_READ = 0x00000001 }
enum : uint { STREAM_CONTAINS_SECURITY = 0x00000002 }
enum : uint { STREAM_CONTAINS_PROPERTIES = 0x00000004 }
enum : uint { STREAM_SPARSE_ATTRIBUTE = 0x00000008 }

extern(Windows) export BOOL ReadFileScatter(
  HANDLE hFile,
  FILE_SEGMENT_ELEMENT aSegmentArray[],
  DWORD nNumberOfBytesToRead,
  LPDWORD lpReserved,
  LPOVERLAPPED lpOverlapped);

extern(Windows) export BOOL WriteFileGather(
  HANDLE hFile,
  FILE_SEGMENT_ELEMENT aSegmentArray[],
  DWORD nNumberOfBytesToWrite,
  LPDWORD lpReserved,
  LPOVERLAPPED lpOverlapped);

enum : uint { STARTF_USESHOWWINDOW = 0x00000001 }
enum : uint { STARTF_USESIZE = 0x00000002 }
enum : uint { STARTF_USEPOSITION = 0x00000004 }
enum : uint { STARTF_USECOUNTCHARS = 0x00000008 }
enum : uint { STARTF_USEFILLATTRIBUTE = 0x00000010 }
enum : uint { STARTF_RUNFULLSCREEN = 0x00000020 }
enum : uint { STARTF_FORCEONFEEDBACK = 0x00000040 }
enum : uint { STARTF_FORCEOFFFEEDBACK = 0x00000080 }
enum : uint { STARTF_USESTDHANDLES = 0x00000100 }

// #if(WINVER >= 0x0400)

enum : uint { STARTF_USEHOTKEY = 0x00000200 }
// #endif /* WINVER >= 0x0400 */

struct _STARTUPINFOA {
  DWORD cb;
  LPSTR lpReserved;
  LPSTR lpDesktop;
  LPSTR lpTitle;
  DWORD dwX;
  DWORD dwY;
  DWORD dwXSize;
  DWORD dwYSize;
  DWORD dwXCountChars;
  DWORD dwYCountChars;
  DWORD dwFillAttribute;
  DWORD dwFlags;
  WORD wShowWindow;
  WORD cbReserved2;
  LPBYTE lpReserved2;
  HANDLE hStdInput;
  HANDLE hStdOutput;
  HANDLE hStdError;
}
alias _STARTUPINFOA STARTUPINFOA;
alias _STARTUPINFOA* LPSTARTUPINFOA;

struct _STARTUPINFOW {
  DWORD cb;
  LPWSTR lpReserved;
  LPWSTR lpDesktop;
  LPWSTR lpTitle;
  DWORD dwX;
  DWORD dwY;
  DWORD dwXSize;
  DWORD dwYSize;
  DWORD dwXCountChars;
  DWORD dwYCountChars;
  DWORD dwFillAttribute;
  DWORD dwFlags;
  WORD wShowWindow;
  WORD cbReserved2;
  LPBYTE lpReserved2;
  HANDLE hStdInput;
  HANDLE hStdOutput;
  HANDLE hStdError;
}
alias _STARTUPINFOW STARTUPINFOW;
alias _STARTUPINFOW* LPSTARTUPINFOW;

// #ifdef UNICODE
alias STARTUPINFOW STARTUPINFO;
alias LPSTARTUPINFOW LPSTARTUPINFO;
// #else
// ...
// #endif // UNICODE

enum : uint { SHUTDOWN_NORETRY = 0x00000001 }

struct _WIN32_FIND_DATAA {
  DWORD dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD nFileSizeHigh;
  DWORD nFileSizeLow;
  DWORD dwReserved0;
  DWORD dwReserved1;
  CHAR cFileName[ MAX_PATH ];
  CHAR cAlternateFileName[ 14 ];
// #ifdef _MAC
// ...
// #endif
}
alias _WIN32_FIND_DATAA WIN32_FIND_DATAA;
alias _WIN32_FIND_DATAA* PWIN32_FIND_DATAA;
alias _WIN32_FIND_DATAA* LPWIN32_FIND_DATAA;

struct _WIN32_FIND_DATAW {
  DWORD dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD nFileSizeHigh;
  DWORD nFileSizeLow;
  DWORD dwReserved0;
  DWORD dwReserved1;
  WCHAR cFileName[ MAX_PATH ];
  WCHAR cAlternateFileName[ 14 ];
// #ifdef _MAC
// ...
// #endif
}
alias _WIN32_FIND_DATAW WIN32_FIND_DATAW;
alias _WIN32_FIND_DATAW* PWIN32_FIND_DATAW;
alias _WIN32_FIND_DATAW* LPWIN32_FIND_DATAW;

// #ifdef UNICODE
alias WIN32_FIND_DATAW WIN32_FIND_DATA;
alias PWIN32_FIND_DATAW PWIN32_FIND_DATA;
alias LPWIN32_FIND_DATAW LPWIN32_FIND_DATA;
// #else
// ...
// #endif // UNICODE

struct _WIN32_FILE_ATTRIBUTE_DATA {
  DWORD dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD nFileSizeHigh;
  DWORD nFileSizeLow;
}
alias _WIN32_FILE_ATTRIBUTE_DATA WIN32_FILE_ATTRIBUTE_DATA;
alias _WIN32_FILE_ATTRIBUTE_DATA* LPWIN32_FILE_ATTRIBUTE_DATA;

extern(Windows) export HANDLE CreateMutexA(
  LPSECURITY_ATTRIBUTES lpMutexAttributes,
  BOOL bInitialOwner,
  LPCSTR lpName);
extern(Windows) export HANDLE CreateMutexW(
  LPSECURITY_ATTRIBUTES lpMutexAttributes,
  BOOL bInitialOwner,
  LPCWSTR lpName);
// #ifdef UNICODE
alias CreateMutexW CreateMutex;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE OpenMutexA(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCSTR lpName);
extern(Windows) export HANDLE OpenMutexW(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCWSTR lpName);
// #ifdef UNICODE
alias OpenMutexW OpenMutex;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE CreateEventA(
  LPSECURITY_ATTRIBUTES lpEventAttributes,
  BOOL bManualReset,
  BOOL bInitialState,
  LPCSTR lpName);
extern(Windows) export HANDLE CreateEventW(
  LPSECURITY_ATTRIBUTES lpEventAttributes,
  BOOL bManualReset,
  BOOL bInitialState,
  LPCWSTR lpName);
// #ifdef UNICODE
alias CreateEventW CreateEvent;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE OpenEventA(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCSTR lpName);
extern(Windows) export HANDLE OpenEventW(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCWSTR lpName);
// #ifdef UNICODE
alias OpenEventW OpenEvent;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE CreateSemaphoreA(
  LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
  LONG lInitialCount,
  LONG lMaximumCount,
  LPCSTR lpName);
extern(Windows) export HANDLE CreateSemaphoreW(
  LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
  LONG lInitialCount,
  LONG lMaximumCount,
  LPCWSTR lpName);
// #ifdef UNICODE
alias CreateSemaphoreW CreateSemaphore;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE OpenSemaphoreA(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCSTR lpName);
extern(Windows) export HANDLE OpenSemaphoreW(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCWSTR lpName);
// #ifdef UNICODE
alias OpenSemaphoreW OpenSemaphore;
// #else
// #...
// #endif // !UNICODE

// #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
extern(Windows) alias VOID function( LPVOID lpArgToCompletionRoutine, DWORD dwTimerLowValue, DWORD dwTimerHighValue ) PTIMERAPCROUTINE;

extern(Windows) export HANDLE CreateWaitableTimerA(
  LPSECURITY_ATTRIBUTES lpTimerAttributes,
  BOOL bManualReset,
  LPCSTR lpTimerName);
extern(Windows) export HANDLE CreateWaitableTimerW(
  LPSECURITY_ATTRIBUTES lpTimerAttributes,
  BOOL bManualReset,
  LPCWSTR lpTimerName);
// #ifdef UNICODE
alias CreateWaitableTimerW CreateWaitableTimer;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE OpenWaitableTimerA(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCSTR lpTimerName);
extern(Windows) export HANDLE OpenWaitableTimerW(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCWSTR lpTimerName);
// #ifdef UNICODE
alias OpenWaitableTimerW OpenWaitableTimer;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetWaitableTimer(
  HANDLE hTimer,
  LARGE_INTEGER *lpDueTime,
  LONG lPeriod,
  PTIMERAPCROUTINE pfnCompletionRoutine,
  LPVOID lpArgToCompletionRoutine,
  BOOL fResume);

extern(Windows) export BOOL CancelWaitableTimer(
  HANDLE hTimer);
// #endif /* (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) */

extern(Windows) export HANDLE CreateFileMappingA(
  HANDLE hFile,
  LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
  DWORD flProtect,
  DWORD dwMaximumSizeHigh,
  DWORD dwMaximumSizeLow,
  LPCSTR lpName);
extern(Windows) export HANDLE CreateFileMappingW(
  HANDLE hFile,
  LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
  DWORD flProtect,
  DWORD dwMaximumSizeHigh,
  DWORD dwMaximumSizeLow,
  LPCWSTR lpName);
// #ifdef UNICODE
alias CreateFileMappingW CreateFileMapping;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE OpenFileMappingA(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCSTR lpName);
extern(Windows) export HANDLE OpenFileMappingW(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCWSTR lpName);
// #ifdef UNICODE
alias OpenFileMappingW OpenFileMapping;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetLogicalDriveStringsA(
  DWORD nBufferLength,
  LPSTR lpBuffer);
extern(Windows) export DWORD GetLogicalDriveStringsW(
  DWORD nBufferLength,
  LPWSTR lpBuffer);
// #ifdef UNICODE
alias GetLogicalDriveStringsW GetLogicalDriveStrings;
// #else
// #...
// #endif // !UNICODE

// #if _WIN32_WINNT >= 0x0501

alias int _MEMORY_RESOURCE_NOTIFICATION_TYPE;
enum {
  LowMemoryResourceNotification,
  HighMemoryResourceNotification,
}
alias _MEMORY_RESOURCE_NOTIFICATION_TYPE MEMORY_RESOURCE_NOTIFICATION_TYPE;

extern(Windows) export HANDLE CreateMemoryResourceNotification(
  MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType);

extern(Windows) export BOOL QueryMemoryResourceNotification(
  HANDLE ResourceNotificationHandle,
  PBOOL ResourceState);

// #endif // _WIN32_WINNT >= 0x0501

extern(Windows) export HMODULE LoadLibraryA(
  LPCSTR lpLibFileName);
extern(Windows) export HMODULE LoadLibraryW(
  LPCWSTR lpLibFileName);
// #ifdef UNICODE
alias LoadLibraryW LoadLibrary;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HMODULE LoadLibraryExA(
  LPCSTR lpLibFileName,
  HANDLE hFile,
  DWORD dwFlags);
extern(Windows) export HMODULE LoadLibraryExW(
  LPCWSTR lpLibFileName,
  HANDLE hFile,
  DWORD dwFlags);
// #ifdef UNICODE
alias LoadLibraryExW LoadLibraryEx;
// #else
// #...
// #endif // !UNICODE

enum : uint { DONT_RESOLVE_DLL_REFERENCES = 0x00000001 }
enum : uint { LOAD_LIBRARY_AS_DATAFILE = 0x00000002 }
enum : uint { LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008 }
enum : uint { LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010 }

extern(Windows) export DWORD GetModuleFileNameA(
  HMODULE hModule,
  LPSTR lpFilename,
  DWORD nSize);
extern(Windows) export DWORD GetModuleFileNameW(
  HMODULE hModule,
  LPWSTR lpFilename,
  DWORD nSize);
// #ifdef UNICODE
alias GetModuleFileNameW GetModuleFileName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HMODULE GetModuleHandleA(
  LPCSTR lpModuleName);
extern(Windows) export HMODULE GetModuleHandleW(
  LPCWSTR lpModuleName);
// #ifdef UNICODE
alias GetModuleHandleW GetModuleHandle;
// #else
// #...
// #endif // !UNICODE

// #if !defined(RC_INVOKED)
// #if _WIN32_WINNT > 0x0500 || defined(WINBASE_DECLARE_GET_MODULE_HANDLE_EX) || ISOLATION_AWARE_ENABLED

enum : uint { GET_MODULE_HANDLE_EX_FLAG_PIN = 0x00000001 }
enum : uint { GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 0x00000002 }
enum : uint { GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 0x00000004 }

extern(Windows) alias BOOL function(  DWORD dwFlags,  LPCSTR lpModuleName,  HMODULE* phModule ) PGET_MODULE_HANDLE_EXA;
extern(Windows) alias BOOL function(  DWORD dwFlags,  LPCWSTR lpModuleName,  HMODULE* phModule ) PGET_MODULE_HANDLE_EXW;
// #ifdef UNICODE
alias PGET_MODULE_HANDLE_EXW PGET_MODULE_HANDLE_EX;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetModuleHandleExA(
  DWORD dwFlags,
  LPCSTR lpModuleName,
  HMODULE* phModule);
extern(Windows) export BOOL GetModuleHandleExW(
  DWORD dwFlags,
  LPCWSTR lpModuleName,
  HMODULE* phModule);
// #ifdef UNICODE
alias GetModuleHandleExW GetModuleHandleEx;
// #else
// #...
// #endif // !UNICODE

// #endif
// #endif

extern(Windows) export BOOL CreateProcessA(
  LPCSTR lpApplicationName,
  LPSTR lpCommandLine,
  LPSECURITY_ATTRIBUTES lpProcessAttributes,
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  BOOL bInheritHandles,
  DWORD dwCreationFlags,
  LPVOID lpEnvironment,
  LPCSTR lpCurrentDirectory,
  LPSTARTUPINFOA lpStartupInfo,
  LPPROCESS_INFORMATION lpProcessInformation);
extern(Windows) export BOOL CreateProcessW(
  LPCWSTR lpApplicationName,
  LPWSTR lpCommandLine,
  LPSECURITY_ATTRIBUTES lpProcessAttributes,
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  BOOL bInheritHandles,
  DWORD dwCreationFlags,
  LPVOID lpEnvironment,
  LPCWSTR lpCurrentDirectory,
  LPSTARTUPINFOW lpStartupInfo,
  LPPROCESS_INFORMATION lpProcessInformation);
// #ifdef UNICODE
alias CreateProcessW CreateProcess;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetProcessShutdownParameters(
  DWORD dwLevel,
  DWORD dwFlags);

extern(Windows) export BOOL GetProcessShutdownParameters(
  LPDWORD lpdwLevel,
  LPDWORD lpdwFlags);

extern(Windows) export DWORD GetProcessVersion(
  DWORD ProcessId);

extern(Windows) export VOID FatalAppExitA(
  UINT uAction,
  LPCSTR lpMessageText);
extern(Windows) export VOID FatalAppExitW(
  UINT uAction,
  LPCWSTR lpMessageText);
// #ifdef UNICODE
alias FatalAppExitW FatalAppExit;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export VOID GetStartupInfoA(
  LPSTARTUPINFOA lpStartupInfo);
extern(Windows) export VOID GetStartupInfoW(
  LPSTARTUPINFOW lpStartupInfo);
// #ifdef UNICODE
alias GetStartupInfoW GetStartupInfo;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export LPSTR GetCommandLineA();
extern(Windows) export LPWSTR GetCommandLineW();
// #ifdef UNICODE
alias GetCommandLineW GetCommandLine;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetEnvironmentVariableA(
  LPCSTR lpName,
  LPSTR lpBuffer,
  DWORD nSize);
extern(Windows) export DWORD GetEnvironmentVariableW(
  LPCWSTR lpName,
  LPWSTR lpBuffer,
  DWORD nSize);
// #ifdef UNICODE
alias GetEnvironmentVariableW GetEnvironmentVariable;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetEnvironmentVariableA(
  LPCSTR lpName,
  LPCSTR lpValue);
extern(Windows) export BOOL SetEnvironmentVariableW(
  LPCWSTR lpName,
  LPCWSTR lpValue);
// #ifdef UNICODE
alias SetEnvironmentVariableW SetEnvironmentVariable;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD ExpandEnvironmentStringsA(
  LPCSTR lpSrc,
  LPSTR lpDst,
  DWORD nSize);
extern(Windows) export DWORD ExpandEnvironmentStringsW(
  LPCWSTR lpSrc,
  LPWSTR lpDst,
  DWORD nSize);
// #ifdef UNICODE
alias ExpandEnvironmentStringsW ExpandEnvironmentStrings;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetFirmwareEnvironmentVariableA(
  LPCSTR lpName,
  LPCSTR lpGuid,
  PVOID pBuffer,
  DWORD nSize);
extern(Windows) export DWORD GetFirmwareEnvironmentVariableW(
  LPCWSTR lpName,
  LPCWSTR lpGuid,
  PVOID pBuffer,
  DWORD nSize);
// #ifdef UNICODE
alias GetFirmwareEnvironmentVariableW GetFirmwareEnvironmentVariable;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetFirmwareEnvironmentVariableA(
  LPCSTR lpName,
  LPCSTR lpGuid,
  PVOID pValue,
  DWORD nSize);
extern(Windows) export BOOL SetFirmwareEnvironmentVariableW(
  LPCWSTR lpName,
  LPCWSTR lpGuid,
  PVOID pValue,
  DWORD nSize);
// #ifdef UNICODE
alias SetFirmwareEnvironmentVariableW SetFirmwareEnvironmentVariable;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export VOID OutputDebugStringA(
  LPCSTR lpOutputString);
extern(Windows) export VOID OutputDebugStringW(
  LPCWSTR lpOutputString);
// #ifdef UNICODE
alias OutputDebugStringW OutputDebugString;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HRSRC FindResourceA(
  HMODULE hModule,
  LPCSTR lpName,
  LPCSTR lpType);
extern(Windows) export HRSRC FindResourceW(
  HMODULE hModule,
  LPCWSTR lpName,
  LPCWSTR lpType);
// #ifdef UNICODE
alias FindResourceW FindResource;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HRSRC FindResourceExA(
  HMODULE hModule,
  LPCSTR lpType,
  LPCSTR lpName,
  WORD wLanguage);
extern(Windows) export HRSRC FindResourceExW(
  HMODULE hModule,
  LPCWSTR lpType,
  LPCWSTR lpName,
  WORD wLanguage);
// #ifdef UNICODE
alias FindResourceExW FindResourceEx;
// #else
// #...
// #endif // !UNICODE

// #ifdef STRICT
extern(Windows) alias BOOL function(HMODULE hModule, LPSTR lpType, LONG_PTR lParam) ENUMRESTYPEPROCA;
extern(Windows) alias BOOL function(HMODULE hModule, LPWSTR lpType, LONG_PTR lParam) ENUMRESTYPEPROCW;
// #ifdef UNICODE
alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
// #else
// #...
// #endif // !UNICODE
extern(Windows) alias BOOL function(HMODULE hModule, LPCSTR lpType, LPSTR lpName, LONG_PTR lParam) ENUMRESNAMEPROCA;
extern(Windows) alias BOOL function(HMODULE hModule, LPCWSTR lpType, LPWSTR lpName, LONG_PTR lParam) ENUMRESNAMEPROCW;
// #ifdef UNICODE
alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
// #else
// #...
// #endif // !UNICODE
extern(Windows) alias BOOL function(HMODULE hModule, LPCSTR lpType, LPCSTR lpName, WORD wLanguage, LONG_PTR lParam) ENUMRESLANGPROCA;
extern(Windows) alias BOOL function(HMODULE hModule, LPCWSTR lpType, LPCWSTR lpName, WORD wLanguage, LONG_PTR lParam) ENUMRESLANGPROCW;
// #ifdef UNICODE
alias ENUMRESLANGPROCW ENUMRESLANGPROC;
// #else
// #...
// #endif // !UNICODE
// #else
// ...
// #ifdef UNICODE
// ...
// #else
// ...
// #endif // UNICODE
// ...
// #ifdef UNICODE
// ...
// #else
// ...
// #endif // UNICODE
// ...
// #ifdef UNICODE
// ...
// #else
// ...
// #endif // UNICODE
// #endif

extern(Windows) export BOOL EnumResourceTypesA(
  HMODULE hModule,
  ENUMRESTYPEPROCA lpEnumFunc,
  LONG_PTR lParam);
extern(Windows) export BOOL EnumResourceTypesW(
  HMODULE hModule,
  ENUMRESTYPEPROCW lpEnumFunc,
  LONG_PTR lParam);
// #ifdef UNICODE
alias EnumResourceTypesW EnumResourceTypes;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL EnumResourceNamesA(
  HMODULE hModule,
  LPCSTR lpType,
  ENUMRESNAMEPROCA lpEnumFunc,
  LONG_PTR lParam);
extern(Windows) export BOOL EnumResourceNamesW(
  HMODULE hModule,
  LPCWSTR lpType,
  ENUMRESNAMEPROCW lpEnumFunc,
  LONG_PTR lParam);
// #ifdef UNICODE
alias EnumResourceNamesW EnumResourceNames;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL EnumResourceLanguagesA(
  HMODULE hModule,
  LPCSTR lpType,
  LPCSTR lpName,
  ENUMRESLANGPROCA lpEnumFunc,
  LONG_PTR lParam);
extern(Windows) export BOOL EnumResourceLanguagesW(
  HMODULE hModule,
  LPCWSTR lpType,
  LPCWSTR lpName,
  ENUMRESLANGPROCW lpEnumFunc,
  LONG_PTR lParam);
// #ifdef UNICODE
alias EnumResourceLanguagesW EnumResourceLanguages;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE BeginUpdateResourceA(
  LPCSTR pFileName,
  BOOL bDeleteExistingResources);
extern(Windows) export HANDLE BeginUpdateResourceW(
  LPCWSTR pFileName,
  BOOL bDeleteExistingResources);
// #ifdef UNICODE
alias BeginUpdateResourceW BeginUpdateResource;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL UpdateResourceA(
  HANDLE hUpdate,
  LPCSTR lpType,
  LPCSTR lpName,
  WORD wLanguage,
  LPVOID lpData,
  DWORD cbData);
extern(Windows) export BOOL UpdateResourceW(
  HANDLE hUpdate,
  LPCWSTR lpType,
  LPCWSTR lpName,
  WORD wLanguage,
  LPVOID lpData,
  DWORD cbData);
// #ifdef UNICODE
alias UpdateResourceW UpdateResource;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL EndUpdateResourceA(
  HANDLE hUpdate,
  BOOL fDiscard);
extern(Windows) export BOOL EndUpdateResourceW(
  HANDLE hUpdate,
  BOOL fDiscard);
// #ifdef UNICODE
alias EndUpdateResourceW EndUpdateResource;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export ATOM GlobalAddAtomA(
  LPCSTR lpString);
extern(Windows) export ATOM GlobalAddAtomW(
  LPCWSTR lpString);
// #ifdef UNICODE
alias GlobalAddAtomW GlobalAddAtom;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export ATOM GlobalFindAtomA(
  LPCSTR lpString);
extern(Windows) export ATOM GlobalFindAtomW(
  LPCWSTR lpString);
// #ifdef UNICODE
alias GlobalFindAtomW GlobalFindAtom;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GlobalGetAtomNameA(
  ATOM nAtom,
  LPSTR lpBuffer,
  int nSize);
extern(Windows) export UINT GlobalGetAtomNameW(
  ATOM nAtom,
  LPWSTR lpBuffer,
  int nSize);
// #ifdef UNICODE
alias GlobalGetAtomNameW GlobalGetAtomName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export ATOM AddAtomA(
  LPCSTR lpString);
extern(Windows) export ATOM AddAtomW(
  LPCWSTR lpString);
// #ifdef UNICODE
alias AddAtomW AddAtom;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export ATOM FindAtomA(
  LPCSTR lpString);
extern(Windows) export ATOM FindAtomW(
  LPCWSTR lpString);
// #ifdef UNICODE
alias FindAtomW FindAtom;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GetAtomNameA(
  ATOM nAtom,
  LPSTR lpBuffer,
  int nSize);
extern(Windows) export UINT GetAtomNameW(
  ATOM nAtom,
  LPWSTR lpBuffer,
  int nSize);
// #ifdef UNICODE
alias GetAtomNameW GetAtomName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GetProfileIntA(
  LPCSTR lpAppName,
  LPCSTR lpKeyName,
  INT nDefault);
extern(Windows) export UINT GetProfileIntW(
  LPCWSTR lpAppName,
  LPCWSTR lpKeyName,
  INT nDefault);
// #ifdef UNICODE
alias GetProfileIntW GetProfileInt;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetProfileStringA(
  LPCSTR lpAppName,
  LPCSTR lpKeyName,
  LPCSTR lpDefault,
  LPSTR lpReturnedString,
  DWORD nSize);
extern(Windows) export DWORD GetProfileStringW(
  LPCWSTR lpAppName,
  LPCWSTR lpKeyName,
  LPCWSTR lpDefault,
  LPWSTR lpReturnedString,
  DWORD nSize);
// #ifdef UNICODE
alias GetProfileStringW GetProfileString;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL WriteProfileStringA(
  LPCSTR lpAppName,
  LPCSTR lpKeyName,
  LPCSTR lpString);
extern(Windows) export BOOL WriteProfileStringW(
  LPCWSTR lpAppName,
  LPCWSTR lpKeyName,
  LPCWSTR lpString);
// #ifdef UNICODE
alias WriteProfileStringW WriteProfileString;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetProfileSectionA(
  LPCSTR lpAppName,
  LPSTR lpReturnedString,
  DWORD nSize);
extern(Windows) export DWORD GetProfileSectionW(
  LPCWSTR lpAppName,
  LPWSTR lpReturnedString,
  DWORD nSize);
// #ifdef UNICODE
alias GetProfileSectionW GetProfileSection;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL WriteProfileSectionA(
  LPCSTR lpAppName,
  LPCSTR lpString);
extern(Windows) export BOOL WriteProfileSectionW(
  LPCWSTR lpAppName,
  LPCWSTR lpString);
// #ifdef UNICODE
alias WriteProfileSectionW WriteProfileSection;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GetPrivateProfileIntA(
  LPCSTR lpAppName,
  LPCSTR lpKeyName,
  INT nDefault,
  LPCSTR lpFileName);
extern(Windows) export UINT GetPrivateProfileIntW(
  LPCWSTR lpAppName,
  LPCWSTR lpKeyName,
  INT nDefault,
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias GetPrivateProfileIntW GetPrivateProfileInt;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetPrivateProfileStringA(
  LPCSTR lpAppName,
  LPCSTR lpKeyName,
  LPCSTR lpDefault,
  LPSTR lpReturnedString,
  DWORD nSize,
  LPCSTR lpFileName);
extern(Windows) export DWORD GetPrivateProfileStringW(
  LPCWSTR lpAppName,
  LPCWSTR lpKeyName,
  LPCWSTR lpDefault,
  LPWSTR lpReturnedString,
  DWORD nSize,
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias GetPrivateProfileStringW GetPrivateProfileString;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL WritePrivateProfileStringA(
  LPCSTR lpAppName,
  LPCSTR lpKeyName,
  LPCSTR lpString,
  LPCSTR lpFileName);
extern(Windows) export BOOL WritePrivateProfileStringW(
  LPCWSTR lpAppName,
  LPCWSTR lpKeyName,
  LPCWSTR lpString,
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias WritePrivateProfileStringW WritePrivateProfileString;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetPrivateProfileSectionA(
  LPCSTR lpAppName,
  LPSTR lpReturnedString,
  DWORD nSize,
  LPCSTR lpFileName);
extern(Windows) export DWORD GetPrivateProfileSectionW(
  LPCWSTR lpAppName,
  LPWSTR lpReturnedString,
  DWORD nSize,
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias GetPrivateProfileSectionW GetPrivateProfileSection;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL WritePrivateProfileSectionA(
  LPCSTR lpAppName,
  LPCSTR lpString,
  LPCSTR lpFileName);
extern(Windows) export BOOL WritePrivateProfileSectionW(
  LPCWSTR lpAppName,
  LPCWSTR lpString,
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias WritePrivateProfileSectionW WritePrivateProfileSection;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetPrivateProfileSectionNamesA(
  LPSTR lpszReturnBuffer,
  DWORD nSize,
  LPCSTR lpFileName);
extern(Windows) export DWORD GetPrivateProfileSectionNamesW(
  LPWSTR lpszReturnBuffer,
  DWORD nSize,
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias GetPrivateProfileSectionNamesW GetPrivateProfileSectionNames;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetPrivateProfileStructA(
  LPCSTR lpszSection,
  LPCSTR lpszKey,
  LPVOID lpStruct,
  UINT uSizeStruct,
  LPCSTR szFile);
extern(Windows) export BOOL GetPrivateProfileStructW(
  LPCWSTR lpszSection,
  LPCWSTR lpszKey,
  LPVOID lpStruct,
  UINT uSizeStruct,
  LPCWSTR szFile);
// #ifdef UNICODE
alias GetPrivateProfileStructW GetPrivateProfileStruct;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL WritePrivateProfileStructA(
  LPCSTR lpszSection,
  LPCSTR lpszKey,
  LPVOID lpStruct,
  UINT uSizeStruct,
  LPCSTR szFile);
extern(Windows) export BOOL WritePrivateProfileStructW(
  LPCWSTR lpszSection,
  LPCWSTR lpszKey,
  LPVOID lpStruct,
  UINT uSizeStruct,
  LPCWSTR szFile);
// #ifdef UNICODE
alias WritePrivateProfileStructW WritePrivateProfileStruct;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GetDriveTypeA(
  LPCSTR lpRootPathName);
extern(Windows) export UINT GetDriveTypeW(
  LPCWSTR lpRootPathName);
// #ifdef UNICODE
alias GetDriveTypeW GetDriveType;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GetSystemDirectoryA(
  LPSTR lpBuffer,
  UINT uSize);
extern(Windows) export UINT GetSystemDirectoryW(
  LPWSTR lpBuffer,
  UINT uSize);
// #ifdef UNICODE
alias GetSystemDirectoryW GetSystemDirectory;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetTempPathA(
  DWORD nBufferLength,
  LPSTR lpBuffer);
extern(Windows) export DWORD GetTempPathW(
  DWORD nBufferLength,
  LPWSTR lpBuffer);
// #ifdef UNICODE
alias GetTempPathW GetTempPath;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GetTempFileNameA(
  LPCSTR lpPathName,
  LPCSTR lpPrefixString,
  UINT uUnique,
  LPSTR lpTempFileName);
extern(Windows) export UINT GetTempFileNameW(
  LPCWSTR lpPathName,
  LPCWSTR lpPrefixString,
  UINT uUnique,
  LPWSTR lpTempFileName);
// #ifdef UNICODE
alias GetTempFileNameW GetTempFileName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GetWindowsDirectoryA(
  LPSTR lpBuffer,
  UINT uSize);
extern(Windows) export UINT GetWindowsDirectoryW(
  LPWSTR lpBuffer,
  UINT uSize);
// #ifdef UNICODE
alias GetWindowsDirectoryW GetWindowsDirectory;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export UINT GetSystemWindowsDirectoryA(
  LPSTR lpBuffer,
  UINT uSize);
extern(Windows) export UINT GetSystemWindowsDirectoryW(
  LPWSTR lpBuffer,
  UINT uSize);
// #ifdef UNICODE
alias GetSystemWindowsDirectoryW GetSystemWindowsDirectory;
// #else
// #...
// #endif // !UNICODE

// #if !defined(RC_INVOKED) // RC warns because "WINBASE_DECLARE_GET_SYSTEM_WOW64_DIRECTORY" is a bit long.
// #if _WIN32_WINNT >= 0x0501 || defined(WINBASE_DECLARE_GET_SYSTEM_WOW64_DIRECTORY)

extern(Windows) export UINT GetSystemWow64DirectoryA(
  LPSTR lpBuffer,
  UINT uSize);
extern(Windows) export UINT GetSystemWow64DirectoryW(
  LPWSTR lpBuffer,
  UINT uSize);
// #ifdef UNICODE
alias GetSystemWow64DirectoryW GetSystemWow64Directory;
// #else
// #...
// #endif // !UNICODE

extern(Windows) alias UINT function( LPSTR lpBuffer, UINT uSize) PGET_SYSTEM_WOW64_DIRECTORY_A;
extern(Windows) alias UINT function( LPWSTR lpBuffer, UINT uSize) PGET_SYSTEM_WOW64_DIRECTORY_W;

const char[] GET_SYSTEM_WOW64_DIRECTORY_NAME_A_A = "GetSystemWow64DirectoryA";
const wchar[] GET_SYSTEM_WOW64_DIRECTORY_NAME_A_W = "GetSystemWow64DirectoryA";
const TCHAR[] GET_SYSTEM_WOW64_DIRECTORY_NAME_A_T = "GetSystemWow64DirectoryA";
const char[] GET_SYSTEM_WOW64_DIRECTORY_NAME_W_A = "GetSystemWow64DirectoryW";
const wchar[] GET_SYSTEM_WOW64_DIRECTORY_NAME_W_W = "GetSystemWow64DirectoryW";
const TCHAR[] GET_SYSTEM_WOW64_DIRECTORY_NAME_W_T = "GetSystemWow64DirectoryW";

// #ifdef UNICODE
alias GET_SYSTEM_WOW64_DIRECTORY_NAME_W_A GET_SYSTEM_WOW64_DIRECTORY_NAME_T_A;
alias GET_SYSTEM_WOW64_DIRECTORY_NAME_W_W GET_SYSTEM_WOW64_DIRECTORY_NAME_T_W;
alias GET_SYSTEM_WOW64_DIRECTORY_NAME_W_T GET_SYSTEM_WOW64_DIRECTORY_NAME_T_T;
// #else
// #...
// #...
// #...
// #endif

// #endif // _WIN32_WINNT >= 0x0501
// #endif

extern(Windows) export BOOL SetCurrentDirectoryA(
  LPCSTR lpPathName);
extern(Windows) export BOOL SetCurrentDirectoryW(
  LPCWSTR lpPathName);
// #ifdef UNICODE
alias SetCurrentDirectoryW SetCurrentDirectory;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetCurrentDirectoryA(
  DWORD nBufferLength,
  LPSTR lpBuffer);
extern(Windows) export DWORD GetCurrentDirectoryW(
  DWORD nBufferLength,
  LPWSTR lpBuffer);
// #ifdef UNICODE
alias GetCurrentDirectoryW GetCurrentDirectory;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetDiskFreeSpaceA(
  LPCSTR lpRootPathName,
  LPDWORD lpSectorsPerCluster,
  LPDWORD lpBytesPerSector,
  LPDWORD lpNumberOfFreeClusters,
  LPDWORD lpTotalNumberOfClusters);
extern(Windows) export BOOL GetDiskFreeSpaceW(
  LPCWSTR lpRootPathName,
  LPDWORD lpSectorsPerCluster,
  LPDWORD lpBytesPerSector,
  LPDWORD lpNumberOfFreeClusters,
  LPDWORD lpTotalNumberOfClusters);
// #ifdef UNICODE
alias GetDiskFreeSpaceW GetDiskFreeSpace;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetDiskFreeSpaceExA(
  LPCSTR lpDirectoryName,
  PULARGE_INTEGER lpFreeBytesAvailableToCaller,
  PULARGE_INTEGER lpTotalNumberOfBytes,
  PULARGE_INTEGER lpTotalNumberOfFreeBytes);
extern(Windows) export BOOL GetDiskFreeSpaceExW(
  LPCWSTR lpDirectoryName,
  PULARGE_INTEGER lpFreeBytesAvailableToCaller,
  PULARGE_INTEGER lpTotalNumberOfBytes,
  PULARGE_INTEGER lpTotalNumberOfFreeBytes);
// #ifdef UNICODE
alias GetDiskFreeSpaceExW GetDiskFreeSpaceEx;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL CreateDirectoryA(
  LPCSTR lpPathName,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
extern(Windows) export BOOL CreateDirectoryW(
  LPCWSTR lpPathName,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
// #ifdef UNICODE
alias CreateDirectoryW CreateDirectory;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL CreateDirectoryExA(
  LPCSTR lpTemplateDirectory,
  LPCSTR lpNewDirectory,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
extern(Windows) export BOOL CreateDirectoryExW(
  LPCWSTR lpTemplateDirectory,
  LPCWSTR lpNewDirectory,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
// #ifdef UNICODE
alias CreateDirectoryExW CreateDirectoryEx;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL RemoveDirectoryA(
  LPCSTR lpPathName);
extern(Windows) export BOOL RemoveDirectoryW(
  LPCWSTR lpPathName);
// #ifdef UNICODE
alias RemoveDirectoryW RemoveDirectory;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetFullPathNameA(
  LPCSTR lpFileName,
  DWORD nBufferLength,
  LPSTR lpBuffer,
  LPSTR *lpFilePart);
extern(Windows) export DWORD GetFullPathNameW(
  LPCWSTR lpFileName,
  DWORD nBufferLength,
  LPWSTR lpBuffer,
  LPWSTR *lpFilePart);
// #ifdef UNICODE
alias GetFullPathNameW GetFullPathName;
// #else
// #...
// #endif // !UNICODE

enum : uint { DDD_RAW_TARGET_PATH = 0x00000001 }
enum : uint { DDD_REMOVE_DEFINITION = 0x00000002 }
enum : uint { DDD_EXACT_MATCH_ON_REMOVE = 0x00000004 }
enum : uint { DDD_NO_BROADCAST_SYSTEM = 0x00000008 }
enum : uint { DDD_LUID_BROADCAST_DRIVE = 0x00000010 }

extern(Windows) export BOOL DefineDosDeviceA(
  DWORD dwFlags,
  LPCSTR lpDeviceName,
  LPCSTR lpTargetPath);
extern(Windows) export BOOL DefineDosDeviceW(
  DWORD dwFlags,
  LPCWSTR lpDeviceName,
  LPCWSTR lpTargetPath);
// #ifdef UNICODE
alias DefineDosDeviceW DefineDosDevice;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD QueryDosDeviceA(
  LPCSTR lpDeviceName,
  LPSTR lpTargetPath,
  DWORD ucchMax);
extern(Windows) export DWORD QueryDosDeviceW(
  LPCWSTR lpDeviceName,
  LPWSTR lpTargetPath,
  DWORD ucchMax);
// #ifdef UNICODE
alias QueryDosDeviceW QueryDosDevice;
// #else
// #...
// #endif // !UNICODE

// #define EXPAND_LOCAL_DRIVES

extern(Windows) export HANDLE CreateFileA(
  LPCSTR lpFileName,
  DWORD dwDesiredAccess,
  DWORD dwShareMode,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  DWORD dwCreationDisposition,
  DWORD dwFlagsAndAttributes,
  HANDLE hTemplateFile);
extern(Windows) export HANDLE CreateFileW(
  LPCWSTR lpFileName,
  DWORD dwDesiredAccess,
  DWORD dwShareMode,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  DWORD dwCreationDisposition,
  DWORD dwFlagsAndAttributes,
  HANDLE hTemplateFile);
// #ifdef UNICODE
alias CreateFileW CreateFile;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetFileAttributesA(
  LPCSTR lpFileName,
  DWORD dwFileAttributes);
extern(Windows) export BOOL SetFileAttributesW(
  LPCWSTR lpFileName,
  DWORD dwFileAttributes);
// #ifdef UNICODE
alias SetFileAttributesW SetFileAttributes;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetFileAttributesA(
  LPCSTR lpFileName);
extern(Windows) export DWORD GetFileAttributesW(
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias GetFileAttributesW GetFileAttributes;
// #else
// #...
// #endif // !UNICODE

alias int _GET_FILEEX_INFO_LEVELS;
enum {
  GetFileExInfoStandard,
  GetFileExMaxInfoLevel,
}
alias _GET_FILEEX_INFO_LEVELS GET_FILEEX_INFO_LEVELS;

extern(Windows) export BOOL GetFileAttributesExA(
  LPCSTR lpFileName,
  GET_FILEEX_INFO_LEVELS fInfoLevelId,
  LPVOID lpFileInformation);
extern(Windows) export BOOL GetFileAttributesExW(
  LPCWSTR lpFileName,
  GET_FILEEX_INFO_LEVELS fInfoLevelId,
  LPVOID lpFileInformation);
// #ifdef UNICODE
alias GetFileAttributesExW GetFileAttributesEx;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD GetCompressedFileSizeA(
  LPCSTR lpFileName,
  LPDWORD lpFileSizeHigh);
extern(Windows) export DWORD GetCompressedFileSizeW(
  LPCWSTR lpFileName,
  LPDWORD lpFileSizeHigh);
// #ifdef UNICODE
alias GetCompressedFileSizeW GetCompressedFileSize;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL DeleteFileA(
  LPCSTR lpFileName);
extern(Windows) export BOOL DeleteFileW(
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias DeleteFileW DeleteFile;
// #else
// #...
// #endif // !UNICODE

// #if(_WIN32_WINNT >= 0x0400)
alias int _FINDEX_INFO_LEVELS;
enum {
  FindExInfoStandard,
  FindExInfoMaxInfoLevel,
}
alias _FINDEX_INFO_LEVELS FINDEX_INFO_LEVELS;

alias int _FINDEX_SEARCH_OPS;
enum {
  FindExSearchNameMatch,
  FindExSearchLimitToDirectories,
  FindExSearchLimitToDevices,
  FindExSearchMaxSearchOp,
}
alias _FINDEX_SEARCH_OPS FINDEX_SEARCH_OPS;

enum : uint { FIND_FIRST_EX_CASE_SENSITIVE = 0x00000001 }

extern(Windows) export HANDLE FindFirstFileExA(
  LPCSTR lpFileName,
  FINDEX_INFO_LEVELS fInfoLevelId,
  LPVOID lpFindFileData,
  FINDEX_SEARCH_OPS fSearchOp,
  LPVOID lpSearchFilter,
  DWORD dwAdditionalFlags);
extern(Windows) export HANDLE FindFirstFileExW(
  LPCWSTR lpFileName,
  FINDEX_INFO_LEVELS fInfoLevelId,
  LPVOID lpFindFileData,
  FINDEX_SEARCH_OPS fSearchOp,
  LPVOID lpSearchFilter,
  DWORD dwAdditionalFlags);
// #ifdef UNICODE
alias FindFirstFileExW FindFirstFileEx;
// #else
// #...
// #endif // !UNICODE
// #endif /* _WIN32_WINNT >= 0x0400 */

extern(Windows) export HANDLE FindFirstFileA(
  LPCSTR lpFileName,
  LPWIN32_FIND_DATAA lpFindFileData);
extern(Windows) export HANDLE FindFirstFileW(
  LPCWSTR lpFileName,
  LPWIN32_FIND_DATAW lpFindFileData);
// #ifdef UNICODE
alias FindFirstFileW FindFirstFile;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL FindNextFileA(
  HANDLE hFindFile,
  LPWIN32_FIND_DATAA lpFindFileData);
extern(Windows) export BOOL FindNextFileW(
  HANDLE hFindFile,
  LPWIN32_FIND_DATAW lpFindFileData);
// #ifdef UNICODE
alias FindNextFileW FindNextFile;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD SearchPathA(
  LPCSTR lpPath,
  LPCSTR lpFileName,
  LPCSTR lpExtension,
  DWORD nBufferLength,
  LPSTR lpBuffer,
  LPSTR *lpFilePart);
extern(Windows) export DWORD SearchPathW(
  LPCWSTR lpPath,
  LPCWSTR lpFileName,
  LPCWSTR lpExtension,
  DWORD nBufferLength,
  LPWSTR lpBuffer,
  LPWSTR *lpFilePart);
// #ifdef UNICODE
alias SearchPathW SearchPath;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL CopyFileA(
  LPCSTR lpExistingFileName,
  LPCSTR lpNewFileName,
  BOOL bFailIfExists);
extern(Windows) export BOOL CopyFileW(
  LPCWSTR lpExistingFileName,
  LPCWSTR lpNewFileName,
  BOOL bFailIfExists);
// #ifdef UNICODE
alias CopyFileW CopyFile;
// #else
// #...
// #endif // !UNICODE

// #if(_WIN32_WINNT >= 0x0400)
extern(Windows) alias DWORD function( LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData  ) LPPROGRESS_ROUTINE;

extern(Windows) export BOOL CopyFileExA(
  LPCSTR lpExistingFileName,
  LPCSTR lpNewFileName,
  LPPROGRESS_ROUTINE lpProgressRoutine ,
  LPVOID lpData ,
  LPBOOL pbCancel ,
  DWORD dwCopyFlags);
extern(Windows) export BOOL CopyFileExW(
  LPCWSTR lpExistingFileName,
  LPCWSTR lpNewFileName,
  LPPROGRESS_ROUTINE lpProgressRoutine ,
  LPVOID lpData ,
  LPBOOL pbCancel ,
  DWORD dwCopyFlags);
// #ifdef UNICODE
alias CopyFileExW CopyFileEx;
// #else
// #...
// #endif // !UNICODE
// #endif /* _WIN32_WINNT >= 0x0400 */

extern(Windows) export BOOL MoveFileA(
  LPCSTR lpExistingFileName,
  LPCSTR lpNewFileName);
extern(Windows) export BOOL MoveFileW(
  LPCWSTR lpExistingFileName,
  LPCWSTR lpNewFileName);
// #ifdef UNICODE
alias MoveFileW MoveFile;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL MoveFileExA(
  LPCSTR lpExistingFileName,
  LPCSTR lpNewFileName,
  DWORD dwFlags);
extern(Windows) export BOOL MoveFileExW(
  LPCWSTR lpExistingFileName,
  LPCWSTR lpNewFileName,
  DWORD dwFlags);
// #ifdef UNICODE
alias MoveFileExW MoveFileEx;
// #else
// #...
// #endif // !UNICODE

// #if (_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL MoveFileWithProgressA(
  LPCSTR lpExistingFileName,
  LPCSTR lpNewFileName,
  LPPROGRESS_ROUTINE lpProgressRoutine ,
  LPVOID lpData ,
  DWORD dwFlags);
extern(Windows) export BOOL MoveFileWithProgressW(
  LPCWSTR lpExistingFileName,
  LPCWSTR lpNewFileName,
  LPPROGRESS_ROUTINE lpProgressRoutine ,
  LPVOID lpData ,
  DWORD dwFlags);
// #ifdef UNICODE
alias MoveFileWithProgressW MoveFileWithProgress;
// #else
// #...
// #endif // !UNICODE
// #endif // (_WIN32_WINNT >= 0x0500)

enum : uint { MOVEFILE_REPLACE_EXISTING = 0x00000001 }
enum : uint { MOVEFILE_COPY_ALLOWED = 0x00000002 }
enum : uint { MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004 }
enum : uint { MOVEFILE_WRITE_THROUGH = 0x00000008 }
// #if (_WIN32_WINNT >= 0x0500)
enum : uint { MOVEFILE_CREATE_HARDLINK = 0x00000010 }
enum : uint { MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x00000020 }
// #endif // (_WIN32_WINNT >= 0x0500)

// #if (_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL ReplaceFileA(
  LPCSTR lpReplacedFileName,
  LPCSTR lpReplacementFileName,
  LPCSTR lpBackupFileName,
  DWORD dwReplaceFlags,
  LPVOID lpExclude,
  LPVOID lpReserved);
extern(Windows) export BOOL ReplaceFileW(
  LPCWSTR lpReplacedFileName,
  LPCWSTR lpReplacementFileName,
  LPCWSTR lpBackupFileName,
  DWORD dwReplaceFlags,
  LPVOID lpExclude,
  LPVOID lpReserved);
// #ifdef UNICODE
alias ReplaceFileW ReplaceFile;
// #else
// #...
// #endif // !UNICODE
// #endif // (_WIN32_WINNT >= 0x0500)

// #if (_WIN32_WINNT >= 0x0500)

extern(Windows) export BOOL CreateHardLinkA(
  LPCSTR lpFileName,
  LPCSTR lpExistingFileName,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
extern(Windows) export BOOL CreateHardLinkW(
  LPCWSTR lpFileName,
  LPCWSTR lpExistingFileName,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
// #ifdef UNICODE
alias CreateHardLinkW CreateHardLink;
// #else
// #...
// #endif // !UNICODE

// #endif // (_WIN32_WINNT >= 0x0500)

extern(Windows) export HANDLE CreateNamedPipeA(
  LPCSTR lpName,
  DWORD dwOpenMode,
  DWORD dwPipeMode,
  DWORD nMaxInstances,
  DWORD nOutBufferSize,
  DWORD nInBufferSize,
  DWORD nDefaultTimeOut,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
extern(Windows) export HANDLE CreateNamedPipeW(
  LPCWSTR lpName,
  DWORD dwOpenMode,
  DWORD dwPipeMode,
  DWORD nMaxInstances,
  DWORD nOutBufferSize,
  DWORD nInBufferSize,
  DWORD nDefaultTimeOut,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);
// #ifdef UNICODE
alias CreateNamedPipeW CreateNamedPipe;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetNamedPipeHandleStateA(
  HANDLE hNamedPipe,
  LPDWORD lpState,
  LPDWORD lpCurInstances,
  LPDWORD lpMaxCollectionCount,
  LPDWORD lpCollectDataTimeout,
  LPSTR lpUserName,
  DWORD nMaxUserNameSize);
extern(Windows) export BOOL GetNamedPipeHandleStateW(
  HANDLE hNamedPipe,
  LPDWORD lpState,
  LPDWORD lpCurInstances,
  LPDWORD lpMaxCollectionCount,
  LPDWORD lpCollectDataTimeout,
  LPWSTR lpUserName,
  DWORD nMaxUserNameSize);
// #ifdef UNICODE
alias GetNamedPipeHandleStateW GetNamedPipeHandleState;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL CallNamedPipeA(
  LPCSTR lpNamedPipeName,
  LPVOID lpInBuffer,
  DWORD nInBufferSize,
  LPVOID lpOutBuffer,
  DWORD nOutBufferSize,
  LPDWORD lpBytesRead,
  DWORD nTimeOut);
extern(Windows) export BOOL CallNamedPipeW(
  LPCWSTR lpNamedPipeName,
  LPVOID lpInBuffer,
  DWORD nInBufferSize,
  LPVOID lpOutBuffer,
  DWORD nOutBufferSize,
  LPDWORD lpBytesRead,
  DWORD nTimeOut);
// #ifdef UNICODE
alias CallNamedPipeW CallNamedPipe;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL WaitNamedPipeA(
  LPCSTR lpNamedPipeName,
  DWORD nTimeOut);
extern(Windows) export BOOL WaitNamedPipeW(
  LPCWSTR lpNamedPipeName,
  DWORD nTimeOut);
// #ifdef UNICODE
alias WaitNamedPipeW WaitNamedPipe;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetVolumeLabelA(
  LPCSTR lpRootPathName,
  LPCSTR lpVolumeName);
extern(Windows) export BOOL SetVolumeLabelW(
  LPCWSTR lpRootPathName,
  LPCWSTR lpVolumeName);
// #ifdef UNICODE
alias SetVolumeLabelW SetVolumeLabel;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export VOID SetFileApisToOEM();

extern(Windows) export VOID SetFileApisToANSI();

extern(Windows) export BOOL AreFileApisANSI();

extern(Windows) export BOOL GetVolumeInformationA(
  LPCSTR lpRootPathName,
  LPSTR lpVolumeNameBuffer,
  DWORD nVolumeNameSize,
  LPDWORD lpVolumeSerialNumber,
  LPDWORD lpMaximumComponentLength,
  LPDWORD lpFileSystemFlags,
  LPSTR lpFileSystemNameBuffer,
  DWORD nFileSystemNameSize);
extern(Windows) export BOOL GetVolumeInformationW(
  LPCWSTR lpRootPathName,
  LPWSTR lpVolumeNameBuffer,
  DWORD nVolumeNameSize,
  LPDWORD lpVolumeSerialNumber,
  LPDWORD lpMaximumComponentLength,
  LPDWORD lpFileSystemFlags,
  LPWSTR lpFileSystemNameBuffer,
  DWORD nFileSystemNameSize);
// #ifdef UNICODE
alias GetVolumeInformationW GetVolumeInformation;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL CancelIo(
  HANDLE hFile);

extern(Windows) export BOOL ClearEventLogA(
  HANDLE hEventLog,
  LPCSTR lpBackupFileName);
extern(Windows) export BOOL ClearEventLogW(
  HANDLE hEventLog,
  LPCWSTR lpBackupFileName);
// #ifdef UNICODE
alias ClearEventLogW ClearEventLog;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL BackupEventLogA(
  HANDLE hEventLog,
  LPCSTR lpBackupFileName);
extern(Windows) export BOOL BackupEventLogW(
  HANDLE hEventLog,
  LPCWSTR lpBackupFileName);
// #ifdef UNICODE
alias BackupEventLogW BackupEventLog;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL CloseEventLog(
  HANDLE hEventLog);

extern(Windows) export BOOL DeregisterEventSource(
  HANDLE hEventLog);

extern(Windows) export BOOL NotifyChangeEventLog(
  HANDLE hEventLog,
  HANDLE hEvent);

extern(Windows) export BOOL GetNumberOfEventLogRecords(
  HANDLE hEventLog,
  PDWORD NumberOfRecords);

extern(Windows) export BOOL GetOldestEventLogRecord(
  HANDLE hEventLog,
  PDWORD OldestRecord);

extern(Windows) export HANDLE OpenEventLogA(
  LPCSTR lpUNCServerName,
  LPCSTR lpSourceName);
extern(Windows) export HANDLE OpenEventLogW(
  LPCWSTR lpUNCServerName,
  LPCWSTR lpSourceName);
// #ifdef UNICODE
alias OpenEventLogW OpenEventLog;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE RegisterEventSourceA(
  LPCSTR lpUNCServerName,
  LPCSTR lpSourceName);
extern(Windows) export HANDLE RegisterEventSourceW(
  LPCWSTR lpUNCServerName,
  LPCWSTR lpSourceName);
// #ifdef UNICODE
alias RegisterEventSourceW RegisterEventSource;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE OpenBackupEventLogA(
  LPCSTR lpUNCServerName,
  LPCSTR lpFileName);
extern(Windows) export HANDLE OpenBackupEventLogW(
  LPCWSTR lpUNCServerName,
  LPCWSTR lpFileName);
// #ifdef UNICODE
alias OpenBackupEventLogW OpenBackupEventLog;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL ReadEventLogA(
  HANDLE hEventLog,
  DWORD dwReadFlags,
  DWORD dwRecordOffset,
  LPVOID lpBuffer,
  DWORD nNumberOfBytesToRead,
  DWORD *pnBytesRead,
  DWORD *pnMinNumberOfBytesNeeded);
extern(Windows) export BOOL ReadEventLogW(
  HANDLE hEventLog,
  DWORD dwReadFlags,
  DWORD dwRecordOffset,
  LPVOID lpBuffer,
  DWORD nNumberOfBytesToRead,
  DWORD *pnBytesRead,
  DWORD *pnMinNumberOfBytesNeeded);
// #ifdef UNICODE
alias ReadEventLogW ReadEventLog;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL ReportEventA(
  HANDLE hEventLog,
  WORD wType,
  WORD wCategory,
  DWORD dwEventID,
  PSID lpUserSid,
  WORD wNumStrings,
  DWORD dwDataSize,
  LPCSTR *lpStrings,
  LPVOID lpRawData);
extern(Windows) export BOOL ReportEventW(
  HANDLE hEventLog,
  WORD wType,
  WORD wCategory,
  DWORD dwEventID,
  PSID lpUserSid,
  WORD wNumStrings,
  DWORD dwDataSize,
  LPCWSTR *lpStrings,
  LPVOID lpRawData);
// #ifdef UNICODE
alias ReportEventW ReportEvent;
// #else
// #...
// #endif // !UNICODE

enum : uint { EVENTLOG_FULL_INFO = 0 }

struct _EVENTLOG_FULL_INFORMATION {
  DWORD dwFull;
}
alias _EVENTLOG_FULL_INFORMATION EVENTLOG_FULL_INFORMATION;
alias _EVENTLOG_FULL_INFORMATION* LPEVENTLOG_FULL_INFORMATION;

extern(Windows) export BOOL GetEventLogInformation(
  HANDLE hEventLog,
  DWORD dwInfoLevel,
  LPVOID lpBuffer,
  DWORD cbBufSize,
  LPDWORD pcbBytesNeeded);

extern(Windows) export BOOL DuplicateToken(
  HANDLE ExistingTokenHandle,
  SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  PHANDLE DuplicateTokenHandle);

extern(Windows) export BOOL GetKernelObjectSecurity(
  HANDLE Handle,
  SECURITY_INFORMATION RequestedInformation,
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  DWORD nLength,
  LPDWORD lpnLengthNeeded);

extern(Windows) export BOOL ImpersonateNamedPipeClient(
  HANDLE hNamedPipe);

extern(Windows) export BOOL ImpersonateSelf(
  SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);

extern(Windows) export BOOL RevertToSelf();

extern(Windows) export BOOL SetThreadToken(
  PHANDLE Thread,
  HANDLE Token);

extern(Windows) export BOOL AccessCheck(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  HANDLE ClientToken,
  DWORD DesiredAccess,
  PGENERIC_MAPPING GenericMapping,
  PPRIVILEGE_SET PrivilegeSet,
  LPDWORD PrivilegeSetLength,
  LPDWORD GrantedAccess,
  LPBOOL AccessStatus);

// #if(_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL AccessCheckByType(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  PSID PrincipalSelfSid,
  HANDLE ClientToken,
  DWORD DesiredAccess,
  POBJECT_TYPE_LIST ObjectTypeList,
  DWORD ObjectTypeListLength,
  PGENERIC_MAPPING GenericMapping,
  PPRIVILEGE_SET PrivilegeSet,
  LPDWORD PrivilegeSetLength,
  LPDWORD GrantedAccess,
  LPBOOL AccessStatus);

extern(Windows) export BOOL AccessCheckByTypeResultList(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  PSID PrincipalSelfSid,
  HANDLE ClientToken,
  DWORD DesiredAccess,
  POBJECT_TYPE_LIST ObjectTypeList,
  DWORD ObjectTypeListLength,
  PGENERIC_MAPPING GenericMapping,
  PPRIVILEGE_SET PrivilegeSet,
  LPDWORD PrivilegeSetLength,
  LPDWORD GrantedAccessList,
  LPDWORD AccessStatusList);
// #endif /* _WIN32_WINNT >=  0x0500 */

extern(Windows) export BOOL OpenProcessToken(
  HANDLE ProcessHandle,
  DWORD DesiredAccess,
  PHANDLE TokenHandle);

extern(Windows) export BOOL OpenThreadToken(
  HANDLE ThreadHandle,
  DWORD DesiredAccess,
  BOOL OpenAsSelf,
  PHANDLE TokenHandle);

extern(Windows) export BOOL GetTokenInformation(
  HANDLE TokenHandle,
  TOKEN_INFORMATION_CLASS TokenInformationClass,
  LPVOID TokenInformation,
  DWORD TokenInformationLength,
  PDWORD ReturnLength);

extern(Windows) export BOOL SetTokenInformation(
  HANDLE TokenHandle,
  TOKEN_INFORMATION_CLASS TokenInformationClass,
  LPVOID TokenInformation,
  DWORD TokenInformationLength);

extern(Windows) export BOOL AdjustTokenPrivileges(
  HANDLE TokenHandle,
  BOOL DisableAllPrivileges,
  PTOKEN_PRIVILEGES NewState,
  DWORD BufferLength,
  PTOKEN_PRIVILEGES PreviousState,
  PDWORD ReturnLength);

extern(Windows) export BOOL AdjustTokenGroups(
  HANDLE TokenHandle,
  BOOL ResetToDefault,
  PTOKEN_GROUPS NewState,
  DWORD BufferLength,
  PTOKEN_GROUPS PreviousState,
  PDWORD ReturnLength);

extern(Windows) export BOOL PrivilegeCheck(
  HANDLE ClientToken,
  PPRIVILEGE_SET RequiredPrivileges,
  LPBOOL pfResult);

extern(Windows) export BOOL AccessCheckAndAuditAlarmA(
  LPCSTR SubsystemName,
  LPVOID HandleId,
  LPSTR ObjectTypeName,
  LPSTR ObjectName,
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  DWORD DesiredAccess,
  PGENERIC_MAPPING GenericMapping,
  BOOL ObjectCreation,
  LPDWORD GrantedAccess,
  LPBOOL AccessStatus,
  LPBOOL pfGenerateOnClose);
extern(Windows) export BOOL AccessCheckAndAuditAlarmW(
  LPCWSTR SubsystemName,
  LPVOID HandleId,
  LPWSTR ObjectTypeName,
  LPWSTR ObjectName,
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  DWORD DesiredAccess,
  PGENERIC_MAPPING GenericMapping,
  BOOL ObjectCreation,
  LPDWORD GrantedAccess,
  LPBOOL AccessStatus,
  LPBOOL pfGenerateOnClose);
// #ifdef UNICODE
alias AccessCheckAndAuditAlarmW AccessCheckAndAuditAlarm;
// #else
// #...
// #endif // !UNICODE

// #if(_WIN32_WINNT >= 0x0500)

extern(Windows) export BOOL AccessCheckByTypeAndAuditAlarmA(
  LPCSTR SubsystemName,
  LPVOID HandleId,
  LPCSTR ObjectTypeName,
  LPCSTR ObjectName,
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  PSID PrincipalSelfSid,
  DWORD DesiredAccess,
  AUDIT_EVENT_TYPE AuditType,
  DWORD Flags,
  POBJECT_TYPE_LIST ObjectTypeList,
  DWORD ObjectTypeListLength,
  PGENERIC_MAPPING GenericMapping,
  BOOL ObjectCreation,
  LPDWORD GrantedAccess,
  LPBOOL AccessStatus,
  LPBOOL pfGenerateOnClose);
extern(Windows) export BOOL AccessCheckByTypeAndAuditAlarmW(
  LPCWSTR SubsystemName,
  LPVOID HandleId,
  LPCWSTR ObjectTypeName,
  LPCWSTR ObjectName,
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  PSID PrincipalSelfSid,
  DWORD DesiredAccess,
  AUDIT_EVENT_TYPE AuditType,
  DWORD Flags,
  POBJECT_TYPE_LIST ObjectTypeList,
  DWORD ObjectTypeListLength,
  PGENERIC_MAPPING GenericMapping,
  BOOL ObjectCreation,
  LPDWORD GrantedAccess,
  LPBOOL AccessStatus,
  LPBOOL pfGenerateOnClose);
// #ifdef UNICODE
alias AccessCheckByTypeAndAuditAlarmW AccessCheckByTypeAndAuditAlarm;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL AccessCheckByTypeResultListAndAuditAlarmA(
  LPCSTR SubsystemName,
  LPVOID HandleId,
  LPCSTR ObjectTypeName,
  LPCSTR ObjectName,
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  PSID PrincipalSelfSid,
  DWORD DesiredAccess,
  AUDIT_EVENT_TYPE AuditType,
  DWORD Flags,
  POBJECT_TYPE_LIST ObjectTypeList,
  DWORD ObjectTypeListLength,
  PGENERIC_MAPPING GenericMapping,
  BOOL ObjectCreation,
  LPDWORD GrantedAccess,
  LPDWORD AccessStatusList,
  LPBOOL pfGenerateOnClose);
extern(Windows) export BOOL AccessCheckByTypeResultListAndAuditAlarmW(
  LPCWSTR SubsystemName,
  LPVOID HandleId,
  LPCWSTR ObjectTypeName,
  LPCWSTR ObjectName,
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  PSID PrincipalSelfSid,
  DWORD DesiredAccess,
  AUDIT_EVENT_TYPE AuditType,
  DWORD Flags,
  POBJECT_TYPE_LIST ObjectTypeList,
  DWORD ObjectTypeListLength,
  PGENERIC_MAPPING GenericMapping,
  BOOL ObjectCreation,
  LPDWORD GrantedAccess,
  LPDWORD AccessStatusList,
  LPBOOL pfGenerateOnClose);
// #ifdef UNICODE
alias AccessCheckByTypeResultListAndAuditAlarmW AccessCheckByTypeResultListAndAuditAlarm;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL AccessCheckByTypeResultListAndAuditAlarmByHandleA(
  LPCSTR SubsystemName,
  LPVOID HandleId,
  HANDLE ClientToken,
  LPCSTR ObjectTypeName,
  LPCSTR ObjectName,
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  PSID PrincipalSelfSid,
  DWORD DesiredAccess,
  AUDIT_EVENT_TYPE AuditType,
  DWORD Flags,
  POBJECT_TYPE_LIST ObjectTypeList,
  DWORD ObjectTypeListLength,
  PGENERIC_MAPPING GenericMapping,
  BOOL ObjectCreation,
  LPDWORD GrantedAccess,
  LPDWORD AccessStatusList,
  LPBOOL pfGenerateOnClose);
extern(Windows) export BOOL AccessCheckByTypeResultListAndAuditAlarmByHandleW(
  LPCWSTR SubsystemName,
  LPVOID HandleId,
  HANDLE ClientToken,
  LPCWSTR ObjectTypeName,
  LPCWSTR ObjectName,
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  PSID PrincipalSelfSid,
  DWORD DesiredAccess,
  AUDIT_EVENT_TYPE AuditType,
  DWORD Flags,
  POBJECT_TYPE_LIST ObjectTypeList,
  DWORD ObjectTypeListLength,
  PGENERIC_MAPPING GenericMapping,
  BOOL ObjectCreation,
  LPDWORD GrantedAccess,
  LPDWORD AccessStatusList,
  LPBOOL pfGenerateOnClose);
// #ifdef UNICODE
alias AccessCheckByTypeResultListAndAuditAlarmByHandleW AccessCheckByTypeResultListAndAuditAlarmByHandle;
// #else
// #...
// #endif // !UNICODE

// #endif //(_WIN32_WINNT >= 0x0500)

extern(Windows) export BOOL ObjectOpenAuditAlarmA(
  LPCSTR SubsystemName,
  LPVOID HandleId,
  LPSTR ObjectTypeName,
  LPSTR ObjectName,
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  HANDLE ClientToken,
  DWORD DesiredAccess,
  DWORD GrantedAccess,
  PPRIVILEGE_SET Privileges,
  BOOL ObjectCreation,
  BOOL AccessGranted,
  LPBOOL GenerateOnClose);
extern(Windows) export BOOL ObjectOpenAuditAlarmW(
  LPCWSTR SubsystemName,
  LPVOID HandleId,
  LPWSTR ObjectTypeName,
  LPWSTR ObjectName,
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  HANDLE ClientToken,
  DWORD DesiredAccess,
  DWORD GrantedAccess,
  PPRIVILEGE_SET Privileges,
  BOOL ObjectCreation,
  BOOL AccessGranted,
  LPBOOL GenerateOnClose);
// #ifdef UNICODE
alias ObjectOpenAuditAlarmW ObjectOpenAuditAlarm;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL ObjectPrivilegeAuditAlarmA(
  LPCSTR SubsystemName,
  LPVOID HandleId,
  HANDLE ClientToken,
  DWORD DesiredAccess,
  PPRIVILEGE_SET Privileges,
  BOOL AccessGranted);
extern(Windows) export BOOL ObjectPrivilegeAuditAlarmW(
  LPCWSTR SubsystemName,
  LPVOID HandleId,
  HANDLE ClientToken,
  DWORD DesiredAccess,
  PPRIVILEGE_SET Privileges,
  BOOL AccessGranted);
// #ifdef UNICODE
alias ObjectPrivilegeAuditAlarmW ObjectPrivilegeAuditAlarm;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL ObjectCloseAuditAlarmA(
  LPCSTR SubsystemName,
  LPVOID HandleId,
  BOOL GenerateOnClose);
extern(Windows) export BOOL ObjectCloseAuditAlarmW(
  LPCWSTR SubsystemName,
  LPVOID HandleId,
  BOOL GenerateOnClose);
// #ifdef UNICODE
alias ObjectCloseAuditAlarmW ObjectCloseAuditAlarm;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL ObjectDeleteAuditAlarmA(
  LPCSTR SubsystemName,
  LPVOID HandleId,
  BOOL GenerateOnClose);
extern(Windows) export BOOL ObjectDeleteAuditAlarmW(
  LPCWSTR SubsystemName,
  LPVOID HandleId,
  BOOL GenerateOnClose);
// #ifdef UNICODE
alias ObjectDeleteAuditAlarmW ObjectDeleteAuditAlarm;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL PrivilegedServiceAuditAlarmA(
  LPCSTR SubsystemName,
  LPCSTR ServiceName,
  HANDLE ClientToken,
  PPRIVILEGE_SET Privileges,
  BOOL AccessGranted);
extern(Windows) export BOOL PrivilegedServiceAuditAlarmW(
  LPCWSTR SubsystemName,
  LPCWSTR ServiceName,
  HANDLE ClientToken,
  PPRIVILEGE_SET Privileges,
  BOOL AccessGranted);
// #ifdef UNICODE
alias PrivilegedServiceAuditAlarmW PrivilegedServiceAuditAlarm;
// #else
// #...
// #endif // !UNICODE

// #if(_WIN32_WINNT >= 0x0501)

enum _0 {

  WinNullSid = 0,
  WinWorldSid = 1,
  WinLocalSid = 2,
  WinCreatorOwnerSid = 3,
  WinCreatorGroupSid = 4,
  WinCreatorOwnerServerSid = 5,
  WinCreatorGroupServerSid = 6,
  WinNtAuthoritySid = 7,
  WinDialupSid = 8,
  WinNetworkSid = 9,
  WinBatchSid = 10,
  WinInteractiveSid = 11,
  WinServiceSid = 12,
  WinAnonymousSid = 13,
  WinProxySid = 14,
  WinEnterpriseControllersSid = 15,
  WinSelfSid = 16,
  WinAuthenticatedUserSid = 17,
  WinRestrictedCodeSid = 18,
  WinTerminalServerSid = 19,
  WinRemoteLogonIdSid = 20,
  WinLogonIdsSid = 21,
  WinLocalSystemSid = 22,
  WinLocalServiceSid = 23,
  WinNetworkServiceSid = 24,
  WinBuiltinDomainSid = 25,
  WinBuiltinAdministratorsSid = 26,
  WinBuiltinUsersSid = 27,
  WinBuiltinGuestsSid = 28,
  WinBuiltinPowerUsersSid = 29,
  WinBuiltinAccountOperatorsSid = 30,
  WinBuiltinSystemOperatorsSid = 31,
  WinBuiltinPrintOperatorsSid = 32,
  WinBuiltinBackupOperatorsSid = 33,
  WinBuiltinReplicatorSid = 34,
  WinBuiltinPreWindows2000CompatibleAccessSid = 35,
  WinBuiltinRemoteDesktopUsersSid = 36,
  WinBuiltinNetworkConfigurationOperatorsSid = 37,
  WinAccountAdministratorSid = 38,
  WinAccountGuestSid = 39,
  WinAccountKrbtgtSid = 40,
  WinAccountDomainAdminsSid = 41,
  WinAccountDomainUsersSid = 42,
  WinAccountDomainGuestsSid = 43,
  WinAccountComputersSid = 44,
  WinAccountControllersSid = 45,
  WinAccountCertAdminsSid = 46,
  WinAccountSchemaAdminsSid = 47,
  WinAccountEnterpriseAdminsSid = 48,
  WinAccountPolicyAdminsSid = 49,
  WinAccountRasAndIasServersSid = 50,

}
alias _0 WELL_KNOWN_SID_TYPE;

extern(Windows) export BOOL IsWellKnownSid(
  PSID pSid,
  WELL_KNOWN_SID_TYPE WellKnownSidType);

extern(Windows) export BOOL CreateWellKnownSid(
  WELL_KNOWN_SID_TYPE WellKnownSidType,
  PSID DomainSid ,
  PSID pSid,
  DWORD *cbSid);

extern(Windows) export BOOL EqualDomainSid(
  PSID pSid1,
  PSID pSid2,
  BOOL *pfEqual);

extern(Windows) export BOOL GetWindowsAccountDomainSid(
  PSID pSid,
  PSID ppDomainSid ,
  DWORD *cbSid);

// #endif //(_WIN32_WINNT >= 0x0501)

extern(Windows) export BOOL IsValidSid(
  PSID pSid);

extern(Windows) export BOOL EqualSid(
  PSID pSid1,
  PSID pSid2);

extern(Windows) export BOOL EqualPrefixSid(
  PSID pSid1,
  PSID pSid2);

extern(Windows) export DWORD GetSidLengthRequired(
  UCHAR nSubAuthorityCount);

extern(Windows) export BOOL AllocateAndInitializeSid(
  PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
  BYTE nSubAuthorityCount,
  DWORD nSubAuthority0,
  DWORD nSubAuthority1,
  DWORD nSubAuthority2,
  DWORD nSubAuthority3,
  DWORD nSubAuthority4,
  DWORD nSubAuthority5,
  DWORD nSubAuthority6,
  DWORD nSubAuthority7,
  PSID *pSid);

extern(Windows) export PVOID FreeSid(
  PSID pSid);

extern(Windows) export BOOL InitializeSid(
  PSID Sid,
  PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
  BYTE nSubAuthorityCount);

extern(Windows) export PSID_IDENTIFIER_AUTHORITY GetSidIdentifierAuthority(
  PSID pSid);

extern(Windows) export PDWORD GetSidSubAuthority(
  PSID pSid,
  DWORD nSubAuthority);

extern(Windows) export PUCHAR GetSidSubAuthorityCount(
  PSID pSid);

extern(Windows) export DWORD GetLengthSid(
  PSID pSid);

extern(Windows) export BOOL CopySid(
  DWORD nDestinationSidLength,
  PSID pDestinationSid,
  PSID pSourceSid);

extern(Windows) export BOOL AreAllAccessesGranted(
  DWORD GrantedAccess,
  DWORD DesiredAccess);

extern(Windows) export BOOL AreAnyAccessesGranted(
  DWORD GrantedAccess,
  DWORD DesiredAccess);

extern(Windows) export VOID MapGenericMask(
  PDWORD AccessMask,
  PGENERIC_MAPPING GenericMapping);

extern(Windows) export BOOL IsValidAcl(
  PACL pAcl);

extern(Windows) export BOOL InitializeAcl(
  PACL pAcl,
  DWORD nAclLength,
  DWORD dwAclRevision);

extern(Windows) export BOOL GetAclInformation(
  PACL pAcl,
  LPVOID pAclInformation,
  DWORD nAclInformationLength,
  ACL_INFORMATION_CLASS dwAclInformationClass);

extern(Windows) export BOOL SetAclInformation(
  PACL pAcl,
  LPVOID pAclInformation,
  DWORD nAclInformationLength,
  ACL_INFORMATION_CLASS dwAclInformationClass);

extern(Windows) export BOOL AddAce(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD dwStartingAceIndex,
  LPVOID pAceList,
  DWORD nAceListLength);

extern(Windows) export BOOL DeleteAce(
  PACL pAcl,
  DWORD dwAceIndex);

extern(Windows) export BOOL GetAce(
  PACL pAcl,
  DWORD dwAceIndex,
  LPVOID *pAce);

extern(Windows) export BOOL AddAccessAllowedAce(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD AccessMask,
  PSID pSid);

// #if(_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL AddAccessAllowedAceEx(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD AceFlags,
  DWORD AccessMask,
  PSID pSid);
// #endif /* _WIN32_WINNT >=  0x0500 */

extern(Windows) export BOOL AddAccessDeniedAce(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD AccessMask,
  PSID pSid);

// #if(_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL AddAccessDeniedAceEx(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD AceFlags,
  DWORD AccessMask,
  PSID pSid);
// #endif /* _WIN32_WINNT >=  0x0500 */

extern(Windows) export BOOL AddAuditAccessAce(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD dwAccessMask,
  PSID pSid,
  BOOL bAuditSuccess,
  BOOL bAuditFailure);

// #if(_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL AddAuditAccessAceEx(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD AceFlags,
  DWORD dwAccessMask,
  PSID pSid,
  BOOL bAuditSuccess,
  BOOL bAuditFailure);

extern(Windows) export BOOL AddAccessAllowedObjectAce(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD AceFlags,
  DWORD AccessMask,
  GUID *ObjectTypeGuid,
  GUID *InheritedObjectTypeGuid,
  PSID pSid);

extern(Windows) export BOOL AddAccessDeniedObjectAce(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD AceFlags,
  DWORD AccessMask,
  GUID *ObjectTypeGuid,
  GUID *InheritedObjectTypeGuid,
  PSID pSid);

extern(Windows) export BOOL AddAuditAccessObjectAce(
  PACL pAcl,
  DWORD dwAceRevision,
  DWORD AceFlags,
  DWORD AccessMask,
  GUID *ObjectTypeGuid,
  GUID *InheritedObjectTypeGuid,
  PSID pSid,
  BOOL bAuditSuccess,
  BOOL bAuditFailure);
// #endif /* _WIN32_WINNT >=  0x0500 */

extern(Windows) export BOOL FindFirstFreeAce(
  PACL pAcl,
  LPVOID *pAce);

extern(Windows) export BOOL InitializeSecurityDescriptor(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  DWORD dwRevision);

extern(Windows) export BOOL IsValidSecurityDescriptor(
  PSECURITY_DESCRIPTOR pSecurityDescriptor);

extern(Windows) export DWORD GetSecurityDescriptorLength(
  PSECURITY_DESCRIPTOR pSecurityDescriptor);

extern(Windows) export BOOL GetSecurityDescriptorControl(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  PSECURITY_DESCRIPTOR_CONTROL pControl,
  LPDWORD lpdwRevision);

// #if(_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL SetSecurityDescriptorControl(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
  SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet);
// #endif /* _WIN32_WINNT >=  0x0500 */

extern(Windows) export BOOL SetSecurityDescriptorDacl(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  BOOL bDaclPresent,
  PACL pDacl,
  BOOL bDaclDefaulted);

extern(Windows) export BOOL GetSecurityDescriptorDacl(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  LPBOOL lpbDaclPresent,
  PACL *pDacl,
  LPBOOL lpbDaclDefaulted);

extern(Windows) export BOOL SetSecurityDescriptorSacl(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  BOOL bSaclPresent,
  PACL pSacl,
  BOOL bSaclDefaulted);

extern(Windows) export BOOL GetSecurityDescriptorSacl(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  LPBOOL lpbSaclPresent,
  PACL *pSacl,
  LPBOOL lpbSaclDefaulted);

extern(Windows) export BOOL SetSecurityDescriptorOwner(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  PSID pOwner,
  BOOL bOwnerDefaulted);

extern(Windows) export BOOL GetSecurityDescriptorOwner(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  PSID *pOwner,
  LPBOOL lpbOwnerDefaulted);

extern(Windows) export BOOL SetSecurityDescriptorGroup(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  PSID pGroup,
  BOOL bGroupDefaulted);

extern(Windows) export BOOL GetSecurityDescriptorGroup(
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  PSID *pGroup,
  LPBOOL lpbGroupDefaulted);

extern(Windows) export DWORD SetSecurityDescriptorRMControl(
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  PUCHAR RMControl );

extern(Windows) export DWORD GetSecurityDescriptorRMControl(
  PSECURITY_DESCRIPTOR SecurityDescriptor,
  PUCHAR RMControl);

extern(Windows) export BOOL CreatePrivateObjectSecurity(
  PSECURITY_DESCRIPTOR ParentDescriptor,
  PSECURITY_DESCRIPTOR CreatorDescriptor,
  PSECURITY_DESCRIPTOR * NewDescriptor,
  BOOL IsDirectoryObject,
  HANDLE Token,
  PGENERIC_MAPPING GenericMapping);

// #if(_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL ConvertToAutoInheritPrivateObjectSecurity(
  PSECURITY_DESCRIPTOR ParentDescriptor,
  PSECURITY_DESCRIPTOR CurrentSecurityDescriptor,
  PSECURITY_DESCRIPTOR *NewSecurityDescriptor,
  GUID *ObjectType,
  BOOLEAN IsDirectoryObject,
  PGENERIC_MAPPING GenericMapping);

extern(Windows) export BOOL CreatePrivateObjectSecurityEx(
  PSECURITY_DESCRIPTOR ParentDescriptor,
  PSECURITY_DESCRIPTOR CreatorDescriptor,
  PSECURITY_DESCRIPTOR * NewDescriptor,
  GUID *ObjectType ,
  BOOL IsContainerObject,
  ULONG AutoInheritFlags,
  HANDLE Token,
  PGENERIC_MAPPING GenericMapping);

extern(Windows) export BOOL CreatePrivateObjectSecurityWithMultipleInheritance(
  PSECURITY_DESCRIPTOR ParentDescriptor,
  PSECURITY_DESCRIPTOR CreatorDescriptor,
  PSECURITY_DESCRIPTOR * NewDescriptor,
  GUID **ObjectTypes ,
  ULONG GuidCount,
  BOOL IsContainerObject,
  ULONG AutoInheritFlags,
  HANDLE Token,
  PGENERIC_MAPPING GenericMapping);
// #endif /* _WIN32_WINNT >=  0x0500 */

extern(Windows) export BOOL SetPrivateObjectSecurity(
  SECURITY_INFORMATION SecurityInformation,
  PSECURITY_DESCRIPTOR ModificationDescriptor,
  PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  PGENERIC_MAPPING GenericMapping,
  HANDLE Token);

// #if(_WIN32_WINNT >= 0x0500)
extern(Windows) export BOOL SetPrivateObjectSecurityEx(
  SECURITY_INFORMATION SecurityInformation,
  PSECURITY_DESCRIPTOR ModificationDescriptor,
  PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  ULONG AutoInheritFlags,
  PGENERIC_MAPPING GenericMapping,
  HANDLE Token );
// #endif /* _WIN32_WINNT >=  0x0500 */

extern(Windows) export BOOL GetPrivateObjectSecurity(
  PSECURITY_DESCRIPTOR ObjectDescriptor,
  SECURITY_INFORMATION SecurityInformation,
  PSECURITY_DESCRIPTOR ResultantDescriptor,
  DWORD DescriptorLength,
  PDWORD ReturnLength);

extern(Windows) export BOOL DestroyPrivateObjectSecurity(
  PSECURITY_DESCRIPTOR * ObjectDescriptor);

extern(Windows) export BOOL MakeSelfRelativeSD(
  PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
  PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
  LPDWORD lpdwBufferLength);

extern(Windows) export BOOL MakeAbsoluteSD(
  PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
  PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
  LPDWORD lpdwAbsoluteSecurityDescriptorSize,
  PACL pDacl,
  LPDWORD lpdwDaclSize,
  PACL pSacl,
  LPDWORD lpdwSaclSize,
  PSID pOwner,
  LPDWORD lpdwOwnerSize,
  PSID pPrimaryGroup,
  LPDWORD lpdwPrimaryGroupSize);

extern(Windows) export BOOL MakeAbsoluteSD2(
  PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
  LPDWORD lpdwBufferSize);

extern(Windows) export BOOL SetFileSecurityA(
  LPCSTR lpFileName,
  SECURITY_INFORMATION SecurityInformation,
  PSECURITY_DESCRIPTOR pSecurityDescriptor);
extern(Windows) export BOOL SetFileSecurityW(
  LPCWSTR lpFileName,
  SECURITY_INFORMATION SecurityInformation,
  PSECURITY_DESCRIPTOR pSecurityDescriptor);
// #ifdef UNICODE
alias SetFileSecurityW SetFileSecurity;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetFileSecurityA(
  LPCSTR lpFileName,
  SECURITY_INFORMATION RequestedInformation,
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  DWORD nLength,
  LPDWORD lpnLengthNeeded);
extern(Windows) export BOOL GetFileSecurityW(
  LPCWSTR lpFileName,
  SECURITY_INFORMATION RequestedInformation,
  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  DWORD nLength,
  LPDWORD lpnLengthNeeded);
// #ifdef UNICODE
alias GetFileSecurityW GetFileSecurity;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetKernelObjectSecurity(
  HANDLE Handle,
  SECURITY_INFORMATION SecurityInformation,
  PSECURITY_DESCRIPTOR SecurityDescriptor);

extern(Windows) export HANDLE FindFirstChangeNotificationA(
  LPCSTR lpPathName,
  BOOL bWatchSubtree,
  DWORD dwNotifyFilter);
extern(Windows) export HANDLE FindFirstChangeNotificationW(
  LPCWSTR lpPathName,
  BOOL bWatchSubtree,
  DWORD dwNotifyFilter);
// #ifdef UNICODE
alias FindFirstChangeNotificationW FindFirstChangeNotification;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL FindNextChangeNotification(
  HANDLE hChangeHandle);

extern(Windows) export BOOL FindCloseChangeNotification(
  HANDLE hChangeHandle);

// #if(_WIN32_WINNT >= 0x0400)
extern(Windows) export BOOL ReadDirectoryChangesW(
  HANDLE hDirectory,
  LPVOID lpBuffer,
  DWORD nBufferLength,
  BOOL bWatchSubtree,
  DWORD dwNotifyFilter,
  LPDWORD lpBytesReturned,
  LPOVERLAPPED lpOverlapped,
  LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
// #endif /* _WIN32_WINNT >= 0x0400 */

extern(Windows) export BOOL VirtualLock(
  LPVOID lpAddress,
  SIZE_T dwSize);

extern(Windows) export BOOL VirtualUnlock(
  LPVOID lpAddress,
  SIZE_T dwSize);

extern(Windows) export LPVOID MapViewOfFileEx(
  HANDLE hFileMappingObject,
  DWORD dwDesiredAccess,
  DWORD dwFileOffsetHigh,
  DWORD dwFileOffsetLow,
  SIZE_T dwNumberOfBytesToMap,
  LPVOID lpBaseAddress);

extern(Windows) export BOOL SetPriorityClass(
  HANDLE hProcess,
  DWORD dwPriorityClass);

extern(Windows) export DWORD GetPriorityClass(
  HANDLE hProcess);

extern(Windows) export BOOL IsBadReadPtr(
  VOID *lp,
  UINT_PTR ucb);

extern(Windows) export BOOL IsBadWritePtr(
  LPVOID lp,
  UINT_PTR ucb);

extern(Windows) export BOOL IsBadHugeReadPtr(
  VOID *lp,
  UINT_PTR ucb);

extern(Windows) export BOOL IsBadHugeWritePtr(
  LPVOID lp,
  UINT_PTR ucb);

extern(Windows) export BOOL IsBadCodePtr(
  FARPROC lpfn);

extern(Windows) export BOOL IsBadStringPtrA(
  LPCSTR lpsz,
  UINT_PTR ucchMax);
extern(Windows) export BOOL IsBadStringPtrW(
  LPCWSTR lpsz,
  UINT_PTR ucchMax);
// #ifdef UNICODE
alias IsBadStringPtrW IsBadStringPtr;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL LookupAccountSidA(
  LPCSTR lpSystemName,
  PSID Sid,
  LPSTR Name,
  LPDWORD cbName,
  LPSTR ReferencedDomainName,
  LPDWORD cbReferencedDomainName,
  PSID_NAME_USE peUse);
extern(Windows) export BOOL LookupAccountSidW(
  LPCWSTR lpSystemName,
  PSID Sid,
  LPWSTR Name,
  LPDWORD cbName,
  LPWSTR ReferencedDomainName,
  LPDWORD cbReferencedDomainName,
  PSID_NAME_USE peUse);
// #ifdef UNICODE
alias LookupAccountSidW LookupAccountSid;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL LookupAccountNameA(
  LPCSTR lpSystemName,
  LPCSTR lpAccountName,
  PSID Sid,
  LPDWORD cbSid,
  LPSTR ReferencedDomainName,
  LPDWORD cbReferencedDomainName,
  PSID_NAME_USE peUse);
extern(Windows) export BOOL LookupAccountNameW(
  LPCWSTR lpSystemName,
  LPCWSTR lpAccountName,
  PSID Sid,
  LPDWORD cbSid,
  LPWSTR ReferencedDomainName,
  LPDWORD cbReferencedDomainName,
  PSID_NAME_USE peUse);
// #ifdef UNICODE
alias LookupAccountNameW LookupAccountName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL LookupPrivilegeValueA(
  LPCSTR lpSystemName,
  LPCSTR lpName,
  PLUID lpLuid);
extern(Windows) export BOOL LookupPrivilegeValueW(
  LPCWSTR lpSystemName,
  LPCWSTR lpName,
  PLUID lpLuid);
// #ifdef UNICODE
alias LookupPrivilegeValueW LookupPrivilegeValue;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL LookupPrivilegeNameA(
  LPCSTR lpSystemName,
  PLUID lpLuid,
  LPSTR lpName,
  LPDWORD cbName);
extern(Windows) export BOOL LookupPrivilegeNameW(
  LPCWSTR lpSystemName,
  PLUID lpLuid,
  LPWSTR lpName,
  LPDWORD cbName);
// #ifdef UNICODE
alias LookupPrivilegeNameW LookupPrivilegeName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL LookupPrivilegeDisplayNameA(
  LPCSTR lpSystemName,
  LPCSTR lpName,
  LPSTR lpDisplayName,
  LPDWORD cbDisplayName,
  LPDWORD lpLanguageId);
extern(Windows) export BOOL LookupPrivilegeDisplayNameW(
  LPCWSTR lpSystemName,
  LPCWSTR lpName,
  LPWSTR lpDisplayName,
  LPDWORD cbDisplayName,
  LPDWORD lpLanguageId);
// #ifdef UNICODE
alias LookupPrivilegeDisplayNameW LookupPrivilegeDisplayName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL AllocateLocallyUniqueId(
  PLUID Luid);

extern(Windows) export BOOL BuildCommDCBA(
  LPCSTR lpDef,
  LPDCB lpDCB);
extern(Windows) export BOOL BuildCommDCBW(
  LPCWSTR lpDef,
  LPDCB lpDCB);
// #ifdef UNICODE
alias BuildCommDCBW BuildCommDCB;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL BuildCommDCBAndTimeoutsA(
  LPCSTR lpDef,
  LPDCB lpDCB,
  LPCOMMTIMEOUTS lpCommTimeouts);
extern(Windows) export BOOL BuildCommDCBAndTimeoutsW(
  LPCWSTR lpDef,
  LPDCB lpDCB,
  LPCOMMTIMEOUTS lpCommTimeouts);
// #ifdef UNICODE
alias BuildCommDCBAndTimeoutsW BuildCommDCBAndTimeouts;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL CommConfigDialogA(
  LPCSTR lpszName,
  HWND hWnd,
  LPCOMMCONFIG lpCC);
extern(Windows) export BOOL CommConfigDialogW(
  LPCWSTR lpszName,
  HWND hWnd,
  LPCOMMCONFIG lpCC);
// #ifdef UNICODE
alias CommConfigDialogW CommConfigDialog;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetDefaultCommConfigA(
  LPCSTR lpszName,
  LPCOMMCONFIG lpCC,
  LPDWORD lpdwSize);
extern(Windows) export BOOL GetDefaultCommConfigW(
  LPCWSTR lpszName,
  LPCOMMCONFIG lpCC,
  LPDWORD lpdwSize);
// #ifdef UNICODE
alias GetDefaultCommConfigW GetDefaultCommConfig;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetDefaultCommConfigA(
  LPCSTR lpszName,
  LPCOMMCONFIG lpCC,
  DWORD dwSize);
extern(Windows) export BOOL SetDefaultCommConfigW(
  LPCWSTR lpszName,
  LPCOMMCONFIG lpCC,
  DWORD dwSize);
// #ifdef UNICODE
alias SetDefaultCommConfigW SetDefaultCommConfig;
// #else
// #...
// #endif // !UNICODE

// #ifndef _MAC
enum : uint { MAX_COMPUTERNAME_LENGTH = 15 }
// #else
// #...
// #endif

extern(Windows) export BOOL GetComputerNameA(
  LPSTR lpBuffer,
  LPDWORD nSize);
extern(Windows) export BOOL GetComputerNameW(
  LPWSTR lpBuffer,
  LPDWORD nSize);
// #ifdef UNICODE
alias GetComputerNameW GetComputerName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetComputerNameA(
  LPCSTR lpComputerName);
extern(Windows) export BOOL SetComputerNameW(
  LPCWSTR lpComputerName);
// #ifdef UNICODE
alias SetComputerNameW SetComputerName;
// #else
// #...
// #endif // !UNICODE

// #if (_WIN32_WINNT >= 0x0500)

alias int _COMPUTER_NAME_FORMAT;
enum {
  ComputerNameNetBIOS,
  ComputerNameDnsHostname,
  ComputerNameDnsDomain,
  ComputerNameDnsFullyQualified,
  ComputerNamePhysicalNetBIOS,
  ComputerNamePhysicalDnsHostname,
  ComputerNamePhysicalDnsDomain,
  ComputerNamePhysicalDnsFullyQualified,
  ComputerNameMax,
}
alias _COMPUTER_NAME_FORMAT COMPUTER_NAME_FORMAT;

extern(Windows) export BOOL GetComputerNameExA(
  COMPUTER_NAME_FORMAT NameType,
  LPSTR lpBuffer,
  LPDWORD nSize);
extern(Windows) export BOOL GetComputerNameExW(
  COMPUTER_NAME_FORMAT NameType,
  LPWSTR lpBuffer,
  LPDWORD nSize);
// #ifdef UNICODE
alias GetComputerNameExW GetComputerNameEx;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL SetComputerNameExA(
  COMPUTER_NAME_FORMAT NameType,
  LPCSTR lpBuffer);
extern(Windows) export BOOL SetComputerNameExW(
  COMPUTER_NAME_FORMAT NameType,
  LPCWSTR lpBuffer);
// #ifdef UNICODE
alias SetComputerNameExW SetComputerNameEx;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD AddLocalAlternateComputerNameA(
  LPCSTR lpDnsFQHostname,
  ULONG ulFlags);
extern(Windows) export DWORD AddLocalAlternateComputerNameW(
  LPCWSTR lpDnsFQHostname,
  ULONG ulFlags);
// #ifdef UNICODE
alias AddLocalAlternateComputerNameW AddLocalAlternateComputerName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD RemoveLocalAlternateComputerNameA(
  LPCSTR lpAltDnsFQHostname,
  ULONG ulFlags);
extern(Windows) export DWORD RemoveLocalAlternateComputerNameW(
  LPCWSTR lpAltDnsFQHostname,
  ULONG ulFlags);
// #ifdef UNICODE
alias RemoveLocalAlternateComputerNameW RemoveLocalAlternateComputerName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export DWORD SetLocalPrimaryComputerNameA(
  LPCSTR lpAltDnsFQHostname,
  ULONG ulFlags);
extern(Windows) export DWORD SetLocalPrimaryComputerNameW(
  LPCWSTR lpAltDnsFQHostname,
  ULONG ulFlags);
// #ifdef UNICODE
alias SetLocalPrimaryComputerNameW SetLocalPrimaryComputerName;
// #else
// #...
// #endif // !UNICODE

alias int _COMPUTER_NAME_TYPE;
enum {
  PrimaryComputerName,
  AlternateComputerNames,
  AllComputerNames,
  ComputerNameTypeMax,
}
alias _COMPUTER_NAME_TYPE COMPUTER_NAME_TYPE;

extern(Windows) export DWORD EnumerateLocalComputerNamesA(
  COMPUTER_NAME_TYPE NameType,
  ULONG ulFlags,
  LPSTR lpDnsFQHostname,
  LPDWORD nSize);
extern(Windows) export DWORD EnumerateLocalComputerNamesW(
  COMPUTER_NAME_TYPE NameType,
  ULONG ulFlags,
  LPWSTR lpDnsFQHostname,
  LPDWORD nSize);
// #ifdef UNICODE
alias EnumerateLocalComputerNamesW EnumerateLocalComputerNames;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL DnsHostnameToComputerNameA(
  LPCSTR Hostname,
  LPSTR ComputerName,
  LPDWORD nSize);
extern(Windows) export BOOL DnsHostnameToComputerNameW(
  LPCWSTR Hostname,
  LPWSTR ComputerName,
  LPDWORD nSize);
// #ifdef UNICODE
alias DnsHostnameToComputerNameW DnsHostnameToComputerName;
// #else
// #...
// #endif // !UNICODE

// #endif // _WIN32_WINNT

extern(Windows) export BOOL GetUserNameA(
  LPSTR lpBuffer,
  LPDWORD nSize);
extern(Windows) export BOOL GetUserNameW(
  LPWSTR lpBuffer,
  LPDWORD nSize);
// #ifdef UNICODE
alias GetUserNameW GetUserName;
// #else
// #...
// #endif // !UNICODE

enum : uint { LOGON32_LOGON_INTERACTIVE = 2 }
enum : uint { LOGON32_LOGON_NETWORK = 3 }
enum : uint { LOGON32_LOGON_BATCH = 4 }
enum : uint { LOGON32_LOGON_SERVICE = 5 }
enum : uint { LOGON32_LOGON_UNLOCK = 7 }
// #if(_WIN32_WINNT >= 0x0500)
enum : uint { LOGON32_LOGON_NETWORK_CLEARTEXT = 8 }
enum : uint { LOGON32_LOGON_NEW_CREDENTIALS = 9 }
// #endif // (_WIN32_WINNT >= 0x0500)

enum : uint { LOGON32_PROVIDER_DEFAULT = 0 }
enum : uint { LOGON32_PROVIDER_WINNT35 = 1 }
// #if(_WIN32_WINNT >= 0x0400)
enum : uint { LOGON32_PROVIDER_WINNT40 = 2 }
// #endif /* _WIN32_WINNT >= 0x0400 */
// #if(_WIN32_WINNT >= 0x0500)
enum : uint { LOGON32_PROVIDER_WINNT50 = 3 }
// #endif // (_WIN32_WINNT >= 0x0500)

extern(Windows) export BOOL LogonUserA(
  LPSTR lpszUsername,
  LPSTR lpszDomain,
  LPSTR lpszPassword,
  DWORD dwLogonType,
  DWORD dwLogonProvider,
  PHANDLE phToken);
extern(Windows) export BOOL LogonUserW(
  LPWSTR lpszUsername,
  LPWSTR lpszDomain,
  LPWSTR lpszPassword,
  DWORD dwLogonType,
  DWORD dwLogonProvider,
  PHANDLE phToken);
// #ifdef UNICODE
alias LogonUserW LogonUser;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL LogonUserExA(
  LPSTR lpszUsername,
  LPSTR lpszDomain,
  LPSTR lpszPassword,
  DWORD dwLogonType,
  DWORD dwLogonProvider,
  PHANDLE phToken ,
  PSID *ppLogonSid ,
  PVOID *ppProfileBuffer ,
  LPDWORD pdwProfileLength ,
  PQUOTA_LIMITS pQuotaLimits );
extern(Windows) export BOOL LogonUserExW(
  LPWSTR lpszUsername,
  LPWSTR lpszDomain,
  LPWSTR lpszPassword,
  DWORD dwLogonType,
  DWORD dwLogonProvider,
  PHANDLE phToken ,
  PSID *ppLogonSid ,
  PVOID *ppProfileBuffer ,
  LPDWORD pdwProfileLength ,
  PQUOTA_LIMITS pQuotaLimits );
// #ifdef UNICODE
alias LogonUserExW LogonUserEx;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL ImpersonateLoggedOnUser(
  HANDLE hToken);

extern(Windows) export BOOL CreateProcessAsUserA(
  HANDLE hToken,
  LPCSTR lpApplicationName,
  LPSTR lpCommandLine,
  LPSECURITY_ATTRIBUTES lpProcessAttributes,
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  BOOL bInheritHandles,
  DWORD dwCreationFlags,
  LPVOID lpEnvironment,
  LPCSTR lpCurrentDirectory,
  LPSTARTUPINFOA lpStartupInfo,
  LPPROCESS_INFORMATION lpProcessInformation);
extern(Windows) export BOOL CreateProcessAsUserW(
  HANDLE hToken,
  LPCWSTR lpApplicationName,
  LPWSTR lpCommandLine,
  LPSECURITY_ATTRIBUTES lpProcessAttributes,
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  BOOL bInheritHandles,
  DWORD dwCreationFlags,
  LPVOID lpEnvironment,
  LPCWSTR lpCurrentDirectory,
  LPSTARTUPINFOW lpStartupInfo,
  LPPROCESS_INFORMATION lpProcessInformation);
// #ifdef UNICODE
alias CreateProcessAsUserW CreateProcessAsUser;
// #else
// #...
// #endif // !UNICODE

// #if(_WIN32_WINNT >= 0x0500)

enum : uint { LOGON_WITH_PROFILE = 0x00000001 }
enum : uint { LOGON_NETCREDENTIALS_ONLY = 0x00000002 }

extern(Windows) export BOOL CreateProcessWithLogonW(
  LPCWSTR lpUsername,
  LPCWSTR lpDomain,
  LPCWSTR lpPassword,
  DWORD dwLogonFlags,
  LPCWSTR lpApplicationName,
  LPWSTR lpCommandLine,
  DWORD dwCreationFlags,
  LPVOID lpEnvironment,
  LPCWSTR lpCurrentDirectory,
  LPSTARTUPINFOW lpStartupInfo,
  LPPROCESS_INFORMATION lpProcessInformation);

// #endif // (_WIN32_WINNT >= 0x0500)

extern(Windows) export BOOL ImpersonateAnonymousToken(
  HANDLE ThreadHandle);

extern(Windows) export BOOL DuplicateTokenEx(
  HANDLE hExistingToken,
  DWORD dwDesiredAccess,
  LPSECURITY_ATTRIBUTES lpTokenAttributes,
  SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  TOKEN_TYPE TokenType,
  PHANDLE phNewToken);

extern(Windows) export BOOL CreateRestrictedToken(
  HANDLE ExistingTokenHandle,
  DWORD Flags,
  DWORD DisableSidCount,
  PSID_AND_ATTRIBUTES SidsToDisable ,
  DWORD DeletePrivilegeCount,
  PLUID_AND_ATTRIBUTES PrivilegesToDelete ,
  DWORD RestrictedSidCount,
  PSID_AND_ATTRIBUTES SidsToRestrict ,
  PHANDLE NewTokenHandle);

extern(Windows) export BOOL IsTokenRestricted(
  HANDLE TokenHandle);

extern(Windows) export BOOL IsTokenUntrusted(
  HANDLE TokenHandle);

extern(Windows) export BOOL CheckTokenMembership(
  HANDLE TokenHandle ,
  PSID SidToCheck,
  PBOOL IsMember);

// #if (_WIN32_WINNT >= 0x0500)

alias WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK;

extern(Windows) export BOOL RegisterWaitForSingleObject(
  PHANDLE phNewWaitObject,
  HANDLE hObject,
  WAITORTIMERCALLBACK Callback,
  PVOID Context,
  ULONG dwMilliseconds,
  ULONG dwFlags);

extern(Windows) export HANDLE RegisterWaitForSingleObjectEx(
  HANDLE hObject,
  WAITORTIMERCALLBACK Callback,
  PVOID Context,
  ULONG dwMilliseconds,
  ULONG dwFlags);

extern(Windows) export BOOL UnregisterWait(
  HANDLE WaitHandle);

extern(Windows) export BOOL UnregisterWaitEx(
  HANDLE WaitHandle,
  HANDLE CompletionEvent);

extern(Windows) export BOOL QueueUserWorkItem(
  LPTHREAD_START_ROUTINE Function,
  PVOID Context,
  ULONG Flags);

extern(Windows) export BOOL BindIoCompletionCallback(
  HANDLE FileHandle,
  LPOVERLAPPED_COMPLETION_ROUTINE Function,
  ULONG Flags);

extern(Windows) export HANDLE CreateTimerQueue();

extern(Windows) export BOOL CreateTimerQueueTimer(
  PHANDLE phNewTimer,
  HANDLE TimerQueue,
  WAITORTIMERCALLBACK Callback,
  PVOID Parameter,
  DWORD DueTime,
  DWORD Period,
  ULONG Flags);

extern(Windows) export BOOL ChangeTimerQueueTimer(
  HANDLE TimerQueue,
  HANDLE Timer,
  ULONG DueTime,
  ULONG Period);

extern(Windows) export BOOL DeleteTimerQueueTimer(
  HANDLE TimerQueue,
  HANDLE Timer,
  HANDLE CompletionEvent);

extern(Windows) export BOOL DeleteTimerQueueEx(
  HANDLE TimerQueue,
  HANDLE CompletionEvent);

extern(Windows) export HANDLE SetTimerQueueTimer(
  HANDLE TimerQueue,
  WAITORTIMERCALLBACK Callback,
  PVOID Parameter,
  DWORD DueTime,
  DWORD Period,
  BOOL PreferIo);

extern(Windows) export BOOL CancelTimerQueueTimer(
  HANDLE TimerQueue,
  HANDLE Timer);

extern(Windows) export BOOL DeleteTimerQueue(
  HANDLE TimerQueue);

// #endif // _WIN32_WINNT

// #if(_WIN32_WINNT >= 0x0400)

enum : uint { HW_PROFILE_GUIDLEN = 39 }
enum : uint { MAX_PROFILE_LEN = 80 }

enum : uint { DOCKINFO_UNDOCKED = 0x1 }
enum : uint { DOCKINFO_DOCKED = 0x2 }
enum : uint { DOCKINFO_USER_SUPPLIED = 0x4 }
enum : uint { DOCKINFO_USER_UNDOCKED = DOCKINFO_USER_SUPPLIED | DOCKINFO_UNDOCKED }
enum : uint { DOCKINFO_USER_DOCKED = DOCKINFO_USER_SUPPLIED | DOCKINFO_DOCKED }

struct tagHW_PROFILE_INFOA {
  DWORD dwDockInfo;
  CHAR szHwProfileGuid[HW_PROFILE_GUIDLEN];
  CHAR szHwProfileName[MAX_PROFILE_LEN];
}
alias tagHW_PROFILE_INFOA HW_PROFILE_INFOA;
alias tagHW_PROFILE_INFOA* LPHW_PROFILE_INFOA;

struct tagHW_PROFILE_INFOW {
  DWORD dwDockInfo;
  WCHAR szHwProfileGuid[HW_PROFILE_GUIDLEN];
  WCHAR szHwProfileName[MAX_PROFILE_LEN];
}
alias tagHW_PROFILE_INFOW HW_PROFILE_INFOW;
alias tagHW_PROFILE_INFOW* LPHW_PROFILE_INFOW;

// #ifdef UNICODE
alias HW_PROFILE_INFOW HW_PROFILE_INFO;
alias LPHW_PROFILE_INFOW LPHW_PROFILE_INFO;
// #else
// ...
// #endif // UNICODE

extern(Windows) export BOOL GetCurrentHwProfileA(
  LPHW_PROFILE_INFOA lpHwProfileInfo);
extern(Windows) export BOOL GetCurrentHwProfileW(
  LPHW_PROFILE_INFOW lpHwProfileInfo);
// #ifdef UNICODE
alias GetCurrentHwProfileW GetCurrentHwProfile;
// #else
// #...
// #endif // !UNICODE
// #endif /* _WIN32_WINNT >= 0x0400 */

extern(Windows) export BOOL QueryPerformanceCounter(
  LARGE_INTEGER *lpPerformanceCount);

extern(Windows) export BOOL QueryPerformanceFrequency(
  LARGE_INTEGER *lpFrequency);

extern(Windows) export BOOL GetVersionExA(
  LPOSVERSIONINFOA lpVersionInformation);
extern(Windows) export BOOL GetVersionExW(
  LPOSVERSIONINFOW lpVersionInformation);
// #ifdef UNICODE
alias GetVersionExW GetVersionEx;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL VerifyVersionInfoA(
  LPOSVERSIONINFOEXA lpVersionInformation,
  DWORD dwTypeMask,
  DWORDLONG dwlConditionMask);
extern(Windows) export BOOL VerifyVersionInfoW(
  LPOSVERSIONINFOEXW lpVersionInformation,
  DWORD dwTypeMask,
  DWORDLONG dwlConditionMask);
// #ifdef UNICODE
alias VerifyVersionInfoW VerifyVersionInfo;
// #else
// #...
// #endif // !UNICODE

import win32.winerror;

enum : uint { TC_NORMAL = 0 }
enum : uint { TC_HARDERR = 1 }
enum : uint { TC_GP_TRAP = 2 }
enum : uint { TC_SIGNAL = 3 }

// #if(WINVER >= 0x0400)

enum : uint { AC_LINE_OFFLINE = 0x00 }
enum : uint { AC_LINE_ONLINE = 0x01 }
enum : uint { AC_LINE_BACKUP_POWER = 0x02 }
enum : uint { AC_LINE_UNKNOWN = 0xFF }

enum : uint { BATTERY_FLAG_HIGH = 0x01 }
enum : uint { BATTERY_FLAG_LOW = 0x02 }
enum : uint { BATTERY_FLAG_CRITICAL = 0x04 }
enum : uint { BATTERY_FLAG_CHARGING = 0x08 }
enum : uint { BATTERY_FLAG_NO_BATTERY = 0x80 }
enum : uint { BATTERY_FLAG_UNKNOWN = 0xFF }

enum : uint { BATTERY_PERCENTAGE_UNKNOWN = 0xFF }

enum : uint { BATTERY_LIFE_UNKNOWN = 0xFFFFFFFF }

struct _SYSTEM_POWER_STATUS {
  BYTE ACLineStatus;
  BYTE BatteryFlag;
  BYTE BatteryLifePercent;
  BYTE Reserved1;
  DWORD BatteryLifeTime;
  DWORD BatteryFullLifeTime;
}
alias _SYSTEM_POWER_STATUS SYSTEM_POWER_STATUS;
alias _SYSTEM_POWER_STATUS* LPSYSTEM_POWER_STATUS;

extern(Windows) export BOOL GetSystemPowerStatus(
  LPSYSTEM_POWER_STATUS lpSystemPowerStatus);

extern(Windows) export BOOL SetSystemPowerState(
  BOOL fSuspend,
  BOOL fForce);

// #endif /* WINVER >= 0x0400 */

// #if (_WIN32_WINNT >= 0x0500)

extern(Windows) export BOOL AllocateUserPhysicalPages(
  HANDLE hProcess,
  PULONG_PTR NumberOfPages,
  PULONG_PTR PageArray);

extern(Windows) export BOOL FreeUserPhysicalPages(
  HANDLE hProcess,
  PULONG_PTR NumberOfPages,
  PULONG_PTR PageArray);

extern(Windows) export BOOL MapUserPhysicalPages(
  PVOID VirtualAddress,
  ULONG_PTR NumberOfPages,
  PULONG_PTR PageArray );

extern(Windows) export BOOL MapUserPhysicalPagesScatter(
  PVOID *VirtualAddresses,
  ULONG_PTR NumberOfPages,
  PULONG_PTR PageArray );

extern(Windows) export HANDLE CreateJobObjectA(
  LPSECURITY_ATTRIBUTES lpJobAttributes,
  LPCSTR lpName);
extern(Windows) export HANDLE CreateJobObjectW(
  LPSECURITY_ATTRIBUTES lpJobAttributes,
  LPCWSTR lpName);
// #ifdef UNICODE
alias CreateJobObjectW CreateJobObject;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export HANDLE OpenJobObjectA(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCSTR lpName);
extern(Windows) export HANDLE OpenJobObjectW(
  DWORD dwDesiredAccess,
  BOOL bInheritHandle,
  LPCWSTR lpName);
// #ifdef UNICODE
alias OpenJobObjectW OpenJobObject;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL AssignProcessToJobObject(
  HANDLE hJob,
  HANDLE hProcess);

extern(Windows) export BOOL TerminateJobObject(
  HANDLE hJob,
  UINT uExitCode);

extern(Windows) export BOOL QueryInformationJobObject(
  HANDLE hJob,
  JOBOBJECTINFOCLASS JobObjectInformationClass,
  LPVOID lpJobObjectInformation,
  DWORD cbJobObjectInformationLength,
  LPDWORD lpReturnLength);

extern(Windows) export BOOL SetInformationJobObject(
  HANDLE hJob,
  JOBOBJECTINFOCLASS JobObjectInformationClass,
  LPVOID lpJobObjectInformation,
  DWORD cbJobObjectInformationLength);

extern(Windows) export BOOL IsProcessInJob(
  HANDLE ProcessHandle,
  HANDLE JobHandle,
  PBOOL Result);

extern(Windows) export BOOL CreateJobSet(
  ULONG NumJob,
  PJOB_SET_ARRAY UserJobSet,
  ULONG Flags);

extern(Windows) export PVOID AddVectoredExceptionHandler(
  ULONG FirstHandler,
  PVECTORED_EXCEPTION_HANDLER VectoredHandler);

extern(Windows) export ULONG RemoveVectoredExceptionHandler(
  PVOID VectoredHandlerHandle);

extern(Windows) export HANDLE FindFirstVolumeA(
  LPSTR lpszVolumeName,
  DWORD cchBufferLength);
extern(Windows) export HANDLE FindFirstVolumeW(
  LPWSTR lpszVolumeName,
  DWORD cchBufferLength);
// #ifdef UNICODE
alias FindFirstVolumeW FindFirstVolume;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL FindNextVolumeA(
  HANDLE hFindVolume,
  LPSTR lpszVolumeName,
  DWORD cchBufferLength);
extern(Windows) export BOOL FindNextVolumeW(
  HANDLE hFindVolume,
  LPWSTR lpszVolumeName,
  DWORD cchBufferLength);
// #ifdef UNICODE
alias FindNextVolumeW FindNextVolume;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL FindVolumeClose(
  HANDLE hFindVolume);

extern(Windows) export HANDLE FindFirstVolumeMountPointA(
  LPCSTR lpszRootPathName,
  LPSTR lpszVolumeMountPoint,
  DWORD cchBufferLength);
extern(Windows) export HANDLE FindFirstVolumeMountPointW(
  LPCWSTR lpszRootPathName,
  LPWSTR lpszVolumeMountPoint,
  DWORD cchBufferLength);
// #ifdef UNICODE
alias FindFirstVolumeMountPointW FindFirstVolumeMountPoint;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL FindNextVolumeMountPointA(
  HANDLE hFindVolumeMountPoint,
  LPSTR lpszVolumeMountPoint,
  DWORD cchBufferLength);
extern(Windows) export BOOL FindNextVolumeMountPointW(
  HANDLE hFindVolumeMountPoint,
  LPWSTR lpszVolumeMountPoint,
  DWORD cchBufferLength);
// #ifdef UNICODE
alias FindNextVolumeMountPointW FindNextVolumeMountPoint;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL FindVolumeMountPointClose(
  HANDLE hFindVolumeMountPoint);

extern(Windows) export BOOL SetVolumeMountPointA(
  LPCSTR lpszVolumeMountPoint,
  LPCSTR lpszVolumeName);
extern(Windows) export BOOL SetVolumeMountPointW(
  LPCWSTR lpszVolumeMountPoint,
  LPCWSTR lpszVolumeName);
// #ifdef UNICODE
alias SetVolumeMountPointW SetVolumeMountPoint;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL DeleteVolumeMountPointA(
  LPCSTR lpszVolumeMountPoint);
extern(Windows) export BOOL DeleteVolumeMountPointW(
  LPCWSTR lpszVolumeMountPoint);
// #ifdef UNICODE
alias DeleteVolumeMountPointW DeleteVolumeMountPoint;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetVolumeNameForVolumeMountPointA(
  LPCSTR lpszVolumeMountPoint,
  LPSTR lpszVolumeName,
  DWORD cchBufferLength);
extern(Windows) export BOOL GetVolumeNameForVolumeMountPointW(
  LPCWSTR lpszVolumeMountPoint,
  LPWSTR lpszVolumeName,
  DWORD cchBufferLength);
// #ifdef UNICODE
alias GetVolumeNameForVolumeMountPointW GetVolumeNameForVolumeMountPoint;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetVolumePathNameA(
  LPCSTR lpszFileName,
  LPSTR lpszVolumePathName,
  DWORD cchBufferLength);
extern(Windows) export BOOL GetVolumePathNameW(
  LPCWSTR lpszFileName,
  LPWSTR lpszVolumePathName,
  DWORD cchBufferLength);
// #ifdef UNICODE
alias GetVolumePathNameW GetVolumePathName;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL GetVolumePathNamesForVolumeNameA(
  LPCSTR lpszVolumeName,
  LPSTR lpszVolumePathNames,
  DWORD cchBufferLength,
  PDWORD lpcchReturnLength);
extern(Windows) export BOOL GetVolumePathNamesForVolumeNameW(
  LPCWSTR lpszVolumeName,
  LPWSTR lpszVolumePathNames,
  DWORD cchBufferLength,
  PDWORD lpcchReturnLength);
// #ifdef UNICODE
alias GetVolumePathNamesForVolumeNameW GetVolumePathNamesForVolumeName;
// #else
// #...
// #endif // !UNICODE

// #endif

// #if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100) || ISOLATION_AWARE_ENABLED

enum : uint { ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID = 0x00000001 }
enum : uint { ACTCTX_FLAG_LANGID_VALID = 0x00000002 }
enum : uint { ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID = 0x00000004 }
enum : uint { ACTCTX_FLAG_RESOURCE_NAME_VALID = 0x00000008 }
enum : uint { ACTCTX_FLAG_SET_PROCESS_DEFAULT = 0x00000010 }
enum : uint { ACTCTX_FLAG_APPLICATION_NAME_VALID = 0x00000020 }
enum : uint { ACTCTX_FLAG_SOURCE_IS_ASSEMBLYREF = 0x00000040 }
enum : uint { ACTCTX_FLAG_HMODULE_VALID = 0x00000080 }

struct tagACTCTXA {
  ULONG cbSize;
  DWORD dwFlags;
  LPCSTR lpSource;
  USHORT wProcessorArchitecture;
  LANGID wLangId;
  LPCSTR lpAssemblyDirectory;
  LPCSTR lpResourceName;
  LPCSTR lpApplicationName;
  HMODULE hModule;
}
alias tagACTCTXA ACTCTXA;
alias tagACTCTXA* PACTCTXA;

struct tagACTCTXW {
  ULONG cbSize;
  DWORD dwFlags;
  LPCWSTR lpSource;
  USHORT wProcessorArchitecture;
  LANGID wLangId;
  LPCWSTR lpAssemblyDirectory;
  LPCWSTR lpResourceName;
  LPCWSTR lpApplicationName;
  HMODULE hModule;
}
alias tagACTCTXW ACTCTXW;
alias tagACTCTXW* PACTCTXW;

// #ifdef UNICODE
// skip typedef ACTCTXW ACTCTX;
alias PACTCTXW PACTCTX;
// #else
// ...
// #endif // UNICODE

alias ACTCTXA* PCACTCTXA;
alias ACTCTXW* PCACTCTXW;
// #ifdef UNICODE
// skip typedef ACTCTXW ACTCTX;
alias PCACTCTXW PCACTCTX;
// #else
// ...
// #endif // UNICODE

// #endif

// #if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100)

extern(Windows) export HANDLE CreateActCtxA(
  PCACTCTXA pActCtx);
extern(Windows) export HANDLE CreateActCtxW(
  PCACTCTXW pActCtx);
// #ifdef UNICODE
alias CreateActCtxW CreateActCtx;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export VOID AddRefActCtx(
  HANDLE hActCtx);

extern(Windows) export VOID ReleaseActCtx(
  HANDLE hActCtx);

extern(Windows) export BOOL ZombifyActCtx(
  HANDLE hActCtx);

extern(Windows) export BOOL ActivateActCtx(
  HANDLE hActCtx,
  ULONG_PTR *lpCookie);

enum : uint { DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION = 0x00000001 }

extern(Windows) export BOOL DeactivateActCtx(
  DWORD dwFlags,
  ULONG_PTR ulCookie);

extern(Windows) export BOOL GetCurrentActCtx(
  HANDLE *lphActCtx);

// #endif

// #if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100) || ISOLATION_AWARE_ENABLED

struct tagACTCTX_SECTION_KEYED_DATA {
  ULONG cbSize;
  ULONG ulDataFormatVersion;
  PVOID lpData;
  ULONG ulLength;
  PVOID lpSectionGlobalData;
  ULONG ulSectionGlobalDataLength;
  PVOID lpSectionBase;
  ULONG ulSectionTotalLength;
  HANDLE hActCtx;
  ULONG ulAssemblyRosterIndex;
}
alias tagACTCTX_SECTION_KEYED_DATA ACTCTX_SECTION_KEYED_DATA;
alias tagACTCTX_SECTION_KEYED_DATA* PACTCTX_SECTION_KEYED_DATA;

enum : uint { FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX = 0x00000001 }

// #endif

// #if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100)

extern(Windows) export BOOL FindActCtxSectionStringA(
  DWORD dwFlags,
  GUID *lpExtensionGuid,
  ULONG ulSectionId,
  LPCSTR lpStringToFind,
  PACTCTX_SECTION_KEYED_DATA ReturnedData);
extern(Windows) export BOOL FindActCtxSectionStringW(
  DWORD dwFlags,
  GUID *lpExtensionGuid,
  ULONG ulSectionId,
  LPCWSTR lpStringToFind,
  PACTCTX_SECTION_KEYED_DATA ReturnedData);
// #ifdef UNICODE
alias FindActCtxSectionStringW FindActCtxSectionString;
// #else
// #...
// #endif // !UNICODE

extern(Windows) export BOOL FindActCtxSectionGuid(
  DWORD dwFlags,
  GUID *lpExtensionGuid,
  ULONG ulSectionId,
  GUID *lpGuidToFind,
  PACTCTX_SECTION_KEYED_DATA ReturnedData);

// #endif

// #if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100) || ISOLATION_AWARE_ENABLED

// #if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
// #if !defined(ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED)

// ...

// ...

// #...

// #endif // !defined(ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED)
// #endif

enum : uint { QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX = 0x00000004 }
enum : uint { QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE = 0x00000008 }
enum : uint { QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS = 0x00000010 }
enum : uint { QUERY_ACTCTX_FLAG_NO_ADDREF = 0x80000000 }

// #endif

// #if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100)

extern(Windows) export BOOL QueryActCtxW(
  DWORD dwFlags,
  HANDLE hActCtx,
  PVOID pvSubInstance,
  ULONG ulInfoClass,
  PVOID pvBuffer,
  SIZE_T cbBuffer ,
  SIZE_T *pcbWrittenOrRequired );

extern(Windows) alias BOOL function(  DWORD dwFlags,  HANDLE hActCtx,  PVOID pvSubInstance,  ULONG ulInfoClass,  PVOID pvBuffer,  SIZE_T cbBuffer ,  SIZE_T *pcbWrittenOrRequired  ) PQUERYACTCTXW_FUNC;

// #endif // (_WIN32_WINNT > 0x0500) || (_WIN32_FUSION >= 0x0100)

extern(Windows) export BOOL ProcessIdToSessionId(
  DWORD dwProcessId,
  DWORD *pSessionId);

// #if _WIN32_WINNT >= 0x0501

extern(Windows) export DWORD WTSGetActiveConsoleSessionId();

extern(Windows) export BOOL IsWow64Process(
  HANDLE hProcess,
  PBOOL Wow64Process);

// #endif // (_WIN32_WINNT >= 0x0501)

extern(Windows) export BOOL GetNumaHighestNodeNumber(
  PULONG HighestNodeNumber);

extern(Windows) export BOOL GetNumaProcessorNode(
  UCHAR Processor,
  PUCHAR NodeNumber);

extern(Windows) export BOOL GetNumaNodeProcessorMask(
  UCHAR Node,
  PULONGLONG ProcessorMask);

extern(Windows) export BOOL GetNumaProcessorMap(
  PSYSTEM_NUMA_INFORMATION Map,
  ULONG Length,
  PULONG ReturnedLength);

extern(Windows) export BOOL GetNumaAvailableMemory(
  PSYSTEM_NUMA_INFORMATION Memory,
  ULONG Length,
  PULONG ReturnedLength);

extern(Windows) export BOOL GetNumaAvailableMemoryNode(
  UCHAR Node,
  PULONGLONG AvailableBytes);

extern(Windows) export ULONGLONG NumaVirtualQueryNode(
  ULONG NumberOfRanges,
  PULONG_PTR RangeList,
  PULONG_PTR VirtualPageAndNode,
  SIZE_T MaximumOutputLength);

// #if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
// #if ISOLATION_AWARE_ENABLED
// #...
// #endif /* ISOLATION_AWARE_ENABLED */
// #endif /* RC */

// #ifdef __cplusplus
// }
// #endif

// #endif // _WINBASE_

