#define BYTE    byte
#define WORD    word
#define DWORD   dword
#define UCHAR   byte
#define USHORT  word
#define UINT    dword
#define ULONG   dword
#define CHAR    char
#define SHORT   short
#define INT     long
#define LONG    long
#define BOOL    long
#define BOOLEAN long
#define FLOAT   dword
#define DOUBLE  dword
#define ATOM    word
#define LPVOID  dword
#define LPSTR   dword
#define LPCSTR  dword
#define LRESULT long
#define LPARAM  long
#define WPARAM  dword
#define HANDLE  dword
#define WCHAR   word

// Описание типов HANDLE

#define HGLOBAL      HANDLE
#define HLOCAL       HANDLE
#define HGDIOBJ      HANDLE
#define HACCEL       HANDLE
#define HBITMAP      HANDLE
#define HBRUSH       HANDLE
#define HDC          HANDLE
#define HGLRC        HANDLE
#define HDESK        HANDLE
#define HENHMETAFILE HANDLE
#define HFONT        HANDLE
#define HICON        HANDLE
#define HMENU        HANDLE
#define HDROP        HANDLE
#define HMETAFILE    HANDLE
#define HINSTANCE    HANDLE
#define HIMAGELIST   HANDLE
#define HPROPSHEETPAGE HANDLE
#define HTREEITEM    HANDLE
#define HMODULE      HANDLE
#define HPALETTE     HANDLE
#define HPEN         HANDLE
#define HRGN         HANDLE
#define HRSRC        HANDLE
#define HSTR         HANDLE
#define HTASK        HANDLE
#define HKL          HANDLE
#define HFILE        HANDLE
#define HWND         HANDLE
#define HKEY         HANDLE
#define HCURSOR      HANDLE

// Описание прочих типов

#define COLORREF      DWORD
#define COLOR16       SHORT
#define FXPT16DOT16   LONG
#define FXPT2DOT30    LONG
#define LCSCSTYPE     LONG
#define LCSGAMUTMATCH LONG
#define ACCESS_MASK   DWORD

#define LPOFNHOOKPROC   dword
#define LPPRINTHOOKPROC dword
#define LPSETUPHOOKPROC dword
#define LPDWORD         dword
#define VOID            void

#define NULL         0

#define MAX_PATH 260

#define DELETE          0x10000
#define READ_CONTROL    0x20000
#define WRITE_DAC       0x40000
#define WRITE_OWNER     0x80000
#define SYNCHRONIZE     0x100000
#define NOTSYNCHRONIZE  !0x100000

#define STANDARD_RIGHTS_READ            READ_CONTROL
#define STANDARD_RIGHTS_WRITE           READ_CONTROL
#define STANDARD_RIGHTS_EXECUTE         READ_CONTROL
#define STANDARD_RIGHTS_REQUIRED        0xF0000
#define STANDARD_RIGHTS_ALL             0x1F0000

#define SPECIFIC_RIGHTS_ALL             0xFFFF

#define STD_INPUT_HANDLE -10
#define STD_OUTPUT_HANDLE -11
#define STD_ERROR_HANDLE -12

#define CONSOLE_TEXTMODE_BUFFER 1

#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
#define GENERIC_EXECUTE 0x20000000
#define GENERIC_ALL 0x10000000

#define FILE_BEGIN      0
#define FILE_CURRENT    1
#define FILE_END        2

#define FILE_FLAG_WRITE_THROUGH         0x80000000
#define FILE_FLAG_OVERLAPPED            0x40000000
#define FILE_FLAG_NO_BUFFERING          0x20000000
#define FILE_FLAG_RANDOM_ACCESS         0x10000000
#define FILE_FLAG_SEQUENTIAL_SCAN       0x8000000
#define FILE_FLAG_DELETE_ON_CLOSE       0x4000000
#define FILE_FLAG_BACKUP_SEMANTICS      0x2000000
#define FILE_FLAG_POSIX_SEMANTICS       0x1000000

#define CREATE_NEW              1
#define CREATE_ALWAYS           2
#define OPEN_EXISTING           3
#define OPEN_ALWAYS             4
#define TRUNCATE_EXISTING       5

#define OF_READ 0x0
#define OF_WRITE 0x1
#define OF_READWRITE 0x2
#define OF_SHARE_COMPAT 0x0
#define OF_SHARE_EXCLUSIVE 0x10
#define OF_SHARE_DENY_WRITE 0x20
#define OF_SHARE_DENY_READ 0x30
#define OF_SHARE_DENY_NONE 0x40
#define OF_PARSE 0x100
#define OF_DELETE 0x200
#define OF_VERIFY 0x400
#define OF_CANCEL 0x800
#define OF_CREATE 0x1000
#define OF_PROMPT 0x2000
#define OF_EXIST 0x4000
#define OF_REOPEN 0x8000

#define OFS_MAXPATHNAME 128

////////////////////////////////////////////////////////////////////////
//                                                                    //
//               Registry API Constants                                //
//                                                                    //
////////////////////////////////////////////////////////////////////////

//Reg Create Type Values...
#define REG_OPTION_RESERVED 0           //Parameter is reserved
#define REG_OPTION_NON_VOLATILE 0       //Key is preserved when system is rebooted
#define REG_OPTION_VOLATILE 1           //Key is not preserved when system is rebooted
#define REG_OPTION_CREATE_LINK 2        //Created key is a symbolic link
#define REG_OPTION_BACKUP_RESTORE 4     //open for backup or restore

//Reg Data Types...
#define REG_NONE 0                       //No value type
#define REG_SZ 1                         //Unicode nul terminated string
#define REG_EXPAND_SZ 2                  //Unicode nul terminated string
#define REG_BINARY 3                     //Free form binary
#define REG_DWORD 4                      //32-bit number
#define REG_DWORD_LITTLE_ENDIAN 4        //32-bit number (same as REG_DWORD)
#define REG_DWORD_BIG_ENDIAN 5           //32-bit number
#define REG_LINK 6                       //Symbolic Link (unicode)
#define REG_MULTI_SZ 7                   //Multiple Unicode strings
#define REG_RESOURCE_LIST 8              //Resource list in the resource map
#define REG_FULL_RESOURCE_DESCRIPTOR 9   //Resource list in the hardware description
#define REG_RESOURCE_REQUIREMENTS_LIST 10
#define REG_CREATED_NEW_KEY 0x1                      //New Registry Key created
#define REG_OPENED_EXISTING_KEY 0x2                      //Existing Key opened
#define REG_WHOLE_HIVE_VOLATILE 0x1                      //Restore whole hive volatile
#define REG_REFRESH_HIVE 0x2                      //Unwind changes to last flush
#define REG_NOTIFY_CHANGE_NAME 0x1                      //Create or delete (child)
#define REG_NOTIFY_CHANGE_ATTRIBUTES 0x2
#define REG_NOTIFY_CHANGE_LAST_SET 0x4                      //Time stamp
#define REG_NOTIFY_CHANGE_SECURITY 0x8
#define REG_LEGAL_CHANGE_FILTER REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_CHANGE_SECURITY
#define REG_LEGAL_OPTION REG_OPTION_RESERVED | REG_OPTION_NON_VOLATILE | REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE


//Reg Key Security Options
//Const READ_CONTROL = &H20000
#define KEY_QUERY_VALUE 0x1
#define KEY_SET_VALUE 0x2
#define KEY_CREATE_SUB_KEY 0x4
#define KEY_ENUMERATE_SUB_KEYS 0x8
#define KEY_NOTIFY 0x10
#define KEY_CREATE_LINK 0x20
#define KEY_READ STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY & NOTSYNCHRONIZE
#define KEY_WRITE STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY & NOTSYNCHRONIZE
#define KEY_ALL_ACCESS STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK & NOTSYNCHRONIZE
//Const STANDARD_RIGHTS_READ = (READ_CONTROL)
//Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)
#define KEY_EXECUTE KEY_READ & NOTSYNCHRONIZE

#define HKEY_CLASSES_ROOT       0x80000000
#define HKEY_CURRENT_USER       0x80000001
#define HKEY_LOCAL_MACHINE      0x80000002
#define HKEY_USERS              0x80000003
#define HKEY_PERFORMANCE_DATA   0x80000004
#define HKEY_CURRENT_CONFIG     0x80000005
#define HKEY_DYN_DATA           0x80000006

//-----------------------------------------
//Win32 API error code definitions
//-----------------------------------------
//This section contains the error code definitions for the Win32 API functions.

#define INVALID_HANDLE_VALUE -1
//NO_ERROR
#define NO_ERROR 0 // dderror
//The configuration registry database operation completed successfully.
#define ERROR_SUCCESS 0
//  Incorrect function.
#define ERROR_INVALID_FUNCTION 1 // dderror
//  The system cannot find the file specified.
#define ERROR_FILE_NOT_FOUND 2
//  The system cannot find the path specified.
#define ERROR_PATH_NOT_FOUND 3
//  The system cannot open the file.
#define ERROR_TOO_MANY_OPEN_FILES 4
//  Access is denied.
#define ERROR_ACCESS_DENIED 5
//  The handle is invalid.
#define ERROR_INVALID_HANDLE 6
//  The storage control blocks were destroyed.
#define ERROR_ARENA_TRASHED 7
//  Not enough storage is available to process this command.
#define ERROR_NOT_ENOUGH_MEMORY 8 // dderror
//  The storage control block address is invalid.
#define ERROR_INVALID_BLOCK 9
//  The environment is incorrect.
#define ERROR_BAD_ENVIRONMENT 10
//  An attempt was made to load a program with an
//  incorrect format.
#define ERROR_BAD_FORMAT 11
//  The access code is invalid.
#define ERROR_INVALID_ACCESS 12
//  The data is invalid.
#define ERROR_INVALID_DATA 13
//  Not enough storage is available to complete this operation.
#define ERROR_OUTOFMEMORY 14
//  The system cannot find the drive specified.
#define ERROR_INVALID_DRIVE 15
//  The directory cannot be removed.
#define ERROR_CURRENT_DIRECTORY 16
//  The system cannot move the file
//  to a different disk drive.
#define ERROR_NOT_SAME_DEVICE 17
//  There are no more files.
#define ERROR_NO_MORE_FILES 18
//  The media is write protected.
#define ERROR_WRITE_PROTECT 19
//  The system cannot find the device specified.
#define ERROR_BAD_UNIT 20
//  The device is not ready.
#define ERROR_NOT_READY 21
//  The device does not recognize the command.
#define ERROR_BAD_COMMAND 22
//  Data error (cyclic redundancy check)
#define ERROR_CRC 23
//  The program issued a command but the
//  command length is incorrect.
#define ERROR_BAD_LENGTH 24
//  The drive cannot locate a specific
//  area or track on the disk.
#define ERROR_SEEK 25
//  The specified disk or diskette cannot be accessed.
#define ERROR_NOT_DOS_DISK 26
//  The drive cannot find the sector requested.
#define ERROR_SECTOR_NOT_FOUND 27
//  The printer is out of paper.
#define ERROR_OUT_OF_PAPER 28
//  The system cannot write to the specified device.
#define ERROR_WRITE_FAULT 29
//  The system cannot read from the specified device.
#define ERROR_READ_FAULT 30
//  A device attached to the system is not functioning.
#define ERROR_GEN_FAILURE 31
//  The process cannot access the file because
//  it is being used by another process.
#define ERROR_SHARING_VIOLATION 32
//  The process cannot access the file because
//  another process has locked a portion of the file.
#define ERROR_LOCK_VIOLATION 33
//  The wrong diskette is in the drive.
//  Insert %2 (Volume Serial Number: %3)
//  into drive %1.
#define ERROR_WRONG_DISK 34
//  Too many files opened for sharing.
#define ERROR_SHARING_BUFFER_EXCEEDED 36
//  Reached end of file.
#define ERROR_HANDLE_EOF 38
//  The disk is full.
#define ERROR_HANDLE_DISK_FULL 39
//  The network request is not supported.
#define ERROR_NOT_SUPPORTED 50
//  The remote computer is not available.
#define ERROR_REM_NOT_LIST 51
//  A duplicate name exists on the network.
#define ERROR_DUP_NAME 52
//  The network path was not found.
#define ERROR_BAD_NETPATH 53
//  The network is busy.
#define ERROR_NETWORK_BUSY 54
//  The specified network resource or device is no longer
//  available.
#define ERROR_DEV_NOT_EXIST 55 // dderror
//  The network BIOS command limit has been reached.
#define ERROR_TOO_MANY_CMDS 56
//  A network adapter hardware error occurred.
#define ERROR_ADAP_HDW_ERR 57
//  The specified server cannot perform the requested
//  operation.
#define ERROR_BAD_NET_RESP 58
//  An unexpected network error occurred.
#define ERROR_UNEXP_NET_ERR 59
//  The remote adapter is not compatible.
#define ERROR_BAD_REM_ADAP 60
//  The printer queue is full.
#define ERROR_PRINTQ_FULL 61
//  Space to store the file waiting to be printed is
//  not available on the server.
#define ERROR_NO_SPOOL_SPACE 62
//  Your file waiting to be printed was deleted.
#define ERROR_PRINT_CANCELLED 63
//  The specified network name is no longer available.
#define ERROR_NETNAME_DELETED 64
//  Network access is denied.
#define ERROR_NETWORK_ACCESS_DENIED 65
//  The network resource type is not correct.
#define ERROR_BAD_DEV_TYPE 66
//  The network name cannot be found.
#define ERROR_BAD_NET_NAME 67
//  The name limit for the local computer network
//  adapter card was exceeded.
#define ERROR_TOO_MANY_NAMES 68
//  The network BIOS session limit was exceeded.
#define ERROR_TOO_MANY_SESS 69
//  The remote server has been paused or is in the
//  process of being started.
#define ERROR_SHARING_PAUSED 70
//  The network request was not accepted.
#define ERROR_REQ_NOT_ACCEP 71
//  The specified printer or disk device has been paused.
#define ERROR_REDIR_PAUSED 72
//  The file exists.
#define ERROR_FILE_EXISTS 80
//  The directory or file cannot be created.
#define ERROR_CANNOT_MAKE 82
//  Fail on INT 24
#define ERROR_FAIL_I24 83
//  Storage to process this request is not available.
#define ERROR_OUT_OF_STRUCTURES 84
//  The local device name is already in use.
#define ERROR_ALREADY_ASSIGNED 85
//  The specified network password is not correct.
#define ERROR_INVALID_PASSWORD 86
//  The parameter is incorrect.
#define ERROR_INVALID_PARAMETER 87 // dderror
//  A write fault occurred on the network.
#define ERROR_NET_WRITE_FAULT 88
//  The system cannot start another process at
//  this time.
#define ERROR_NO_PROC_SLOTS 89
//  Cannot create another system semaphore.
#define ERROR_TOO_MANY_SEMAPHORES 100
//  The exclusive semaphore is owned by another process.
#define ERROR_EXCL_SEM_ALREADY_OWNED 101
//  The semaphore is set and cannot be closed.
#define ERROR_SEM_IS_SET 102
//  The semaphore cannot be set again.
#define ERROR_TOO_MANY_SEM_REQUESTS 103
//  Cannot request exclusive semaphores at interrupt time.
#define ERROR_INVALID_AT_INTERRUPT_TIME 104
//  The previous ownership of this semaphore has ended.
#define ERROR_SEM_OWNER_DIED 105
//  Insert the diskette for drive %1.
#define ERROR_SEM_USER_LIMIT 106
//  Program stopped because alternate diskette was not inserted.
#define ERROR_DISK_CHANGE 107
//  The disk is in use or locked by
//  another process.
#define ERROR_DRIVE_LOCKED 108
//  The pipe has been ended.
#define ERROR_BROKEN_PIPE 109
//  The system cannot open the
//  device or file specified.
#define ERROR_OPEN_FAILED 110
//  The file name is too long.
#define ERROR_BUFFER_OVERFLOW 111
//  There is not enough space on the disk.
#define ERROR_DISK_FULL 112
//  No more internal file identifiers available.
#define ERROR_NO_MORE_SEARCH_HANDLES 113
//  The target internal file identifier is incorrect.
#define ERROR_INVALID_TARGET_HANDLE 114
//  The IOCTL call made by the application program is
//  not correct.
#define ERROR_INVALID_CATEGORY 117
//  The verify-on-write switch parameter value is not
//  correct.
#define ERROR_INVALID_VERIFY_SWITCH 118
//  The system does not support the command requested.
#define ERROR_BAD_DRIVER_LEVEL 119
//  This function is only valid in Windows NT mode.
#define ERROR_CALL_NOT_IMPLEMENTED 120
//  The semaphore timeout period has expired.
#define ERROR_SEM_TIMEOUT 121
//  The data area passed to a system call is too
//  small.
#define ERROR_INSUFFICIENT_BUFFER 122 // dderror
//  The filename, directory name, or volume label syntax is incorrect.
#define ERROR_INVALID_NAME 123
//  The system call level is not correct.
#define ERROR_INVALID_LEVEL 124
//  The disk has no volume label.
#define ERROR_NO_VOLUME_LABEL 125
//  The specified module could not be found.
#define ERROR_MOD_NOT_FOUND 126
//  The specified procedure could not be found.
#define ERROR_PROC_NOT_FOUND 127
//  There are no child processes to wait for.
#define ERROR_WAIT_NO_CHILDREN 128
//  The %1 application cannot be run in Windows NT mode.
#define ERROR_CHILD_NOT_COMPLETE 129
//  Attempt to use a file handle to an open disk partition for an
//  operation other than raw disk I/O.
#define ERROR_DIRECT_ACCESS_HANDLE 130
//  An attempt was made to move the file pointer before the beginning of the file.
#define ERROR_NEGATIVE_SEEK 131
//  The file pointer cannot be set on the specified device or file.
#define ERROR_SEEK_ON_DEVICE 132
//  A JOIN or SUBST command
//  cannot be used for a drive that
//  contains previously joined drives.
#define ERROR_IS_JOIN_TARGET 133
//  An attempt was made to use a
//  JOIN or SUBST command on a drive that has
//  already been joined.
#define ERROR_IS_JOINED 134
//  An attempt was made to use a
//  JOIN or SUBST command on a drive that has
//  already been substituted.
#define ERROR_IS_SUBSTED 135
//  The system tried to delete
//  the JOIN of a drive that is not joined.
#define ERROR_NOT_JOINED 136
//  The system tried to delete the
//  substitution of a drive that is not substituted.
#define ERROR_NOT_SUBSTED 137
//  The system tried to join a drive
//  to a directory on a joined drive.
#define ERROR_JOIN_TO_JOIN 138
//  The system tried to substitute a
//  drive to a directory on a substituted drive.
#define ERROR_SUBST_TO_SUBST 139
//  The system tried to join a drive to
//  a directory on a substituted drive.
#define ERROR_JOIN_TO_SUBST 140
//  The system tried to SUBST a drive
//  to a directory on a joined drive.
#define ERROR_SUBST_TO_JOIN 141
//  The system cannot perform a JOIN or SUBST at this time.
#define ERROR_BUSY_DRIVE 142
//  The system cannot join or substitute a
//  drive to or for a directory on the same drive.
#define ERROR_SAME_DRIVE 143
//  The directory is not a subdirectory of the root directory.
#define ERROR_DIR_NOT_ROOT 144
//  The directory is not empty.
#define ERROR_DIR_NOT_EMPTY 145
//  The path specified is being used in
//  a substitute.
#define ERROR_IS_SUBST_PATH 146
//  Not enough resources are available to
//  process this command.
#define ERROR_IS_JOIN_PATH 147
//  The path specified cannot be used at this time.
#define ERROR_PATH_BUSY 148
//  An attempt was made to join
//  or substitute a drive for which a directory
//  on the drive is the target of a previous
//  substitute.
#define ERROR_IS_SUBST_TARGET 149
//  System trace information was not specified in your
//  CONFIG.SYS file, or tracing is disallowed.
#define ERROR_SYSTEM_TRACE 150
//  The number of specified semaphore events for
//  DosMuxSemWait is not correct.
#define ERROR_INVALID_EVENT_COUNT 151
//  DosMuxSemWait did not execute; too many semaphores
//  are already set.
#define ERROR_TOO_MANY_MUXWAITERS 152
//  The DosMuxSemWait list is not correct.
#define ERROR_INVALID_LIST_FORMAT 153
//  The volume label you entered exceeds the
//  11 character limit.  The first 11 characters were written
//  to disk.  Any characters that exceeded the 11 character limit
//  were automatically deleted.
#define ERROR_LABEL_TOO_LONG 154
//  Cannot create another thread.
#define ERROR_TOO_MANY_TCBS 155
//  The recipient process has refused the signal.
#define ERROR_SIGNAL_REFUSED 156
//  The segment is already discarded and cannot be locked.
#define ERROR_DISCARDED 157
//  The segment is already unlocked.
#define ERROR_NOT_LOCKED 158
//  The address for the thread ID is not correct.
#define ERROR_BAD_THREADID_ADDR 159
//  The argument string passed to DosExecPgm is not correct.
#define ERROR_BAD_ARGUMENTS 160
//  The specified path is invalid.
#define ERROR_BAD_PATHNAME 161
//  A signal is already pending.
#define ERROR_SIGNAL_PENDING 162
//  No more threads can be created in the system.
#define ERROR_MAX_THRDS_REACHED 164
//  Unable to lock a region of a file.
#define ERROR_LOCK_FAILED 167
//  The requested resource is in use.
#define ERROR_BUSY 170
//  A lock request was not outstanding for the supplied cancel region.
#define ERROR_CANCEL_VIOLATION 173
//  The file system does not support atomic changes to the lock type.
#define ERROR_ATOMIC_LOCKS_NOT_SUPPORTED 174
//  The system detected a segment number that was not correct.
#define ERROR_INVALID_SEGMENT_NUMBER 180
//  The operating system cannot run %1.
#define ERROR_INVALID_ORDINAL 182
//  Cannot create a file when that file already exists.
#define ERROR_ALREADY_EXISTS 183
//  The flag passed is not correct.
#define ERROR_INVALID_FLAG_NUMBER 186
//  The specified system semaphore name was not found.
#define ERROR_SEM_NOT_FOUND 187
//  The operating system cannot run %1.
#define ERROR_INVALID_STARTING_CODESEG 188
//  The operating system cannot run %1.
#define ERROR_INVALID_STACKSEG 189
//  The operating system cannot run %1.
#define ERROR_INVALID_MODULETYPE 190
//  Cannot run %1 in Windows NT mode.
#define ERROR_INVALID_EXE_SIGNATURE 191
//  The operating system cannot run %1.
#define ERROR_EXE_MARKED_INVALID 192
//  %1 is not a valid Windows NT application.
#define ERROR_BAD_EXE_FORMAT 193
//  The operating system cannot run %1.
#define ERROR_ITERATED_DATA_EXCEEDS_64k 194
//  The operating system cannot run %1.
#define ERROR_INVALID_MINALLOCSIZE 195
//  The operating system cannot run this
//  application program.
#define ERROR_DYNLINK_FROM_INVALID_RING 196
//  The operating system is not presently
//  configured to run this application.
#define ERROR_IOPL_NOT_ENABLED 197
//  The operating system cannot run %1.
#define ERROR_INVALID_SEGDPL 198
//  The operating system cannot run this
//  application program.
#define ERROR_AUTODATASEG_EXCEEDS_64k 199
//  The code segment cannot be greater than or equal to 64KB.
#define ERROR_RING2SEG_MUST_BE_MOVABLE 200
//  The operating system cannot run %1.
#define ERROR_RELOC_CHAIN_XEEDS_SEGLIM 201
//  The operating system cannot run %1.
#define ERROR_INFLOOP_IN_RELOC_CHAIN 202
//  The system could not find the environment
//  option that was entered.
#define ERROR_ENVVAR_NOT_FOUND 203
//  No process in the command subtree has a
//  signal handler.
#define ERROR_NO_SIGNAL_SENT 205
//  The filename or extension is too long.
#define ERROR_FILENAME_EXCED_RANGE 206
//  The ring 2 stack is in use.
#define ERROR_RING2_STACK_IN_USE 207
//  The  filename characters,  or ?, are entered
//  incorrectly or too many  filename characters are specified.
#define ERROR_META_EXPANSION_TOO_LONG 208
//  The signal being posted is not correct.
#define ERROR_INVALID_SIGNAL_NUMBER 209
//  The signal handler cannot be set.
#define ERROR_THREAD_1_INACTIVE 210
//  The segment is locked and cannot be reallocated.
#define ERROR_LOCKED 212
//  Too many dynamic link modules are attached to this
//  program or dynamic link module.
#define ERROR_TOO_MANY_MODULES 214
//  Can't nest calls to LoadModule.
#define ERROR_NESTING_NOT_ALLOWED 215
//  The pipe state is invalid.
#define ERROR_BAD_PIPE 230
//  All pipe instances are busy.
#define ERROR_PIPE_BUSY 231
//  The pipe is being closed.
#define ERROR_NO_DATA 232
//  No process is on the other end of the pipe.
#define ERROR_PIPE_NOT_CONNECTED 233
//  More data is available.
#define ERROR_MORE_DATA 234 // dderror
//  The session was cancelled.
#define ERROR_VC_DISCONNECTED 240
//  The specified extended attribute name was invalid.
#define ERROR_INVALID_EA_NAME 254
//  The extended attributes are inconsistent.
#define ERROR_EA_LIST_INCONSISTENT 255
//  No more data is available.
#define ERROR_NO_MORE_ITEMS 259
//  The Copy API cannot be used.
#define ERROR_CANNOT_COPY 266
//  The directory name is invalid.
#define ERROR_DIRECTORY 267
//  The extended attributes did not fit in the buffer.
#define ERROR_EAS_DIDNT_FIT 275
//  The extended attribute file on the mounted file system is corrupt.
#define ERROR_EA_FILE_CORRUPT 276
//  The extended attribute table file is full.
#define ERROR_EA_TABLE_FULL 277
//  The specified extended attribute handle is invalid.
#define ERROR_INVALID_EA_HANDLE 278
//  The mounted file system does not support extended attributes.
#define ERROR_EAS_NOT_SUPPORTED 282
//  Attempt to release mutex not owned by caller.
#define ERROR_NOT_OWNER 288
//  Too many posts were made to a semaphore.
#define ERROR_TOO_MANY_POSTS 298
//  The system cannot find message for message number 0x%1
//  in message file for %2.
#define ERROR_MR_MID_NOT_FOUND 317
//  Attempt to access invalid address.
#define ERROR_INVALID_ADDRESS 487
//  Arithmetic result exceeded 32 bits.
#define ERROR_ARITHMETIC_OVERFLOW 534
//  There is a process on other end of the pipe.
#define ERROR_PIPE_CONNECTED 535
//  Waiting for a process to open the other end of the pipe.
#define ERROR_PIPE_LISTENING 536
//  Access to the extended attribute was denied.
#define ERROR_EA_ACCESS_DENIED 994
//  The I/O operation has been aborted because of either a thread exit
//  or an application request.
#define ERROR_OPERATION_ABORTED 995
//  Overlapped I/O event is not in a signalled state.
#define ERROR_IO_INCOMPLETE 996
//  Overlapped I/O operation is in progress.
#define ERROR_IO_PENDING 997 // dderror
//  Invalid access to memory location.
#define ERROR_NOACCESS 998
//  Error performing inpage operation.
#define ERROR_SWAPERROR 999
//  Recursion too deep, stack overflowed.
#define ERROR_STACK_OVERFLOW 1001
//  The window cannot act on the sent message.
#define ERROR_INVALID_MESSAGE 1002
//  Cannot complete this function.
#define ERROR_CAN_NOT_COMPLETE 1003
//  Invalid flags.
#define ERROR_INVALID_FLAGS 1004
//  The volume does not contain a recognized file system.
//  Please make sure that all required file system drivers are loaded and that the
//  volume is not corrupt.
#define ERROR_UNRECOGNIZED_VOLUME 1005
//  The volume for a file has been externally altered such that the
//  opened file is no longer valid.
#define ERROR_FILE_INVALID 1006
//  The requested operation cannot be performed in full-screen mode.
#define ERROR_FULLSCREEN_MODE 1007
//  An attempt was made to reference a token that does not exist.
#define ERROR_NO_TOKEN 1008
//  The configuration registry database is corrupt.
#define ERROR_BADDB 1009
//  The configuration registry key is invalid.
#define ERROR_BADKEY 1010
//  The configuration registry key could not be opened.
#define ERROR_CANTOPEN 1011
//  The configuration registry key could not be read.
#define ERROR_CANTREAD 1012
//  The configuration registry key could not be written.
#define ERROR_CANTWRITE 1013
//  One of the files in the Registry database had to be recovered
//  by use of a log or alternate copy.  The recovery was successful.
#define ERROR_REGISTRY_RECOVERED 1014
//  The Registry is corrupt. The structure of one of the files that contains
//  Registry data is corrupt, or the system's image of the file in memory
//  is corrupt, or the file could not be recovered because the alternate
//  copy or log was absent or corrupt.
#define ERROR_REGISTRY_CORRUPT 1015
//  An I/O operation initiated by the Registry failed unrecoverably.
//  The Registry could not read in, or write out, or flush, one of the files
//  that contain the system's image of the Registry.
#define ERROR_REGISTRY_IO_FAILED 1016
//  The system has attempted to load or restore a file into the Registry, but the
//  specified file is not in a Registry file format.
#define ERROR_NOT_REGISTRY_FILE 1017
//  Illegal operation attempted on a Registry key which has been marked for deletion.
#define ERROR_KEY_DELETED 1018
//  System could not allocate the required space in a Registry log.
#define ERROR_NO_LOG_SPACE 1019
//  Cannot create a symbolic link in a Registry key that already
//  has subkeys or values.
#define ERROR_KEY_HAS_CHILDREN 1020
//  Cannot create a stable subkey under a volatile parent key.
#define ERROR_CHILD_MUST_BE_VOLATILE 1021
//  A notify change request is being completed and the information
//  is not being returned in the caller's buffer. The caller now
//  needs to enumerate the files to find the changes.
#define ERROR_NOTIFY_ENUM_DIR 1022
//  A stop control has been sent to a service which other running services
//  are dependent on.
#define ERROR_DEPENDENT_SERVICES_RUNNING 1051
//  The requested control is not valid for this service
#define ERROR_INVALID_SERVICE_CONTROL 1052
//  The service did not respond to the start or control request in a timely
//  fashion.
#define ERROR_SERVICE_REQUEST_TIMEOUT 1053
//  A thread could not be created for the service.
#define ERROR_SERVICE_NO_THREAD 1054
//  The service database is locked.
#define ERROR_SERVICE_DATABASE_LOCKED 1055
//  An instance of the service is already running.
#define ERROR_SERVICE_ALREADY_RUNNING 1056
//  The account name is invalid or does not exist.
#define ERROR_INVALID_SERVICE_ACCOUNT 1057
//  The specified service is disabled and cannot be started.
#define ERROR_SERVICE_DISABLED 1058
//  Circular service dependency was specified.
#define ERROR_CIRCULAR_DEPENDENCY 1059
//  The specified service does not exist as an installed service.
#define ERROR_SERVICE_DOES_NOT_EXIST 1060
//  The service cannot accept control messages at this time.
#define ERROR_SERVICE_CANNOT_ACCEPT_CTRL 1061
//  The service has not been started.
#define ERROR_SERVICE_NOT_ACTIVE 1062
//  The service process could not connect to the service controller.
#define ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 1063
//  An exception occurred in the service when handling the control request.
#define ERROR_EXCEPTION_IN_SERVICE 1064
//  The database specified does not exist.
#define ERROR_DATABASE_DOES_NOT_EXIST 1065
//  The service has returned a service-specific error code.
#define ERROR_SERVICE_SPECIFIC_ERROR 1066
//  The process terminated unexpectedly.
#define ERROR_PROCESS_ABORTED 1067
//  The dependency service or group failed to start.
#define ERROR_SERVICE_DEPENDENCY_FAIL 1068
//  The service did not start due to a logon failure.
#define ERROR_SERVICE_LOGON_FAILED 1069
//  After starting, the service hung in a start-pending state.
#define ERROR_SERVICE_START_HANG 1070
//  The specified service database lock is invalid.
#define ERROR_INVALID_SERVICE_LOCK 1071
//  The specified service has been marked for deletion.
#define ERROR_SERVICE_MARKED_FOR_DELETE 1072
//  The specified service already exists.
#define ERROR_SERVICE_EXISTS 1073
//  The system is currently running with the last-known-good configuration.
#define ERROR_ALREADY_RUNNING_LKG 1074
//  The dependency service does not exist or has been marked for
//  deletion.
#define ERROR_SERVICE_DEPENDENCY_DELETED 1075
//  The current boot has already been accepted for use as the
//  last-known-good control set.
#define ERROR_BOOT_ALREADY_ACCEPTED 1076
//  No attempts to start the service have been made since the last boot.
#define ERROR_SERVICE_NEVER_STARTED 1077
//  The name is already in use as either a service name or a service display
//  name.
#define ERROR_DUPLICATE_SERVICE_NAME 1078
//  The physical end of the tape has been reached.
#define ERROR_END_OF_MEDIA 1100
//  A tape access reached a filemark.
#define ERROR_FILEMARK_DETECTED 1101
//  Beginning of tape or partition was encountered.
#define ERROR_BEGINNING_OF_MEDIA 1102
//  A tape access reached the end of a set of files.
#define ERROR_SETMARK_DETECTED 1103
//  No more data is on the tape.
#define ERROR_NO_DATA_DETECTED 1104
//  Tape could not be partitioned.
#define ERROR_PARTITION_FAILURE 1105
//  When accessing a new tape of a multivolume partition, the current
//  blocksize is incorrect.
#define ERROR_INVALID_BLOCK_LENGTH 1106
//  Tape partition information could not be found when loading a tape.
#define ERROR_DEVICE_NOT_PARTITIONED 1107
//  Unable to lock the media eject mechanism.
#define ERROR_UNABLE_TO_LOCK_MEDIA 1108
//  Unable to unload the media.
#define ERROR_UNABLE_TO_UNLOAD_MEDIA 1109
//  Media in drive may have changed.
#define ERROR_MEDIA_CHANGED 1110
//  The I/O bus was reset.
#define ERROR_BUS_RESET 1111
//  No media in drive.
#define ERROR_NO_MEDIA_IN_DRIVE 1112
//  No mapping for the Unicode character exists in the target multi-byte code page.
#define ERROR_NO_UNICODE_TRANSLATION 1113
//  A dynamic link library (DLL) initialization routine failed.
#define ERROR_DLL_INIT_FAILED 1114
//  A system shutdown is in progress.
#define ERROR_SHUTDOWN_IN_PROGRESS 1115
//  Unable to abort the system shutdown because no shutdown was in progress.
#define ERROR_NO_SHUTDOWN_IN_PROGRESS 1116
//  The request could not be performed because of an I/O device error.
#define ERROR_IO_DEVICE 1117
//  No serial device was successfully initialized.  The serial driver will unload.
#define ERROR_SERIAL_NO_DEVICE 1118
//  Unable to open a device that was sharing an interrupt request (IRQ)
//  with other devices. At least one other device that uses that IRQ
//  was already opened.
#define ERROR_IRQ_BUSY 1119
//  A serial I/O operation was completed by another write to the serial port.
//  (The IOCTL_SERIAL_XOFF_COUNTER reached zero.)
#define ERROR_MORE_WRITES 1120
//  A serial I/O operation completed because the time-out period expired.
//  (The IOCTL_SERIAL_XOFF_COUNTER did not reach zero.)
#define ERROR_COUNTER_TIMEOUT 1121
//  No ID address mark was found on the floppy disk.
#define ERROR_FLOPPY_ID_MARK_NOT_FOUND 1122
//  Mismatch between the floppy disk sector ID field and the floppy disk
//  controller track address.
#define ERROR_FLOPPY_WRONG_CYLINDER 1123
//  The floppy disk controller reported an error that is not recognized
//  by the floppy disk driver.
#define ERROR_FLOPPY_UNKNOWN_ERROR 1124
//  The floppy disk controller returned inconsistent results in its registers.
#define ERROR_FLOPPY_BAD_REGISTERS 1125
//  While accessing the hard disk, a recalibrate operation failed, even after retries.
#define ERROR_DISK_RECALIBRATE_FAILED 1126
//  While accessing the hard disk, a disk operation failed even after retries.
#define ERROR_DISK_OPERATION_FAILED 1127
//  While accessing the hard disk, a disk controller reset was needed, but
//  even that failed.
#define ERROR_DISK_RESET_FAILED 1128
//  Physical end of tape encountered.
#define ERROR_EOM_OVERFLOW 1129
//  Not enough server storage is available to process this command.
#define ERROR_NOT_ENOUGH_SERVER_MEMORY 1130
//  A potential deadlock condition has been detected.
#define ERROR_POSSIBLE_DEADLOCK 1131
//  The base address or the file offset specified does not have the proper
//  alignment.
#define ERROR_MAPPED_ALIGNMENT 1132

//Local Memory Flags
#define LMEM_FIXED              0x0
#define LMEM_MOVEABLE           0x2
#define LMEM_NOCOMPACT          0x10
#define LMEM_NODISCARD          0x20
#define LMEM_ZEROINIT           0x40
#define LMEM_MODIFY             0x80
#define LMEM_DISCARDABLE        0xF00
#define LMEM_VALID_FLAGS        0xF72
#define LMEM_INVALID_HANDLE     0x8000

#define LHND LMEM_MOVEABLE + LMEM_ZEROINIT
#define LPTR LMEM_FIXED + LMEM_ZEROINIT

#define NONZEROLHND LMEM_MOVEABLE
#define NONZEROLPTR LMEM_FIXED

//Flags returned by LocalFlags (in addition to LMEM_DISCARDABLE)
#define LMEM_DISCARDED 0x4000
#define LMEM_LOCKCOUNT 0xFF

#define FILE_READ_DATA 0x1                     // file pipe
#define FILE_LIST_DIRECTORY 0x1                // directory

#define FILE_WRITE_DATA 0x2                    // file pipe
#define FILE_ADD_FILE 0x2                      // directory

#define FILE_APPEND_DATA 0x4                   // file
#define FILE_ADD_SUBDIRECTORY 0x4              // directory
#define FILE_CREATE_PIPE_INSTANCE 0x4          // named pipe

#define FILE_READ_EA 0x8                       // file directory
#define FILE_READ_PROPERTIES FILE_READ_EA

#define FILE_WRITE_EA 0x10                     // file directory
#define FILE_WRITE_PROPERTIES FILE_WRITE_EA

#define FILE_EXECUTE 0x20                      // file
#define FILE_TRAVERSE 0x20                     // directory

#define FILE_DELETE_CHILD 0x40                 // directory

#define FILE_READ_ATTRIBUTES 0x80              // all

#define FILE_WRITE_ATTRIBUTES 0x100            // all

#define FILE_ALL_ACCESS STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF

#define FILE_GENERIC_READ STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE

#define FILE_GENERIC_WRITE STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE

#define FILE_GENERIC_EXECUTE STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE

#define FILE_SHARE_READ 0x1
#define FILE_SHARE_WRITE 0x2
#define FILE_ATTRIBUTE_READONLY 0x1
#define FILE_ATTRIBUTE_HIDDEN 0x2
#define FILE_ATTRIBUTE_SYSTEM 0x4
#define FILE_ATTRIBUTE_DIRECTORY 0x10
#define FILE_ATTRIBUTE_ARCHIVE 0x20
#define FILE_ATTRIBUTE_NORMAL 0x80
#define FILE_ATTRIBUTE_TEMPORARY 0x100
#define FILE_ATTRIBUTE_COMPRESSED 0x800
#define FILE_NOTIFY_CHANGE_FILE_NAME 0x1
#define FILE_NOTIFY_CHANGE_DIR_NAME 0x2
#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x4
#define FILE_NOTIFY_CHANGE_SIZE 0x8
#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x10
#define FILE_NOTIFY_CHANGE_SECURITY 0x100
#define MAILSLOT_NO_MESSAGE -1
#define MAILSLOT_WAIT_FOREVER -1
#define FILE_CASE_SENSITIVE_SEARCH 0x1
#define FILE_CASE_PRESERVED_NAMES 0x2
#define FILE_UNICODE_ON_DISK 0x4
#define FILE_PERSISTENT_ACLS 0x8
#define FILE_FILE_COMPRESSION 0x10
#define FILE_VOLUME_IS_COMPRESSED 0x8000
#define IO_COMPLETION_MODIFY_STATE 0x2
#define IO_COMPLETION_ALL_ACCESS STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
#define DUPLICATE_CLOSE_SOURCE 0x1
#define DUPLICATE_SAME_ACCESS 0x2

struct PROCESS_INFORMATION{
  long  hProcess;
  long  hThread;
  long  dwProcessId;
  long  dwThreadId;
};

struct FILETIME{
  long  dwLowDateTime;
  long  dwHighDateTime;
};

struct SYSTEMTIME{
  short wYear;
  short wMonth;
  short wDayOfWeek;
  short wDay;
  short wHour;
  short wMinute;
  short wSecond;
  short wMilliseconds;
};

struct WIN32_FIND_DATA{
  long  dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  long  nFileSizeHigh;
  long  nFileSizeLow;
  long  dwReserved0;
  long  dwReserved1;
  char  cFileName[MAX_PATH];
  char  cAlternate[14];
};

struct STARTUPINFO{
  long  cb;
  LPSTR lpReserved;
  LPSTR lpDesktop;
  LPSTR lpTitle;
  long  dwX;
  long  dwY;
  long  dwXSize;
  long  dwYSize;
  long  dwXCountChars;
  long  dwYCountChars;
  long  dwFillAttribute;
  long  dwFlags;
  short wShowWindow;
  short cbReserved2;
  long  lpReserved2;
  long  hStdInput;
  long  hStdOutput;
  long  hStdError;
};

//MessageBox() Flags
#define MB_OK 0x0
#define MB_OKCANCEL 0x1
#define MB_ABORTRETRYIGNORE 0x2
#define MB_YESNOCANCEL 0x3
#define MB_YESNO 0x4
#define MB_RETRYCANCEL 0x5

#define MB_ICONHAND 0x10
#define MB_ICONQUESTION 0x20
#define MB_ICONEXCLAMATION 0x30
#define MB_ICONASTERISK 0x40

#define MB_ICONINFORMATION MB_ICONASTERISK
#define MB_ICONSTOP MB_ICONHAND

#define MB_DEFBUTTON1 0x0
#define MB_DEFBUTTON2 0x100
#define MB_DEFBUTTON3 0x200

#define MB_APPLMODAL 0x0
#define MB_SYSTEMMODAL 0x1000
#define MB_TASKMODAL 0x2000

#define MB_NOFOCUS 0x8000
#define MB_SETFOREGROUND 0x10000
#define MB_DEFAULT_DESKTOP_ONLY 0x20000

#define MB_TYPEMASK 0xF
#define MB_ICONMASK 0xF0
#define MB_DEFMASK 0xF00
#define MB_MODEMASK 0x3000
#define MB_MISCMASK 0xC000

struct RECT{
  long  left;
  long  top;
  long  right;
  long  bottom;
};
#define RECTL RECT

struct POINT{
  long  x;
  long  y;
};
#define POINTL POINT

struct SIZE{
  long  cx;
  long  cy;
};

struct POINTS{
  short x;
  short y;
};

struct COORD{
  short x;
  short y;
};


struct MSG{
  long  hwnd;
  long  message;
  long  wParam;
  long  lParam;
  long  time;
  POINT pt;
};

struct KEY_EVENT_RECORD{
  long  bKeyDown;
  short wRepeatCount;
  short wVirtualKeyCode;
  short wVirtualScanCode;
  byte  uChar;
  long  dwControlKeyState;
};

struct MOUSE_EVENT_RECORD{
  COORD dwMousePosition;
  long  dwButtonState;
  long  dwControlKeyState;
  long  dwEventFlags;
};

struct WINDOW_BUFFER_SIZE_RECORD{
  COORD dwSize;
};

struct MENU_EVENT_RECORD{
  long  dwCommandId;
};

struct FOCUS_EVENT_RECORD{
  long  bSetFocus;
};

#define IGNORE 0 // Ignore signal
#define INFINITE 0xFFFF      // Infinite timeout

//Window Messages
#define WM_NULL 0x0
#define WM_CREATE 0x1
#define WM_DESTROY 0x2
#define WM_MOVE 0x3
#define WM_SIZE 0x5

#define WM_ACTIVATE 0x6
#define WM_SETFOCUS 0x7
#define WM_KILLFOCUS 0x8
#define WM_ENABLE 0xA
#define WM_SETREDRAW 0xB
#define WM_SETTEXT 0xC
#define WM_GETTEXT 0xD
#define WM_GETTEXTLENGTH 0xE
#define WM_PAINT 0xF
#define WM_CLOSE 0x10
#define WM_QUERYENDSESSION 0x11
#define WM_QUIT 0x12
#define WM_QUERYOPEN 0x13
#define WM_ERASEBKGND 0x14
#define WM_SYSCOLORCHANGE 0x15
#define WM_ENDSESSION 0x16
#define WM_SHOWWINDOW 0x18
#define WM_WININICHANGE 0x1A
#define WM_DEVMODECHANGE 0x1B
#define WM_ACTIVATEAPP 0x1C
#define WM_FONTCHANGE 0x1D
#define WM_TIMECHANGE 0x1E
#define WM_CANCELMODE 0x1F
#define WM_SETCURSOR 0x20
#define WM_MOUSEACTIVATE 0x21
#define WM_CHILDACTIVATE 0x22
#define WM_QUEUESYNC 0x23

#define WM_GETMINMAXINFO 0x24
#define WM_PAINTICON 0x26
#define WM_ICONERASEBKGND 0x27
#define WM_NEXTDLGCTL 0x28
#define WM_SPOOLERSTATUS 0x2A
#define WM_DRAWITEM 0x2B
#define WM_MEASUREITEM 0x2C
#define WM_DELETEITEM 0x2D
#define WM_VKEYTOITEM 0x2E
#define WM_CHARTOITEM 0x2F
#define WM_SETFONT 0x30
#define WM_GETFONT 0x31
#define WM_SETHOTKEY 0x32
#define WM_GETHOTKEY 0x33
#define WM_QUERYDRAGICON 0x37
#define WM_COMPAREITEM 0x39
#define WM_COMPACTING 0x41
#define WM_OTHERWINDOWCREATED 0x42               // no longer suported
#define WM_OTHERWINDOWDESTROYED 0x43             // no longer suported
#define WM_COMMNOTIFY 0x44                       // no longer suported
#define WM_WINDOWPOSCHANGING 0x46
#define WM_WINDOWPOSCHANGED 0x47
#define WM_POWER 0x48
#define WM_COPYDATA 0x4A
#define WM_CANCELJOURNAL 0x4B

#define WM_NOTIFY                       0x004E
#define WM_INPUTLANGCHANGEREQUEST       0x0050
#define WM_INPUTLANGCHANGE              0x0051
#define WM_TCARD                        0x0052
#define WM_HELP                         0x0053
#define WM_USERCHANGED                  0x0054
#define WM_NOTIFYFORMAT                 0x0055

#define WM_CONTEXTMENU                  0x007B
#define WM_STYLECHANGING                0x007C
#define WM_STYLECHANGED                 0x007D
#define WM_DISPLAYCHANGE                0x007E
#define WM_GETICON                      0x007F
#define WM_SETICON                      0x0080

#define WM_NCCREATE 0x81
#define WM_NCDESTROY 0x82
#define WM_NCCALCSIZE 0x83
#define WM_NCHITTEST 0x84
#define WM_NCPAINT 0x85
#define WM_NCACTIVATE 0x86
#define WM_GETDLGCODE 0x87
#define WM_NCMOUSEMOVE 0xA0
#define WM_NCLBUTTONDOWN 0xA1
#define WM_NCLBUTTONUP 0xA2
#define WM_NCLBUTTONDBLCLK 0xA3
#define WM_NCRBUTTONDOWN 0xA4
#define WM_NCRBUTTONUP 0xA5
#define WM_NCRBUTTONDBLCLK 0xA6
#define WM_NCMBUTTONDOWN 0xA7
#define WM_NCMBUTTONUP 0xA8
#define WM_NCMBUTTONDBLCLK 0xA9

#define BM_GETCHECK        0x00F0
#define BM_SETCHECK        0x00F1
#define BM_GETSTATE        0x00F2
#define BM_SETSTATE        0x00F3
#define BM_SETSTYLE        0x00F4
#define BM_CLICK           0x00F5
#define BM_GETIMAGE        0x00F6
#define BM_SETIMAGE        0x00F7

#define WM_KEYFIRST 0x100
#define WM_KEYDOWN 0x100
#define WM_KEYUP 0x101
#define WM_CHAR 0x102
#define WM_DEADCHAR 0x103
#define WM_SYSKEYDOWN 0x104
#define WM_SYSKEYUP 0x105
#define WM_SYSCHAR 0x106
#define WM_SYSDEADCHAR 0x107
#define WM_KEYLAST 0x108
#define WM_INITDIALOG 0x110
#define WM_COMMAND 0x111
#define WM_SYSCOMMAND 0x112
#define WM_TIMER 0x113
#define WM_HSCROLL 0x114
#define WM_VSCROLL 0x115
#define WM_INITMENU 0x116
#define WM_INITMENUPOPUP 0x117
#define WM_MENUSELECT 0x11F
#define WM_MENUCHAR 0x120
#define WM_ENTERIDLE 0x121

#define WM_CTLCOLORMSGBOX 0x132
#define WM_CTLCOLOREDIT 0x133
#define WM_CTLCOLORLISTBOX 0x134
#define WM_CTLCOLORBTN 0x135
#define WM_CTLCOLORDLG 0x136
#define WM_CTLCOLORSCROLLBAR 0x137
#define WM_CTLCOLORSTATIC 0x138

#define WM_MOUSEFIRST 0x200
#define WM_MOUSEMOVE 0x200
#define WM_LBUTTONDOWN 0x201
#define WM_LBUTTONUP 0x202
#define WM_LBUTTONDBLCLK 0x203
#define WM_RBUTTONDOWN 0x204
#define WM_RBUTTONUP 0x205
#define WM_RBUTTONDBLCLK 0x206
#define WM_MBUTTONDOWN 0x207
#define WM_MBUTTONUP 0x208
#define WM_MBUTTONDBLCLK 0x209
#define WM_MOUSELAST 0x209

#define WM_PARENTNOTIFY 0x210
#define WM_ENTERMENULOOP 0x211
#define WM_EXITMENULOOP 0x212
#define WM_MDICREATE 0x220
#define WM_MDIDESTROY 0x221
#define WM_MDIACTIVATE 0x222
#define WM_MDIRESTORE 0x223
#define WM_MDINEXT 0x224
#define WM_MDIMAXIMIZE 0x225
#define WM_MDITILE 0x226
#define WM_MDICASCADE 0x227
#define WM_MDIICONARRANGE 0x228
#define WM_MDIGETACTIVE 0x229
#define WM_MDISETMENU 0x230
#define WM_DROPFILES 0x233
#define WM_MDIREFRESHMENU 0x234


#define WM_CUT 0x300
#define WM_COPY 0x301
#define WM_PASTE 0x302
#define WM_CLEAR 0x303
#define WM_UNDO 0x304
#define WM_RENDERFORMAT 0x305
#define WM_RENDERALLFORMATS 0x306
#define WM_DESTROYCLIPBOARD 0x307
#define WM_DRAWCLIPBOARD 0x308
#define WM_PAINTCLIPBOARD 0x309
#define WM_VSCROLLCLIPBOARD 0x30A
#define WM_SIZECLIPBOARD 0x30B
#define WM_ASKCBFORMATNAME 0x30C
#define WM_CHANGECBCHAIN 0x30D
#define WM_HSCROLLCLIPBOARD 0x30E
#define WM_QUERYNEWPALETTE 0x30F
#define WM_PALETTEISCHANGING 0x310
#define WM_PALETTECHANGED 0x311
#define WM_HOTKEY 0x312

#define WM_PENWINFIRST 0x380
#define WM_PENWINLAST 0x38F

#define WM_USER 0x400

// Memory Flags
#define GMEM_FIXED              0x0
#define GMEM_MOVEABLE           0x2
#define GMEM_NOCOMPACT          0x10
#define GMEM_NODISCARD          0x20
#define GMEM_ZEROINIT           0x40
#define GMEM_MODIFY             0x80
#define GMEM_DISCARDABLE        0x100
#define GMEM_NOT_BANKED         0x1000
#define GMEM_SHARE              0x2000
#define GMEM_DDESHARE           0x2000
#define GMEM_NOTIFY             0x4000
#define GMEM_LOWER              GMEM_NOT_BANKED
#define GMEM_VALID_FLAGS        0x7F72
#define GMEM_INVALID_HANDLE     0x8000

#define GHND GMEM_MOVEABLE | GMEM_ZEROINIT
#define GPTR GMEM_FIXED | GMEM_ZEROINIT

//Flags returned by Flags (in addition to GMEM_DISCARDABLE)
#define GMEM_DISCARDED 0x4000
#define GMEM_LOCKCOUNT 0xFF

//Predefined Clipboard Formats
#define CF_TEXT 1
#define CF_BITMAP 2
#define CF_METAFILEPICT 3
#define CF_SYLK 4
#define CF_DIF 5
#define CF_TIFF 6
#define CF_OEMTEXT 7
#define CF_DIB 8
#define CF_PALETTE 9
#define CF_PENDATA 10
#define CF_RIFF 11
#define CF_WAVE 12
#define CF_UNICODETEXT 13
#define CF_ENHMETAFILE 14

#define CF_OWNERDISPLAY 0x80
#define CF_DSPTEXT 0x81
#define CF_DSPBITMAP 0x82
#define CF_DSPMETAFILEPICT 0x83
#define CF_DSPENHMETAFILE 0x8E

//"Private" formats don't get Free()'d
#define CF_PRIVATEFIRST 0x200
#define CF_PRIVATELAST 0x2FF

struct CWPSTRUCT{
  long  lParam;
  long  wParam;
  long  message;
  long  hwnd;
};

#define WH_MIN -1
#define WH_MSGFILTER -1
#define WH_JOURNALRECORD 0
#define WH_JOURNALPLAYBACK 1
#define WH_KEYBOARD 2
#define WH_GETMESSAGE 3
#define WH_CALLWNDPROC 4
#define WH_CBT 5
#define WH_SYSMSGFILTER 6
#define WH_MOUSE 7
#define WH_HARDWARE 8
#define WH_DEBUG 9
#define WH_SHELL 10
#define WH_FOREGROUNDIDLE 11
#define WH_MAX 11

#define PM_NOREMOVE 0x0
#define PM_REMOVE 0x1
#define PM_NOYIELD 0x2

//
// Calculate the byte offset of a field in a structure of type type.
// *  Language IDs.
// *
// *  The following two combinations of primary language ID and
// *  sublanguage ID have special semantics:
// *
// *    Primary Language ID   Sublanguage ID      Result
// *    -------------------   ---------------     ------------------------
// *    LANG_NEUTRAL          SUBLANG_NEUTRAL     Language neutral
// *    LANG_NEUTRAL          SUBLANG_DEFAULT     User default language
// *    LANG_NEUTRAL          SUBLANG_SYS_DEFAULT System default language
// */
//
// *  Primary language IDs.
// */
#define LANG_NEUTRAL    0x0

#define LANG_BULGARIAN  0x2
#define LANG_CHINESE    0x4
#define LANG_CROATIAN   0x1A
#define LANG_CZECH      0x5
#define LANG_DANISH     0x6
#define LANG_DUTCH      0x13
#define LANG_ENGLISH    0x9
#define LANG_FINNISH    0xB
#define LANG_FRENCH     0xC
#define LANG_GERMAN     0x7
#define LANG_GREEK      0x8
#define LANG_HUNGARIAN  0xE
#define LANG_ICELANDIC  0xF
#define LANG_ITALIAN    0x10
#define LANG_JAPANESE   0x11
#define LANG_KOREAN     0x12
#define LANG_NORWEGIAN  0x14
#define LANG_POLISH     0x15
#define LANG_PORTUGUESE 0x16
#define LANG_ROMANIAN   0x18
#define LANG_RUSSIAN    0x19
#define LANG_SLOVAK     0x1B
#define LANG_SLOVENIAN  0x24
#define LANG_SPANISH    0xA
#define LANG_SWEDISH    0x1D
#define LANG_TURKISH    0x1F

///****************************************************************
// *  Sublanguage IDs.
// *
// *  The name immediately following SUBLANG_ dictates which primary
// *  language ID that sublanguage ID can be combined with to form a
// *  valid language ID.
// */
#define SUBLANG_NEUTRAL 0x0                       // language neutral
#define SUBLANG_DEFAULT 0x1                       // user default
#define SUBLANG_SYS_DEFAULT 0x2                   // system default

#define SUBLANG_CHINESE_TRADITIONAL 0x1           // Chinese (Taiwan)
#define SUBLANG_CHINESE_SIMPLIFIED 0x2            // Chinese (PR China)
#define SUBLANG_CHINESE_HONGKONG 0x3              // Chinese (Hong Kong)
#define SUBLANG_CHINESE_SINGAPORE 0x4             // Chinese (Singapore)
#define SUBLANG_DUTCH 0x1                         // Dutch
#define SUBLANG_DUTCH_BELGIAN 0x2                 // Dutch (Belgian)
#define SUBLANG_ENGLISH_US 0x1                    // English (USA)
#define SUBLANG_ENGLISH_UK 0x2                    // English (UK)
#define SUBLANG_ENGLISH_AUS 0x3                   // English (Australian)
#define SUBLANG_ENGLISH_CAN 0x4                   // English (Canadian)
#define SUBLANG_ENGLISH_NZ 0x5                    // English (New Zealand)
#define SUBLANG_ENGLISH_EIRE 0x6                  // English (Irish)
#define SUBLANG_FRENCH 0x1                        // French
#define SUBLANG_FRENCH_BELGIAN 0x2                // French (Belgian)
#define SUBLANG_FRENCH_CANADIAN 0x3               // French (Canadian)
#define SUBLANG_FRENCH_SWISS 0x4                  // French (Swiss)
#define SUBLANG_GERMAN 0x1                        // German
#define SUBLANG_GERMAN_SWISS 0x2                  // German (Swiss)
#define SUBLANG_GERMAN_AUSTRIAN 0x3               // German (Austrian)
#define SUBLANG_ITALIAN 0x1                       // Italian
#define SUBLANG_ITALIAN_SWISS 0x2                 // Italian (Swiss)
#define SUBLANG_NORWEGIAN_BOKMAL 0x1              // Norwegian (Bokma
#define SUBLANG_NORWEGIAN_NYNORSK 0x2             // Norwegian (Nynorsk)
#define SUBLANG_PORTUGUESE 0x2                    // Portuguese
#define SUBLANG_PORTUGUESE_BRAZILIAN 0x1          // Portuguese (Brazilian)
#define SUBLANG_SPANISH 0x1                       // Spanish (Castilian)
#define SUBLANG_SPANISH_MEXICAN 0x2               // Spanish (Mexican)
#define SUBLANG_SPANISH_MODERN 0x3                // Spanish (Modern)

//Routines to convert back and forth
//between system time and file time


#define FORMAT_MESSAGE_ALLOCATE_BUFFER 0x100
#define FORMAT_MESSAGE_IGNORE_INSERTS 0x200
#define FORMAT_MESSAGE_FROM_STRING 0x400
#define FORMAT_MESSAGE_FROM_HMODULE 0x800
#define FORMAT_MESSAGE_FROM_SYSTEM 0x1000
#define FORMAT_MESSAGE_ARGUMENT_ARRAY 0x2000
#define FORMAT_MESSAGE_MAX_WIDTH_MASK 0xFF

//Code Page Default Values.
#define CP_ACP 0  // default to ANSI code page
#define CP_OEMCP 1  // default to OEM  code page

#define SECTION_QUERY 0x1
#define SECTION_MAP_WRITE 0x2
#define SECTION_MAP_READ 0x4
#define SECTION_MAP_EXECUTE 0x8
#define SECTION_EXTEND_SIZE 0x10
#define SECTION_ALL_ACCESS STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE

#define FILE_MAP_COPY SECTION_QUERY
#define FILE_MAP_WRITE SECTION_MAP_WRITE
#define FILE_MAP_READ SECTION_MAP_READ
#define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS

#define PAGE_NOACCESS          0x01
#define PAGE_READONLY          0x02
#define PAGE_READWRITE         0x04
#define PAGE_WRITECOPY         0x08
#define PAGE_EXECUTE           0x10
#define PAGE_EXECUTE_READ      0x20
#define PAGE_EXECUTE_READWRITE 0x40
#define PAGE_EXECUTE_WRITECOPY 0x80
#define PAGE_GUARD            0x100
#define PAGE_NOCACHE          0x200
#define PAGE_WRITECOMBINE     0x400
#define MEM_COMMIT           0x1000
#define MEM_RESERVE          0x2000
#define MEM_DECOMMIT         0x4000
#define MEM_RELEASE          0x8000
#define MEM_FREE            0x10000
#define MEM_PRIVATE         0x20000
#define MEM_MAPPED          0x40000
#define MEM_RESET           0x80000
#define MEM_TOP_DOWN       0x100000
#define MEM_4MB_PAGES    0x80000000
#define SEC_FILE           0x800000
#define SEC_IMAGE         0x1000000
#define SEC_VLM           0x2000000
#define SEC_RESERVE       0x4000000
#define SEC_COMMIT        0x8000000
#define SEC_NOCACHE      0x10000000
#define MEM_IMAGE         SEC_IMAGE

#define MOVEFILE_REPLACE_EXISTING 0x1
#define MOVEFILE_COPY_ALLOWED 0x2
#define MOVEFILE_DELAY_UNTIL_REBOOT 0x4

//Edit Control Messages
#define EM_GETSEL 0xB0
#define EM_SETSEL 0xB1
#define EM_GETRECT 0xB2
#define EM_SETRECT 0xB3
#define EM_SETRECTNP 0xB4
#define EM_SCROLL 0xB5
#define EM_LINESCROLL 0xB6
#define EM_SCROLLCARET 0xB7
#define EM_GETMODIFY 0xB8
#define EM_SETMODIFY 0xB9
#define EM_GETLINECOUNT 0xBA
#define EM_LINEINDEX 0xBB
#define EM_SETHANDLE 0xBC
#define EM_GETHANDLE 0xBD
#define EM_GETTHUMB 0xBE
#define EM_LINELENGTH 0xC1
#define EM_REPLACESEL 0xC2
#define EM_GETLINE 0xC4
#define EM_LIMITTEXT 0xC5
#define EM_CANUNDO 0xC6
#define EM_UNDO 0xC7
#define EM_FMTLINES 0xC8
#define EM_LINEFROMCHAR 0xC9
#define EM_SETTABSTOPS 0xCB
#define EM_SETPASSWORDCHAR 0xCC
#define EM_EMPTYUNDOBUFFER 0xCD
#define EM_GETFIRSTVISIBLELINE 0xCE
#define EM_SETREADONLY 0xCF
#define EM_SETWORDBREAKPROC 0xD0
#define EM_GETWORDBREAKPROC 0xD1
#define EM_GETPASSWORDCHAR 0xD2

//Scroll Bar Commands
#define SB_LINEUP 0
#define SB_LINELEFT 0
#define SB_LINEDOWN 1
#define SB_LINERIGHT 1
#define SB_PAGEUP 2
#define SB_PAGELEFT 2
#define SB_PAGEDOWN 3
#define SB_PAGERIGHT 3
#define SB_THUMBPOSITION 4
#define SB_THUMBTRACK 5
#define SB_TOP 6
#define SB_LEFT 6
#define SB_BOTTOM 7
#define SB_RIGHT 7
#define SB_ENDSCROLL 8

//Combo Box messages
#define CB_GETEDITSEL 0x140
#define CB_LIMITTEXT 0x141
#define CB_SETEDITSEL 0x142
#define CB_ADDSTRING 0x143
#define CB_DELETESTRING 0x144
#define CB_DIR 0x145
#define CB_GETCOUNT 0x146
#define CB_GETCURSEL 0x147
#define CB_GETLBTEXT 0x148
#define CB_GETLBTEXTLEN 0x149
#define CB_INSERTSTRING 0x14A
#define CB_RESETCONTENT 0x14B
#define CB_FINDSTRING 0x14C
#define CB_SELECTSTRING 0x14D
#define CB_SETCURSEL 0x14E
#define CB_SHOWDROPDOWN 0x14F
#define CB_GETITEMDATA 0x150
#define CB_SETITEMDATA 0x151
#define CB_GETDROPPEDCONTROLRECT 0x152
#define CB_SETITEMHEIGHT 0x153
#define CB_GETITEMHEIGHT 0x154
#define CB_SETEXTENDEDUI 0x155
#define CB_GETEXTENDEDUI 0x156
#define CB_GETDROPPEDSTATE 0x157
#define CB_FINDSTRINGEXACT 0x158
#define CB_SETLOCALE 0x159
#define CB_GETLOCALE 0x15A
#define CB_MSGMAX 0x15B

//Combo Box Notification Codes
#define CBN_ERRSPACE -1
#define CBN_SELCHANGE 1
#define CBN_DBLCLK 2
#define CBN_SETFOCUS 3
#define CBN_KILLFOCUS 4
#define CBN_EDITCHANGE 5
#define CBN_EDITUPDATE 6
#define CBN_DROPDOWN 7
#define CBN_CLOSEUP 8
#define CBN_SELENDOK 9
#define CBN_SELENDCANCEL 10

:dword MAKELONG(AX,BX)
{
  EBX<<=16;
  EAX=AX|EBX;
}
#define MAKELPARAM MAKELONG

struct WNDCLASSEX{
  long  cbSize;
  long  style;
  long  lpfnWndProc;
  long  cbClsExtra;
  long  cbWndExtra;
  long  hInstance;
  long  hIcon;
  long  hCursor;
  long  hbrBackground;
  char* lpszMenuName;
  char* lpszClassName;
  long  hIconSm;
};

/*
 * Class styles
 */
#define CS_VREDRAW          0x0001
#define CS_HREDRAW          0x0002
#define CS_DBLCLKS          0x0008
#define CS_OWNDC            0x0020
#define CS_CLASSDC          0x0040
#define CS_PARENTDC         0x0080
#define CS_NOCLOSE          0x0200
#define CS_SAVEBITS         0x0800
#define CS_BYTEALIGNCLIENT  0x1000
#define CS_BYTEALIGNWINDOW  0x2000
#define CS_GLOBALCLASS      0x4000

#define CS_IME              0x00010000

//Background Modes
#define TRANSPARENT 1
#define OPAQUE 2
#define BKMODE_LAST 2

//Listbox messages
#define LB_ADDSTRING 0x180
#define LB_INSERTSTRING 0x181
#define LB_DELETESTRING 0x182
#define LB_SELITEMRANGEEX 0x183
#define LB_RESETCONTENT 0x184
#define LB_SETSEL 0x185
#define LB_SETCURSEL 0x186
#define LB_GETSEL 0x187
#define LB_GETCURSEL 0x188
#define LB_GETTEXT 0x189
#define LB_GETTEXTLEN 0x18A
#define LB_GETCOUNT 0x18B
#define LB_SELECTSTRING 0x18C
#define LB_DIR 0x18D
#define LB_GETTOPINDEX 0x18E
#define LB_FINDSTRING 0x18F
#define LB_GETSELCOUNT 0x190
#define LB_GETSELITEMS 0x191
#define LB_SETTABSTOPS 0x192
#define LB_GETHORIZONTALEXTENT 0x193
#define LB_SETHORIZONTALEXTENT 0x194
#define LB_SETCOLUMNWIDTH 0x195
#define LB_ADDFILE 0x196
#define LB_SETTOPINDEX 0x197
#define LB_GETITEMRECT 0x198
#define LB_GETITEMDATA 0x199
#define LB_SETITEMDATA 0x19A
#define LB_SELITEMRANGE 0x19B
#define LB_SETANCHORINDEX 0x19C
#define LB_GETANCHORINDEX 0x19D
#define LB_SETCARETINDEX 0x19E
#define LB_GETCARETINDEX 0x19F
#define LB_SETITEMHEIGHT 0x1A0
#define LB_GETITEMHEIGHT 0x1A1
#define LB_FINDSTRINGEXACT 0x1A2
#define LB_SETLOCALE 0x1A5
#define LB_GETLOCALE 0x1A6
#define LB_SETCOUNT 0x1A7
#define LB_MSGMAX 0x1A8

// Get/SetWindowWord/Long offsets for use with WC_DIALOG windows
#define DWL_MSGRESULT 0
#define DWL_DLGPROC 4
#define DWL_USER 8

//GetDriveType return values
#define DRIVE_REMOVABLE 2
#define DRIVE_FIXED 3
#define DRIVE_REMOTE 4
#define DRIVE_CDROM 5
#define DRIVE_RAMDISK 6

//ShowWindow() Commands
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_MAX 10

//Old ShowWindow() Commands
#define HIDE_WINDOW 0
#define SHOW_OPENWINDOW 1
#define SHOW_ICONWINDOW 2
#define SHOW_FULLSCREEN 3
#define SHOW_OPENNOACTIVATE 4

//Identifiers for the WM_SHOWWINDOW message
#define SW_PARENTCLOSING 1
#define SW_OTHERZOOM 2
#define SW_PARENTOPENING 3
#define SW_OTHERUNZOOM 4

struct PAINTSTRUCT{
  long  hdc;
  long  fErase;
  RECT  rcPaint;
  long  fRestore;
  long  fIncUpdate;
  byte  rgbReserved[32];
};

//DrawText() Format Flags
#define DT_TOP 0x0
#define DT_LEFT 0x0
#define DT_CENTER 0x1
#define DT_RIGHT 0x2
#define DT_VCENTER 0x4
#define DT_BOTTOM 0x8
#define DT_WORDBREAK 0x10
#define DT_SINGLELINE 0x20
#define DT_EXPANDTABS 0x40
#define DT_TABSTOP 0x80
#define DT_NOCLIP 0x100
#define DT_EXTERNALLEADING 0x200
#define DT_CALCRECT 0x400
#define DT_NOPREFIX 0x800
#define DT_INTERNAL 0x1000

#define BST_UNCHECKED      0x0000
#define BST_CHECKED        0x0001
#define BST_INDETERMINATE  0x0002
#define BST_PUSHED         0x0004
#define BST_FOCUS          0x0008

#define DLL_PROCESS_ATTACH 1
#define DLL_THREAD_ATTACH  2
#define DLL_THREAD_DETACH  3
#define DLL_PROCESS_DETACH 0

//Standard Icon IDs
#define IDI_APPLICATION 32512
#define IDI_HAND 32513
#define IDI_QUESTION 32514
#define IDI_EXCLAMATION 32515
#define IDI_ASTERISK 32516

// tmPitchAndFamily flags
#define TMPF_FIXED_PITCH 0x1
#define TMPF_VECTOR 0x2
#define TMPF_DEVICE 0x8
#define TMPF_TRUETYPE 0x4

#define DEFAULT_PITCH 0
#define FIXED_PITCH 1
#define VARIABLE_PITCH 2

#define NM_FIRST                0
#define NM_OUTOFMEMORY          NM_FIRST-1
#define NM_CLICK                NM_FIRST-2    // uses NMCLICK struct
#define NM_DBLCLK               NM_FIRST-3
#define NM_RETURN               NM_FIRST-4
#define NM_RCLICK               NM_FIRST-5    // uses NMCLICK struct
#define NM_RDBLCLK              NM_FIRST-6
#define NM_SETFOCUS             NM_FIRST-7
#define NM_KILLFOCUS            NM_FIRST-8
#define NM_CUSTOMDRAW           NM_FIRST-12
#define NM_HOVER                NM_FIRST-13
#define NM_NCHITTEST            NM_FIRST-14   // uses NMMOUSE struct
#define NM_KEYDOWN              NM_FIRST-15   // uses NMKEY struct
#define NM_RELEASEDCAPTURE      NM_FIRST-16
#define NM_SETCURSOR            NM_FIRST-17   // uses NMMOUSE struct
#define NM_CHAR                 NM_FIRST-18   // uses NMCHAR struct

//Standard Cursor IDs
#define IDC_ARROW 32512
#define IDC_IBEAM 32513
#define IDC_WAIT 32514
#define IDC_CROSS 32515
#define IDC_UPARROW 32516
#define IDC_SIZE 32640
#define IDC_ICON 32641
#define IDC_SIZENWSE 32642
#define IDC_SIZENESW 32643
#define IDC_SIZEWE 32644
#define IDC_SIZENS 32645
#define IDC_SIZEALL 32646
#define IDC_NO 32648
#define IDC_APPSTARTING 32650

// dwCreationFlag values

#define DEBUG_PROCESS           0x1
#define DEBUG_ONLY_THIS_PROCESS 0x2

#define CREATE_SUSPENDED        0x4

#define DETACHED_PROCESS        0x8

#define CREATE_NEW_CONSOLE      0x10

#define NORMAL_PRIORITY_CLASS   0x20
#define IDLE_PRIORITY_CLASS     0x40
#define HIGH_PRIORITY_CLASS     0x80
#define REALTIME_PRIORITY_CLASS 0x100

#define CREATE_NEW_PROCESS_GROUP 0x200

#define CREATE_NO_WINDOW 0x8000000

// Directory Entries

#define IMAGE_DIRECTORY_ENTRY_EXPORT          0   // Export Directory
#define IMAGE_DIRECTORY_ENTRY_IMPORT          1   // Import Directory
#define IMAGE_DIRECTORY_ENTRY_RESOURCE        2   // Resource Directory
#define IMAGE_DIRECTORY_ENTRY_EXCEPTION       3   // Exception Directory
#define IMAGE_DIRECTORY_ENTRY_SECURITY        4   // Security Directory
#define IMAGE_DIRECTORY_ENTRY_BASERELOC       5   // Base Relocation Table
#define IMAGE_DIRECTORY_ENTRY_DEBUG           6   // Debug Directory
//      IMAGE_DIRECTORY_ENTRY_COPYRIGHT       7   // (X86 usage)
#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE    7   // Architecture Specific Data
#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR       8   // RVA of GP
#define IMAGE_DIRECTORY_ENTRY_TLS             9   // TLS Directory
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG    10   // Load Configuration Directory
#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT   11   // Bound Import Directory in headers
#define IMAGE_DIRECTORY_ENTRY_IAT            12   // Import Address Table
#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT   13   // Delay Load Import Descriptors
#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14   // COM Runtime descriptor

enum {
    FindExInfoStandard,
    FindExInfoMaxInfoLevel
};// FINDEX_INFO_LEVELS;

enum {
    FindExSearchNameMatch,
    FindExSearchLimitToDirectories,
    FindExSearchLimitToDevices,
    FindExSearchMaxSearchOp
};// FINDEX_SEARCH_OPS;

#define FIND_FIRST_EX_CASE_SENSITIVE   0x00000001

enum {
    GetFileExInfoStandard,
    GetFileExMaxInfoLevel
};// GET_FILEEX_INFO_LEVELS;

struct WIN32_FILE_ATTRIBUTE_DATA {
    dword dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    dword nFileSizeHigh;
    dword nFileSizeLow;
};

#define PROCESS_TERMINATE         0x0001
#define PROCESS_CREATE_THREAD     0x0002
#define PROCESS_SET_SESSIONID     0x0004
#define PROCESS_VM_OPERATION      0x0008
#define PROCESS_VM_READ           0x0010
#define PROCESS_VM_WRITE          0x0020
#define PROCESS_DUP_HANDLE        0x0040
#define PROCESS_CREATE_PROCESS    0x0080
#define PROCESS_SET_QUOTA         0x0100
#define PROCESS_SET_INFORMATION   0x0200
#define PROCESS_QUERY_INFORMATION 0x0400
#define PROCESS_ALL_ACCESS        STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xFFF

#define GWL_WNDPROC -4
#define GWL_HINSTANCE -6
#define GWL_HWNDPARENT -8
#define GWL_STYLE -16
#define GWL_EXSTYLE -20
#define GWL_USERDATA -21
#define GWL_ID -12
#define GCL_MENUNAME -8
#define GCL_HBRBACKGROUND -10
#define GCL_HCURSOR -12
#define GCL_HICON -14
#define GCL_HMODULE -16
#define GCL_CBWNDEXTRA -18
#define GCL_CBCLSEXTRA -20
#define GCL_WNDPROC -24
#define GCL_STYLE -26
#define GCW_ATOM -32

struct COPYDATASTRUCT{
  long  dwData;
  long  cbData;
  long  lpData;
};