Browse Source

* Windows unit additions by Vasil.
+ msgqueue, pm, service, winioctl header translations by Vasil.

git-svn-id: trunk@10914 -

yury 17 years ago
parent
commit
981920616f

+ 4 - 0
.gitattributes

@@ -4454,15 +4454,19 @@ packages/winceunits/src/commdlg.pp svneol=native#text/plain
 packages/winceunits/src/gpsapi.pp svneol=native#text/plain
 packages/winceunits/src/gpsapi.pp svneol=native#text/plain
 packages/winceunits/src/gx.pp svneol=native#text/plain
 packages/winceunits/src/gx.pp svneol=native#text/plain
 packages/winceunits/src/iphlpapi.pp svneol=native#text/plain
 packages/winceunits/src/iphlpapi.pp svneol=native#text/plain
+packages/winceunits/src/msgqueue.pp svneol=native#text/plain
 packages/winceunits/src/notify.pp svneol=native#text/plain
 packages/winceunits/src/notify.pp svneol=native#text/plain
 packages/winceunits/src/oleaut32.pp svneol=native#text/plain
 packages/winceunits/src/oleaut32.pp svneol=native#text/plain
+packages/winceunits/src/pm.pp svneol=native#text/plain
 packages/winceunits/src/power.pp svneol=native#text/plain
 packages/winceunits/src/power.pp svneol=native#text/plain
 packages/winceunits/src/rapi.pp svneol=native#text/plain
 packages/winceunits/src/rapi.pp svneol=native#text/plain
+packages/winceunits/src/service.pp svneol=native#text/plain
 packages/winceunits/src/shellapi.pp svneol=native#text/plain
 packages/winceunits/src/shellapi.pp svneol=native#text/plain
 packages/winceunits/src/simmgr.pp svneol=native#text/plain
 packages/winceunits/src/simmgr.pp svneol=native#text/plain
 packages/winceunits/src/tapi.pp svneol=native#text/plain
 packages/winceunits/src/tapi.pp svneol=native#text/plain
 packages/winceunits/src/todaycmn.pp svneol=native#text/plain
 packages/winceunits/src/todaycmn.pp svneol=native#text/plain
 packages/winceunits/src/windbase.pp svneol=native#text/plain
 packages/winceunits/src/windbase.pp svneol=native#text/plain
+packages/winceunits/src/winioctl.pp svneol=native#text/plain
 packages/winunits-base/Makefile svneol=native#text/plain
 packages/winunits-base/Makefile svneol=native#text/plain
 packages/winunits-base/Makefile.fpc svneol=native#text/plain
 packages/winunits-base/Makefile.fpc svneol=native#text/plain
 packages/winunits-base/fpmake.pp svneol=native#text/plain
 packages/winunits-base/fpmake.pp svneol=native#text/plain

+ 3 - 3
packages/winceunits/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/05/07]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/05/09]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
@@ -263,10 +263,10 @@ ifeq ($(FULL_TARGET),arm-wince)
 override TARGET_UNITS+=buildwinceunits
 override TARGET_UNITS+=buildwinceunits
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_IMPLICITUNITS+=aygshell commctrl commdlg iphlpapi notify oleaut32 power shellapi simmgr tapi gpsapi todaycmn windbase cesync gx
+override TARGET_IMPLICITUNITS+=aygshell commctrl commdlg iphlpapi notify oleaut32 power shellapi simmgr tapi gpsapi todaycmn windbase cesync gx winioctl msgqueue pm service
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_IMPLICITUNITS+=aygshell commctrl commdlg iphlpapi notify oleaut32 power shellapi simmgr tapi gpsapi todaycmn windbase cesync gx
+override TARGET_IMPLICITUNITS+=aygshell commctrl commdlg iphlpapi notify oleaut32 power shellapi simmgr tapi gpsapi todaycmn windbase cesync gx winioctl msgqueue pm service
 endif
 endif
 override INSTALL_BUILDUNIT=buildwinceunits
 override INSTALL_BUILDUNIT=buildwinceunits
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y

+ 1 - 1
packages/winceunits/Makefile.fpc

@@ -9,7 +9,7 @@ version=2.2.0
 [target]
 [target]
 units_wince=buildwinceunits
 units_wince=buildwinceunits
 implicitunits_wince=aygshell commctrl commdlg iphlpapi notify oleaut32 power shellapi simmgr tapi \
 implicitunits_wince=aygshell commctrl commdlg iphlpapi notify oleaut32 power shellapi simmgr tapi \
-                    gpsapi todaycmn windbase cesync gx
+                    gpsapi todaycmn windbase cesync gx winioctl msgqueue pm service
 units_win32=rapi cesync
 units_win32=rapi cesync
 
 
 [install]
 [install]

+ 1 - 1
packages/winceunits/src/buildwinceunits.pp

@@ -22,7 +22,7 @@ interface
 
 
 uses
 uses
   aygshell,commctrl,commdlg,iphlpapi,notify,oleaut32,power,shellapi,simmgr,tapi,
   aygshell,commctrl,commdlg,iphlpapi,notify,oleaut32,power,shellapi,simmgr,tapi,
-  gpsapi,todaycmn,windbase,cesync,gx;
+  gpsapi,todaycmn,windbase,cesync,gx,winioctl,msgqueue,pm,service;
 
 
 implementation
 implementation
 
 

+ 83 - 0
packages/winceunits/src/msgqueue.pp

@@ -0,0 +1,83 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2008 Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ ********************************************************************** }
+//
+// msgqueue.h - Message queue point-to-point.
+//
+
+//
+//  Microsoft Windows Mobile 6.0 for PocketPC SDK.
+//
+
+unit MsgQueue;
+
+{$CALLING cdecl}
+
+interface
+
+uses Windows;
+
+// Declarations of constants and structures transferred from winbase.h.
+
+const
+      MSGQUEUE_NOPRECOMMIT            = $00000001;
+      MSGQUEUE_ALLOW_BROKEN           = $00000002;
+      
+      MSGQUEUE_MSGALERT               = $00000001;
+
+
+type
+     MSGQUEUEOPTIONS_OS = record
+       dwSize:DWORD;                           // size of the structure
+       dwFlags:DWORD;                          // behavior of message queue
+       dwMaxMessages:DWORD;                    // max # of msgs in queue
+       cbMaxMessage:DWORD;                     // max size of msg
+       bReadAccess:BOOL;                      // read access requested
+     end;
+     MSGQUEUEOPTIONS = MSGQUEUEOPTIONS_OS;
+     LPMSGQUEUEOPTIONS = ^MSGQUEUEOPTIONS_OS;
+     PMSGQUEUEOPTIONS = ^MSGQUEUEOPTIONS_OS;
+
+type
+     MSGQUEUEINFO = record
+       dwSize:DWORD;                           // size of structure
+       dwFlags:DWORD;                          // behavior of message queue
+       dwMaxMessages:DWORD;                    // max # of msgs in queue
+       cbMaxMessage:DWORD;                     // max size of msg
+       dwCurrentMessages:DWORD;                // # of message in queue currently
+       dwMaxQueueMessages:DWORD;               // high water mark of queue
+       wNumReaders:word;                      // # of readers
+       wNumWriters:word;                      // # of writes
+     end;
+     PMSGQUEUEINFO = ^MSGQUEUEINFO;
+     LPMSGQUEUEINFO = ^MSGQUEUEINFO;
+
+     
+function CreateMsgQueue(lpName:LPCWSTR; lpOptions:LPMSGQUEUEOPTIONS):HANDLE; external KernelDLL name 'CreateMsgQueue'; // index 111
+function OpenMsgQueue(hSrcProc:HANDLE; hMsgQ:HANDLE; lpOptions:LPMSGQUEUEOPTIONS):HANDLE; external KernelDLL name 'OpenMsgQueue'; // index 116
+function ReadMsgQueue(hMsgQ:HANDLE;
+                      lpBuffer:LPVOID;
+                      cbBufferSize:DWORD;
+                      lpNumberOfBytesRead:LPDWORD;
+                      dwTimeout:DWORD;
+                      pdwFlags:LPDWORD):BOOL; external KernelDLL name 'ReadMsgQueue'; // index 112
+function WriteMsgQueue(hMsgQ:HANDLE;
+                       lpBuffer:LPVOID;
+                       cbDataSize:DWORD;
+                       dwTimeout:DWORD;
+                       dwFlags:DWORD):BOOL; external KernelDLL name 'WriteMsgQueue'; // index 113
+function GetMsgQueueInfo(hMsgQ:HANDLE; lpInfo:LPMSGQUEUEINFO):BOOL; external KernelDLL name 'GetMsgQueueInfo'; // index 114
+function CloseMsgQueue(hMsgQ:HANDLE):BOOL; external KernelDLL name 'CloseMsgQueue'; // index 115
+
+implementation
+
+end.

+ 363 - 0
packages/winceunits/src/pm.pp

@@ -0,0 +1,363 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2008 Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ ********************************************************************** }
+//
+// Module Name:
+//
+//     pm.h
+//
+// Abstract:
+//
+//     Definitions and API for the WCE Power Manager component.
+//
+
+//
+//  Microsoft Windows Mobile 6.0 for PocketPC SDK.
+//
+
+unit PM;
+
+{$CALLING cdecl}
+
+interface
+
+uses Windows, WinIOCtl;
+
+//**********************************************************************
+// WinCE Device Interface GUIDs for Power Manager controlled devices.
+// NEVER CHANGE THESE VALUES! They indicate that a device is
+// power manageable. The device MUST expose an appropriate class
+// via the IClass registry key or the AdvertiseInterface() API to
+// receive power management IOCTLs.  For example,
+//   "IClass"=multi_sz:"{A32942B7-920C-486b-B0E6-92A702A99B35}"
+// OEMs may define other classes in addition to the ones listed here.
+//**********************************************************************
+const
+      PMCLASS_GENERIC_DEVICE          = '{A32942B7-920C-486B-B0E6-92A702A99B35}';
+      PMCLASS_NDIS_MINIPORT           = '{98C5250D-C29A-4985-AE5F-AFE5367E5006}';
+      PMCLASS_BLOCK_DEVICE            = '{8DD679CE-8AB4-43C8-A14A-EA4963FAA715}';
+      PMCLASS_DISPLAY                 = '{EB91C7C9-8BF6-4A2D-9AB8-69724EED97D1}';
+
+// backwards compatibility definitions from the PM's CE .NET release
+      DEVCLASS_POWER_MANAGER_STRING   = PMCLASS_GENERIC_DEVICE;
+      DEVCLASS_POWER_MANAGER_GUID:GUID = (D1: $A32942B7; D2: $920C; D3: $486B; D4: ($B0, $E6, $92, $A7, $02, $A9, $9B, $35));
+//    DEVCLASS_POWER_MANAGER_GUID:GUID = '{A32942B7-920C-486B-B0E6-92A702A99B35));
+
+
+//*****************************************************************************
+// D E F I N E S
+//*****************************************************************************
+
+// Power Manager's System Power key
+const
+      PWRMGR_REG_KEY           = 'SYSTEM\CurrentControlSet\Control\Power';
+      PM_SUPPORT_PB_RELEASE    = 'SupportPowerButtonRelease';
+
+//
+// System Power (Source/State/Option) Flags
+//
+
+// upper bytes: common power state bits
+function POWER_STATE(f:DWORD):DWORD;                      // power state mask
+
+const
+
+
+      POWER_STATE_ON           = $00010000;        // on state
+      POWER_STATE_OFF          = $00020000;        // no power, full off
+      POWER_STATE_CRITICAL     = $00040000;        // critical off
+      POWER_STATE_BOOT         = $00080000;        // boot state
+      POWER_STATE_IDLE         = $00100000;        // idle state
+      POWER_STATE_SUSPEND      = $00200000;        // suspend state
+      POWER_STATE_UNATTENDED   = $00400000;        // Unattended state.
+      POWER_STATE_RESET        = $00800000;        // reset state
+      POWER_STATE_USERIDLE     = $01000000;        // user idle state
+      POWER_STATE_BACKLIGHTON  = $02000000;        // device scree backlight on
+      POWER_STATE_PASSWORD     = $10000000;        // This state is password protected.
+
+      PM_DEFAULT_SZ            = 'Default';
+      PM_FLAGS_SZ              = 'Flags';
+      MAX_STATE_NAMEL          = MAX_PATH;    // max system power state name length
+
+//
+// Power Requirement Flags
+//
+const
+      POWER_NAME              = $00000001; // default
+      POWER_FORCE             = $00001000;
+      POWER_DUMPDW            = $00002000;// Calling CaptureDumpFileOnDevice() before entering this state.
+
+//
+// POWER IOCTLS
+//
+// We are NOT APCI, we just borrow this unused code from winioctl.h
+const
+      FILE_DEVICE_POWER   = FILE_DEVICE_ACPI;
+
+{
+Required
+InBuf:  PPOWER_RELATIONSHIP - defines the target device for parent/bus drivers, else NULL
+OutBuf: PPOWER_CAPABILITIES - defines the devices power caps
+
+If a driver fails this ioctl the PM assumes the target driver does not support power ioctls.
+}
+const
+      IOCTL_POWER_CAPABILITIES = (FILE_DEVICE_POWER shl 16) or ($400 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+{ ++
+Required
+InBuf:  PPOWER_RELATIONSHIP   - defines the target device for parent/bus drivers, else NULL
+OutBuf: PCEDEVICE_POWER_STATE - returns the device's current state (Dx).
+
+PM will only send this ioctl to drivers that support the power ioctls.
+-- }
+const
+      IOCTL_POWER_GET = (FILE_DEVICE_POWER shl 16) or ($401 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+{ ++
+Required
+InBuf:  PPOWER_RELATIONSHIP   - defines the target device for parent/bus drivers, else NULL
+OutBuf: PCEDEVICE_POWER_STATE - device state (Dx) in which to put the device.
+
+If the driver does not support the proposed Dx then it should write it's adjusted Dx
+into the OutBuf (Dx).
+
+PM will only send this ioctl to drivers that support the power ioctls.
+-- }
+const
+      IOCTL_POWER_SET = (FILE_DEVICE_POWER shl 16) or ($402 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+{++
+Required
+InBuf:  PPOWER_RELATIONSHIP   - defines the target device for parent/bus drivers, else NULL
+OutBuf: PCEDEVICE_POWER_STATE - device state (Dx) that the system is querying for a
+                                pending IOCTL_POWER_SET operation.
+
+To veto the query the driver should write PwrDeviceUnspecified (-1)
+into the OutBuf (Dx), else PM assumes the driver accepted.
+
+PM will only send this ioctl to drivers that support the power ioctls.
+-- }
+const
+      IOCTL_POWER_QUERY = (FILE_DEVICE_POWER shl 16) or ($403 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+{
+Required
+InBuf:  NULL
+OutBuf: NULL
+
+PM does not care the return value from this IOCTL.   It's there to let the Parent device
+to register all devices it controls.
+}
+const
+      IOCTL_REGISTER_POWER_RELATIONSHIP = (FILE_DEVICE_POWER shl 16) or ($406 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//*****************************************************************************
+// T Y P E D E F S
+//*****************************************************************************
+
+//
+// Device Power States
+//
+type
+     _CEDEVICE_POWER_STATE = (PwrDeviceUnspecified := -1,
+                              D0 := 0, // Full On: full power,  full functionality
+                              D1,     // Low Power On: fully functional at low power/performance
+                              D2,     // Standby: partially powered with automatic wake
+                              D3,     // Sleep: partially powered with device initiated wake
+                              D4,     // Off: unpowered
+                              PwrDeviceMaximum
+                             );
+     CEDEVICE_POWER_STATE = _CEDEVICE_POWER_STATE;
+     PCEDEVICE_POWER_STATE = ^_CEDEVICE_POWER_STATE;
+
+function DX_MASK(Dx:DWORD):DWORD;
+
+function VALID_DX(dx:DWORD):BOOL;
+
+//
+// Device or OAL Power Capabilities
+//
+type
+     _POWER_CAPABILITIES = record
+       DeviceDx:UCHAR;
+       WakeFromDx:UCHAR;
+       InrushDx:UCHAR;
+       Power:array[0..DWORD(PwrDeviceMaximum)-1] of DWORD;
+       Latency:array[0..DWORD(PwrDeviceMaximum)-1] of DWORD;
+       Flags:DWORD;
+     end;
+     POWER_CAPABILITIES = _POWER_CAPABILITIES;
+     PPOWER_CAPABILITIES = ^_POWER_CAPABILITIES;
+
+const
+      POWER_CAP_PARENT        = $00000001;      // parent/bus driver
+
+//
+// Defines the target of IOCTL_POWER_Xxx commands to parent/bus drivers
+// if there is a relationship established via RegisterPowerRelationship.
+//
+type
+     _POWER_RELATIONSHIP = record
+       hParent:HANDLE;    // Handle to parent node
+       pwsParent:LPCWSTR;  // Named parent node, e.g. "NDS0:"
+       hChild:HANDLE;     // Handle to child node, returned from RegisterPowerRelationship
+       pwsChild:LPCWSTR;   // Named child node, e.g. "NE20001"
+     end;
+     POWER_RELATIONSHIP = _POWER_RELATIONSHIP;
+     PPOWER_RELATIONSHIP = ^_POWER_RELATIONSHIP;
+
+
+//
+// Power Broadcast Types -- there are up to 32 of these
+//
+const
+      PBT_TRANSITION          = $00000001;  // broadcast specifying system power state transition
+      PBT_RESUME              = $00000002;  // broadcast notifying a resume, specifies previous state
+      PBT_POWERSTATUSCHANGE   = $00000004;  // power supply switched to/from AC/DC
+      PBT_POWERINFOCHANGE     = $00000008;  // some system power status field has changed
+
+      PBT_SUSPENDKEYPRESSED   = $00000100;  // Suspend Key has been pressed.
+
+// OEMS may define power notifications starting with this ID and
+// going up by powers of 2.
+      PBT_OEMBASE             = $00010000;
+
+// This bitmask indicates that an application would like to receive all
+// types of power notifications.
+const
+      POWER_NOTIFY_ALL        = $FFFFFFFF;
+
+//
+// Power Broadcast -- this is a variable length structure.
+//
+type
+     _POWER_BROADCAST  = record
+       _Message:DWORD;    // one of PBT_Xxx
+       Flags:DWORD;      // one of POWER_STATE_Xxx
+       Length:DWORD;     // byte count of data starting at SystemPowerStateName
+       SystemPowerState:array[0..0] of WideChar;    // variable length field, must be smaller than MAX_PATH + 1
+     end;
+     POWER_BROADCAST = _POWER_BROADCAST;
+     PPOWER_BROADCAST = ^_POWER_BROADCAST;
+
+// This structure is used instead of a string name (SystemPowerState) in
+// the POWER_BROADCAST, if the broadcast is of type PBT_POWERINFOCHANGE.
+//
+// For example:
+//  PPOWER_BROADCAST ppb;
+//  PPOWER_BROADCAST_POWER_INFO ppbpi =
+//        (PPOWER_BROADCAST_POWER_INFO) ppb->SystemPowerState;
+//
+type
+     _POWER_BROADCAST_POWER_INFO = record
+      // levels available in battery flag fields, see BatteryDrvrGetLevels()
+       dwNumLevels:DWORD;
+
+      // see GetSystemPowerStatusEx2()
+       dwBatteryLifeTime:DWORD;
+       dwBatteryFullLifeTime:DWORD;
+       dwBackupBatteryLifeTime:DWORD;
+       dwBackupBatteryFullLifeTime:DWORD;
+       bACLineStatus:byte;
+       bBatteryFlag:byte;
+       bBatteryLifePercent:byte;
+       bBackupBatteryFlag:byte;
+       bBackupBatteryLifePercent:byte;
+     end;
+     POWER_BROADCAST_POWER_INFO = _POWER_BROADCAST_POWER_INFO;
+     PPOWER_BROADCAST_POWER_INFO = ^_POWER_BROADCAST_POWER_INFO;
+
+//*****************************************************************************
+// P R O T O S
+//*****************************************************************************
+function GetSystemPowerState(pBuffer:LPWSTR; dwBufChars:DWORD; pdwFlags:PDWORD):DWORD; external KernelDLL name 'GetSystemPowerState'; // index 15E
+
+function SetSystemPowerState(pwsSystemState:LPCWSTR; StateFlags:DWORD; Options:DWORD):DWORD; external KernelDLL name 'SetSystemPowerState'; // index 15F
+
+function SetPowerRequirement(pvDevice:PVOID;
+                             DeviceState:CEDEVICE_POWER_STATE;
+                             DeviceFlags:ULONG;
+                             pvSystemState:PVOID;
+                             StateFlags:ULONG):HANDLE; external KernelDLL name 'SetPowerRequirement'; // index 160
+
+function ReleasePowerRequirement(hPowerReq:HANDLE):DWORD; external KernelDLL name 'ReleasePowerRequirement'; // index 161
+
+function RequestPowerNotifications(hMsgQ:HANDLE; Flags:DWORD):HANDLE; external KernelDLL name 'RequestPowerNotifications'; // index 162
+
+function StopPowerNotifications(h:HANDLE):DWORD; external KernelDLL name 'StopPowerNotifications'; // index 163
+
+function DevicePowerNotify(pvDevice:PVOID;	DeviceState:CEDEVICE_POWER_STATE; Flags:DWORD):DWORD; external KernelDLL name 'DevicePowerNotify'; // index 164
+
+function RegisterPowerRelationship(pvParent:PVOID;
+                                   pvChild:PVOID;
+                                   pCaps:PPOWER_CAPABILITIES;
+                                   Flags:DWORD):HANDLE; external KernelDLL name 'RegisterPowerRelationship'; // index 165
+
+function ReleasePowerRelationship(hChild:HANDLE):DWORD; external KernelDLL name 'ReleasePowerRelationship'; // index 166
+
+function SetDevicePower(pvDevice:PVOID; dwDeviceFlags:DWORD; dwState:CEDEVICE_POWER_STATE):DWORD; external KernelDLL name 'SetDevicePower'; // index 167
+
+function GetDevicePower(pvDevice:PVOID; dwDeviceFlags:DWORD; pdwState:PCEDEVICE_POWER_STATE):DWORD; external KernelDLL name 'GetDevicePower'; // index 168
+
+//*** Begin of pmpolicy.h declarations
+
+//
+// pmpolicy.h
+//
+//
+// This routine contains definitions and APIs for communicating with a platform-specific
+// power policy manager.
+//
+
+// notification messages
+const
+      PPN_REEVALUATESTATE             = $0001;  // dwData is reserved, use 0
+      PPN_POWERCHANGE                 = $0002;  // dwData is reserved, use 0
+      PPN_UNATTENDEDMODE              = $0003;  // dwData is TRUE or FALSE
+      PPN_SUSPENDKEYPRESSED           = $0004;  // dwData is reserved. use 0
+      PPN_SUSPENDKEYRELEASED          = $0005;  // dwData is reserved. use 0
+      PPN_APPBUTTONPRESSED            = $0006;  // dwData is reserved. use 0
+      PPN_POWERBUTTONPRESSED          = PPN_SUSPENDKEYPRESSED;
+
+// OEMs can define values higher than this (as PPN_OEMBASE+0, +1, etc.)
+const
+      PPN_OEMBASE                     = $10000;
+
+// This routine notifies the power policy manager of events it needs in order to
+// implement the OEM's power policy.  The dwMessage parameter is one of the PPN_
+// values (or an OEM-defined one).  The dwData parameter is a 32-bit value whose
+// interpretation varies with the notification message.  A return value of TRUE
+// indicates success.
+function PowerPolicyNotify(dwMessage:DWORD; dwData:DWORD):BOOL; external KernelDLL name 'PowerPolicyNotify'; // index 169
+
+//*** End of pmpolicy.h declarations
+
+implementation
+
+// upper bytes: common power state bits
+function POWER_STATE(f:DWORD):DWORD; inline;
+begin
+  POWER_STATE:=f and $FFFF0000;
+end;
+
+function DX_MASK(Dx:DWORD):DWORD; inline;
+begin
+  DX_MASK:=$00000001 shl Dx;
+end;
+
+function VALID_DX(dx:DWORD):BOOL; inline;
+begin
+  VALID_DX:=(dx>DWORD(PwrDeviceUnspecified)) and (dx<DWORD(PwrDeviceMaximum));
+end;
+
+end.

+ 298 - 0
packages/winceunits/src/service.pp

@@ -0,0 +1,298 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2008 Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ ********************************************************************** }
+{
+service.h
+
+Abstract:
+    Defines programming model for Windows CE Services
+
+Notes:
+}
+
+//
+//  Microsoft Windows Mobile 6.0 for PocketPC SDK.
+//
+
+unit service;
+
+{$CALLING cdecl}
+
+interface
+
+uses Windows, WinIOCtl;
+
+//
+//  Return codes
+//
+const
+      SERVICE_SUCCESS               = 0;
+
+//
+//  Service states
+//
+const
+      SERVICE_STATE_OFF           = 0;
+      SERVICE_STATE_ON            = 1;
+      SERVICE_STATE_STARTING_UP   = 2;
+      SERVICE_STATE_SHUTTING_DOWN = 3;
+      SERVICE_STATE_UNLOADING     = 4;
+      SERVICE_STATE_UNINITIALIZED = 5;
+      SERVICE_STATE_UNKNOWN       = $FFFFFFFF;
+
+const
+//
+// Service startup state (value passed on xxx_Init())
+//
+      SERVICE_INIT_STARTED  = $00000000;
+// Service is a super-service, should not spin its own accept() threads.
+      SERVICE_INIT_STOPPED  = $00000001;
+// Service is being run in an isolated services.exe.  Interprocess communication
+// via IOCTLs or streaming interface is not supported in this configuration.
+      SERVICE_INIT_STANDALONE = $00000002;
+
+// 
+// Service may need to know whether it was called from device.exe or services.exe or elsewhere.
+//
+const
+      SERVICE_CALLER_PROCESS_SERVICES_EXE      = 1;
+      SERVICE_CALLER_PROCESS_DEVICE_EXE        = 2;
+                        SERVICE_CALLER_PROCESS_OTHER_EXE         = 100;
+
+      SERVICE_SERVICES_EXE_PROCNAME            = 'services.exe';
+      SERVICE_DEVICE_EXE_PROCNAME              = 'device.exe';
+
+
+type
+     _ServiceEnumInfo = record
+        szPrefix:array[0..5] of WideChar;
+          szDllName:PWideChar;
+          hServiceHandle:HANDLE;
+          dwServiceState:DWORD;   // one of SERVICE_STATE_XXX values above.
+     end;
+     ServiceEnumInfo = _ServiceEnumInfo;
+
+
+// Called from service on initialization to determine where it's running from
+procedure SERVICE_FIND_CALLER(var callerProc:DWORD); 
+
+//
+//  Service is interfaced via series of IOCTL calls that define service life cycle.
+//  Actual implementation is service-specific.
+//
+
+//
+//  Start the service that has been in inactive state. Return code: SERVICE_SUCCESS or error code.
+//
+const
+      IOCTL_SERVICE_START     = (FILE_DEVICE_SERVICE shl 16) or (1 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Stop service, but do not unload service's DLL
+//
+      IOCTL_SERVICE_STOP       = (FILE_DEVICE_SERVICE shl 16) or (2 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Refresh service's state from registry or other configuration storage
+//
+      IOCTL_SERVICE_REFRESH   = (FILE_DEVICE_SERVICE shl 16) or (3 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Have service configure its registry for auto-load
+//
+      IOCTL_SERVICE_INSTALL   = (FILE_DEVICE_SERVICE shl 16) or (4 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Remove registry configuration
+//
+      IOCTL_SERVICE_UNINSTALL = (FILE_DEVICE_SERVICE shl 16) or (5 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Unload the service which should be stopped.
+//
+      IOCTL_SERVICE_UNLOAD    = (FILE_DEVICE_SERVICE shl 16) or (6 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Supply a configuration or command string and code to the service.
+//
+      IOCTL_SERVICE_CONTROL   = (FILE_DEVICE_SERVICE shl 16) or (7 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Return service status.
+//
+      IOCTL_SERVICE_STATUS    = (FILE_DEVICE_SERVICE shl 16) or (8 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Set service's debug zone mask (parameter is sizeof(DWORD) and contains the mask)
+//
+      IOCTL_SERVICE_DEBUG     = (FILE_DEVICE_SERVICE shl 16) or (9 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+//  Toggle service's console on/off (string "on" on no parameters is ON, "off" means off)
+//
+      IOCTL_SERVICE_CONSOLE   = (FILE_DEVICE_SERVICE shl 16) or (10 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+// Notify service a service request has arrived.  Input contains connected socket.
+//
+      IOCTL_SERVICE_REGISTER_SOCKADDR   = (FILE_DEVICE_SERVICE shl 16) or (11 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+// Notify service a service request has arrived.  For now all sockets associated with service will be closed at once.
+//
+      IOCTL_SERVICE_DEREGISTER_SOCKADDR = (FILE_DEVICE_SERVICE shl 16) or (12 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+// Notify service a another socket has bound to it.  Input contains an accepted socket.
+//
+      IOCTL_SERVICE_CONNECTION = (FILE_DEVICE_SERVICE shl 16) or (13 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+// Service has finished initial control setup.  Ready to start.
+//
+      IOCTL_SERVICE_STARTED    = (FILE_DEVICE_SERVICE shl 16) or (14 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+// Service is called with IOCTL_SERVICE_CAN_DEINIT immediatly before xxx_Deinit is called during DeregisterService.
+// If xxx_IOControl returns TRUE and sets buffer in pBufOut to zero, service instance will remain loaded and
+// xxx_Deinit will not be called.
+//
+      IOCTL_SERVICE_QUERY_CAN_DEINIT   = (FILE_DEVICE_SERVICE shl 16) or (15 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+// If iphlpapi is present, services receive this notification when table that
+// maps IP addresses changes.
+// Input contains PIP_ADAPTER_ADDRESSES retrieved from a call to GetAdaptersAddresses().
+// As soon as the service returns from this call, this buffer is not valid.  The buffer
+// must not be pointed to and it MUST NOT BE COPIED (because internally it has pointers
+// to other structures inside it).  If this data is required after the service returns,
+// the service must make its own call to GetAdaptersAddresses().
+      IOCTL_SERVICE_NOTIFY_ADDR_CHANGE  = (FILE_DEVICE_SERVICE shl 16) or (16 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+// Services.exe supports a set of callbacks that can only be called from a running service (not API).
+// pBufIn data structure contains a pointer to ServiceCallbackFunctions data structure
+// IOCTL_SERVICE_CALLBACKS will sent to service during its initial load, and only if there
+// are supported callbacks for service's mode of operation.
+//
+      IOCTL_SERVICE_CALLBACK_FUNCTIONS  = (FILE_DEVICE_SERVICE shl 16) or (17 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+
+//
+// Service returns a DWORD containing a set of flags that specify what options it supports.
+// The meaning of the flags is service specific.
+//
+      IOCTL_SERVICE_SUPPORTED_OPTIONS   = (FILE_DEVICE_SERVICE shl 16) or (18 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+
+//
+// Service is called from services.exe cmd line with arguments passed into it.
+// (i.e. "services command HTP0: Arg1 Arg2 Arg3...")
+// Args will be passed to service as ServicesExeCommandLineParams struct as the pBufIn paramater.
+// In pBufOut paramater services may put a WCHAR* string, which will be displayed to command line user.
+//
+      IOCTL_SERVICE_COMMAND_LINE_PARAMS = (FILE_DEVICE_SERVICE shl 16) or (19 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+//
+// If a cmd line user of services.exe queries it for help on a particular service
+// (i.e. "services help HTP0:") then this IOCTL will be passed to the service.  If
+// the service supports command line help, it should return a WCHAR* to be displayed
+// to the user in pBufOut.
+
+      IOCTL_SERVICE_COMMAND_LINE_HELP = (FILE_DEVICE_SERVICE shl 16) or (20 shl 2) or METHOD_BUFFERED or (FILE_ANY_ACCESS shl 14);
+
+
+
+// A service will be called with IOCTL_SERVICE_CALLBACKS and a pointer to this struct
+// on startup potentially.  Note that only functions that are supported for a service's
+// mode of operation will be set.  It is possible that function pointers will be NULL.
+type
+      PFN_SERVICE_SHUTDOWN = procedure; cdecl;
+
+type
+     _ServicesExeCallbackFunctions = record
+        // Only set when service is running in context SERVICE_INIT_STANDALONE, i.e.
+         // in its own copy of services.exe.  Service calls this function to request itself
+      // to be unloaded and the services.exe process to exit.  For typical scenario
+      // (no SERVICE_INIT_STANDALONE), use DeregisterService() API to cause service to be unloaded.
+        pfnServiceShutdown:PFN_SERVICE_SHUTDOWN;
+     end;
+     ServicesExeCallbackFunctions = _ServicesExeCallbackFunctions;
+
+const
+      SERVICES_EXE_MAX_CMD_LINE_OPTIONS        = 16;
+
+type
+     _ServicesExeCommandLineParams = record
+       dwArgs:DWORD;
+          ppwszArgs:array[0..SERVICES_EXE_MAX_CMD_LINE_OPTIONS-1] of WideChar;
+     end;
+     ServicesExeCommandLineParams = _ServicesExeCommandLineParams;
+
+
+function ActivateService(lpszDevKey:LPCWSTR; dwClientInfo:DWORD):HANDLE; external KernelDLL name 'ActivateService'; // index 16A
+function RegisterService(lpszType:LPCWSTR; dwIndex:DWORD; lpszLib:LPCWSTR; dwInfo:DWORD):HANDLE; external KernelDLL name 'RegisterService'; // index 16B
+function DeregisterService(hService:HANDLE):BOOL; external KernelDLL name 'DeregisterService'; // index 16C
+// void CloseAllServiceHandles(HANDLE proc);  // not supported
+function CreateServiceHandle(lpNew:LPCWSTR; dwAccess:DWORD; dwShareMode:DWORD; hProc:HANDLE):HANDLE; external KernelDLL name 'CreateServiceHandle'; // index 16E
+function GetServiceByIndex(dwIndex:DWORD; lpFindFileData:LPWIN32_FIND_DATA):BOOL; external KernelDLL name 'GetServiceByIndex'; // index 16F
+function ServiceIoControl(hService:HANDLE;
+                          dwIoControlCode:DWORD;
+                          lpInBuf:LPVOID;
+                          nInBufSize:DWORD;
+                          lpOutBuf:LPVOID;
+                          nOutBufSize:DWORD;
+                          lpBytesReturned:LPDWORD;
+                          lpOverlapped:LPOVERLAPPED):BOOL; external KernelDLL name 'ServiceIoControl'; // index 170
+
+{$IF DEFINED(_WINSOCKAPI_) OR DEFINED(_WINSOCK2API_)}
+function ServiceAddPort(hService:HANDLE; pSockAddr:LPSOCKADDR; cbSockAddr:integer; iProtocol:integer; szRegWritePath:PWideChar):BOOL; external KernelDLL name 'ServiceAddPort'; // index 171
+function ServiceClosePort(hService:HANDLE; pSockAddr:LPSOCKADDR; cbSockAddr:integer; iProtocol:integer; fRemoveFromRegistry:BOOL):BOOL; external KernelDLL name 'ServiceClosePort'; // index 175
+{$ELSE}
+function ServiceAddPort(hService:HANDLE; pSockAddr:LPVOID{ref. to LPSOCKADDR}; cbSockAddr:integer; iProtocol:integer; szRegWritePath:PWideChar):BOOL; external KernelDLL name 'ServiceAddPort'; // index 171
+function ServiceClosePort(hService:HANDLE; pSockAddr:LPVOID{ref. to LPSOCKADDR}; cbSockAddr:integer; iProtocol:integer; fRemoveFromRegistry:BOOL):BOOL; external KernelDLL name 'ServiceClosePort'; // index 175
+{$ENDIF}
+
+function ServiceUnbindPorts(hService:HANDLE):BOOL; external KernelDLL name 'ServiceUnbindPorts'; // index 172
+function EnumServices(pBuffer:PBYTE; pdwServiceEntries:LPDWORD; pdwBufferLen:LPDWORD):BOOL; external KernelDLL name 'EnumServices'; // index 173
+function GetServiceHandle(szPrefix:LPWSTR; szDllName:LPWSTR; pdwDllBuf:LPDWORD):HANDLE; external KernelDLL name 'GetServiceHandle'; // index 174
+
+{
+#if defined(WINCEOEM) && defined(UNDER_CE)
+#ifdef WINCEMACRO
+#include <mservice.h>
+#endif
+#endif
+}
+implementation
+
+// Called from service on initialization to determine where it's running from
+procedure SERVICE_FIND_CALLER(var callerProc:DWORD); inline;
+var szCallerModName:array[0..MAX_PATH-1] of WideChar;
+begin
+  if GetModuleFileName(HINST(GetCurrentProcess),szCallerModName,SizeOf(szCallerModName))<>0
+  then begin
+    if wcsstr(szCallerModName,SERVICE_DEVICE_EXE_PROCNAME)<>nil then begin
+       callerProc:=SERVICE_CALLER_PROCESS_DEVICE_EXE;
+    end else begin
+      if wcsstr(szCallerModName,SERVICE_SERVICES_EXE_PROCNAME)<>nil then begin
+         callerProc:=SERVICE_CALLER_PROCESS_SERVICES_EXE;
+      end else begin
+        callerProc:=SERVICE_CALLER_PROCESS_OTHER_EXE;
+      end;
+    end;
+  end else begin
+    callerProc:=SERVICE_CALLER_PROCESS_OTHER_EXE;
+  end;
+end;
+
+end.

+ 153 - 0
packages/winceunits/src/winioctl.pp

@@ -0,0 +1,153 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2008 Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ ********************************************************************** }
+// *
+// * Module Name: winioctl.h
+// * Abstract: this module defines device IO control codes.
+// *
+
+//
+//  Microsoft Windows Mobile 6.0 for PocketPC SDK.
+//
+
+unit WinIOCtl;
+
+interface
+
+uses Windows;
+
+// The definition below is intentionally left SO FAR because some of useful
+// constants or macros declared here may be redeclared elsewhere by pure accident.
+{$IFNDEF _WINIOCTL_}
+  {$DEFINE _WINIOCTL_}
+{$ENDIF _WINIOCTL_}
+
+type
+     DEVICE_TYPE = ULONG;
+
+//
+// Macro definition for defining IOCTL and FSCTL function control codes.  Note
+// that function codes 0-2047 are reserved for Microsoft Corporation, and
+// 2048-4095 are reserved for customers.
+//
+function CTL_CODE(_DeviceType:DEVICE_TYPE; _Function:DWORD; _Method:DWORD; _Access:DWORD):DWORD;
+{ This macro was declared as:
+#define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
+    ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
+)
+}
+
+
+//
+// Define the method codes for how buffers are passed for I/O and FS controls
+//
+const
+      METHOD_BUFFERED                 = 0;
+      METHOD_IN_DIRECT                = 1;
+      METHOD_OUT_DIRECT               = 2;
+      METHOD_NEITHER                  = 3;
+
+//
+// Define the access check value for any access
+//
+//
+// The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
+// ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
+// constants *MUST* always be in sync.
+//
+const
+      FILE_ANY_ACCESS                 = 0;
+      FILE_READ_ACCESS                = $0001;    // file & pipe
+      FILE_WRITE_ACCESS               = $0002;    // file & pipe
+
+//
+// Define the various device type values.  Note that values used by Microsoft
+// Corporation are in the range 0-32767, and 32768-65535 are reserved for use
+// by customers.
+//
+const
+      FILE_DEVICE_BEEP                = $00000001;
+      FILE_DEVICE_CD_ROM              = $00000002;
+      FILE_DEVICE_CD_ROM_FILE_SYSTEM  = $00000003;
+      FILE_DEVICE_CONTROLLER          = $00000004;
+      FILE_DEVICE_DATALINK            = $00000005;
+      FILE_DEVICE_DFS                 = $00000006;
+      FILE_DEVICE_DISK                = $00000007;
+      FILE_DEVICE_DISK_FILE_SYSTEM    = $00000008;
+      FILE_DEVICE_FILE_SYSTEM         = $00000009;
+      FILE_DEVICE_INPORT_PORT         = $0000000a;
+      FILE_DEVICE_KEYBOARD            = $0000000b;
+      FILE_DEVICE_MAILSLOT            = $0000000c;
+      FILE_DEVICE_MIDI_IN             = $0000000d;
+      FILE_DEVICE_MIDI_OUT            = $0000000e;
+      FILE_DEVICE_MOUSE               = $0000000f;
+      FILE_DEVICE_MULTI_UNC_PROVIDER  = $00000010;
+      FILE_DEVICE_NAMED_PIPE          = $00000011;
+      FILE_DEVICE_NETWORK             = $00000012;
+      FILE_DEVICE_NETWORK_BROWSER     = $00000013;
+      FILE_DEVICE_NETWORK_FILE_SYSTEM = $00000014;
+      FILE_DEVICE_NULL                = $00000015;
+      FILE_DEVICE_PARALLEL_PORT       = $00000016;
+      FILE_DEVICE_PHYSICAL_NETCARD    = $00000017;
+      FILE_DEVICE_PRINTER             = $00000018;
+      FILE_DEVICE_SCANNER             = $00000019;
+      FILE_DEVICE_SERIAL_MOUSE_PORT   = $0000001a;
+      FILE_DEVICE_SERIAL_PORT         = $0000001b;
+      FILE_DEVICE_SCREEN              = $0000001c;
+      FILE_DEVICE_SOUND               = $0000001d;
+      FILE_DEVICE_STREAMS             = $0000001e;
+      FILE_DEVICE_TAPE                = $0000001f;
+      FILE_DEVICE_TAPE_FILE_SYSTEM    = $00000020;
+      FILE_DEVICE_TRANSPORT           = $00000021;
+      FILE_DEVICE_UNKNOWN             = $00000022;
+      FILE_DEVICE_VIDEO               = $00000023;
+      FILE_DEVICE_VIRTUAL_DISK        = $00000024;
+      FILE_DEVICE_WAVE_IN             = $00000025;
+      FILE_DEVICE_WAVE_OUT            = $00000026;
+      FILE_DEVICE_8042_PORT           = $00000027;
+      FILE_DEVICE_NETWORK_REDIRECTOR  = $00000028;
+      FILE_DEVICE_BATTERY             = $00000029;
+      FILE_DEVICE_BUS_EXTENDER        = $0000002a;
+      FILE_DEVICE_MODEM               = $0000002b;
+      FILE_DEVICE_VDM                 = $0000002c;
+      FILE_DEVICE_MASS_STORAGE        = $0000002d;
+      FILE_DEVICE_SMB                 = $0000002e;
+      FILE_DEVICE_KS                  = $0000002f;
+      FILE_DEVICE_CHANGER             = $00000030;
+      FILE_DEVICE_SMARTCARD           = $00000031;
+      FILE_DEVICE_ACPI                = $00000032;
+      FILE_DEVICE_DVD                 = $00000033;
+      FILE_DEVICE_FULLSCREEN_VIDEO    = $00000034;
+      FILE_DEVICE_DFS_FILE_SYSTEM     = $00000035;
+      FILE_DEVICE_DFS_VOLUME          = $00000036;
+
+//
+// Windows CE Specific Defines
+//
+const
+      FILE_DEVICE_HAL                 = $00000101;
+      FILE_DEVICE_CONSOLE             = $00000102;
+      FILE_DEVICE_PSL                 = $00000103;
+      FILE_DEVICE_SERVICE             = $00000104;
+      FILE_DEVICE_NLED                = $00000105;
+      FILE_DEVICE_NOTIFY              = $00000106;
+      FILE_DEVICE_GPS                 = $00000107;
+      FILE_DEVICE_SQM                 = $00000108;
+
+implementation
+
+function CTL_CODE(_DeviceType:DEVICE_TYPE; _Function:DWORD; _Method:DWORD; _Access:DWORD):DWORD; inline;
+begin
+  CTL_CODE:=(_DeviceType shl 16) or (_Access shl 14) or (_Function shl 2) or _Method;
+end;
+
+end.

+ 68 - 87
rtl/wince/wininc/coredll.inc

@@ -69,12 +69,8 @@
       691 A_SHAInit
       691 A_SHAInit
       692 A_SHAUpdate
       692 A_SHAUpdate
       1B8 AccessibilitySoundSentryEvent
       1B8 AccessibilitySoundSentryEvent
-      153 ActivateDevice
-      154 ActivateDeviceEx
-      16A ActivateService
       35B AddEventAccess
       35B AddEventAccess
       37A AddTrackedItem
       37A AddTrackedItem
-      157 AdvertiseInterface
       496 AllKeys
       496 AllKeys
       35F AllocPhysMem
       35F AllocPhysMem
        E5 AttachDebugger
        E5 AttachDebugger
@@ -158,11 +154,9 @@
       1E6 CeUnmountDBVol
       1E6 CeUnmountDBVol
       1E5 CeWriteRecordProps
       1E5 CeWriteRecordProps
        2F CeZeroPointer
        2F CeZeroPointer
-      10B CheckPassword
       184 CloseAllDeviceHandles
       184 CloseAllDeviceHandles
       180 CloseAllFileHandles
       180 CloseAllFileHandles
       16D CloseAllServiceHandles
       16D CloseAllServiceHandles
-      115 CloseMsgQueue
       384 CloseProcOE
       384 CloseProcOE
        18 ComThreadBaseFunc
        18 ComThreadBaseFunc
        51 CompactAllHeaps
        51 CompactAllHeaps
@@ -172,8 +166,6 @@
       528 CreateBitmapFromPointer
       528 CreateBitmapFromPointer
       3A2 CreateCrit
       3A2 CreateCrit
       185 CreateDeviceHandle
       185 CreateDeviceHandle
-      111 CreateMsgQueue
-      16E CreateServiceHandle
       34E CreateStaticMapping
       34E CreateStaticMapping
        C5 CryptAcquireContextW
        C5 CryptAcquireContextW
        E1 CryptContextAddRef
        E1 CryptContextAddRef
@@ -212,27 +204,21 @@
        C3 DDKReg_GetIsrInfo
        C3 DDKReg_GetIsrInfo
        C4 DDKReg_GetPciInfo
        C4 DDKReg_GetPciInfo
        C2 DDKReg_GetWindowInfo
        C2 DDKReg_GetWindowInfo
-      158 DeactivateDevice
       3BF DebugNotify
       3BF DebugNotify
       38B DecompressBinaryBlock
       38B DecompressBinaryBlock
        FF DeleteAndRenameFile
        FF DeleteAndRenameFile
       37B DeleteTrackedItem
       37B DeleteTrackedItem
       179 DeregisterAFS
       179 DeregisterAFS
       17B DeregisterAFSName
       17B DeregisterAFSName
-      150 DeregisterDevice
-      16C DeregisterService
-      164 DevicePowerNotify
       3DA DisableCaretSystemWide
       3DA DisableCaretSystemWide
       17E DumpFileSystemHeap
       17E DumpFileSystemHeap
       30C DumpKCallProfile
       30C DumpKCallProfile
       3DB EnableCaretSystemWide
       3DB EnableCaretSystemWide
       553 EnableEUDC
       553 EnableEUDC
-      486 EnableHardwareKeyboard
        BF EnumDevices
        BF EnumDevices
       50E EnumDisplayDevices
       50E EnumDisplayDevices
       666 EnumDisplayMonitors
       666 EnumDisplayMonitors
        BE EnumPnpIds
        BE EnumPnpIds
-      173 EnumServices
       14D EnumUILanguagesW
       14D EnumUILanguagesW
       374 ExtractResource
       374 ExtractResource
       17F FileSystemPowerFunction
       17F FileSystemPowerFunction
@@ -250,31 +236,23 @@
       398 GetCallerProcess
       398 GetCallerProcess
       3BE GetCallerProcessIndex
       3BE GetCallerProcessIndex
       3E9 GetClipboardDataAlloc
       3E9 GetClipboardDataAlloc
-       B1 GetCommMask
        29 GetCurrentFT
        29 GetCurrentFT
       39F GetCurrentPermissions
       39F GetCurrentPermissions
       186 GetDeviceByIndex
       186 GetDeviceByIndex
        C0 GetDeviceKeys
        C0 GetDeviceKeys
-      168 GetDevicePower
       2FA GetEventData
       2FA GetEventData
       394 GetFSHeapInfo
       394 GetFSHeapInfo
       407 GetForegroundInfo
       407 GetForegroundInfo
       409 GetForegroundKeyboardLayoutHandle
       409 GetForegroundKeyboardLayoutHandle
       408 GetForegroundKeyboardTarget
       408 GetForegroundKeyboardTarget
        50 GetHeapSnapshot
        50 GetHeapSnapshot
-      399 GetIdleTime
       37D GetKPhys
       37D GetKPhys
-      488 GetKeyboardStatus
       405 GetKeyboardTarget
       405 GetKeyboardTarget
       4C3 GetMessageQueueReadyTimeStamp
       4C3 GetMessageQueueReadyTimeStamp
-      4BF GetMessageSource
       4B7 GetMessageWNoWait
       4B7 GetMessageWNoWait
       30B GetModuleInformation
       30B GetModuleInformation
       665 GetMonitorInfo
       665 GetMonitorInfo
-      481 GetMouseMovePoints
-      114 GetMsgQueueInfo
       397 GetOwnerProcess
       397 GetOwnerProcess
-      10D GetPasswordActive
       110 GetPasswordStatus
       110 GetPasswordStatus
       1B6 GetPrivateCallbacks
       1B6 GetPrivateCallbacks
       393 GetProcAddrBits
       393 GetProcAddrBits
@@ -282,19 +260,12 @@
       3A8 GetProcName
       3A8 GetProcName
       3BD GetProcessIDFromIndex
       3BD GetProcessIDFromIndex
       3BC GetProcessIndexFromID
       3BC GetProcessIndexFromID
-      32F GetProcessVersion
       371 GetRealTime
       371 GetRealTime
       377 GetRomFileBytes
       377 GetRomFileBytes
       376 GetRomFileInfo
       376 GetRomFileInfo
-      16F GetServiceByIndex
-      174 GetServiceHandle
       102 GetStoreInformation
       102 GetStoreInformation
-      14A GetSystemDefaultUILanguage
-      17C GetSystemMemoryDivision
-      15E GetSystemPowerState
-      40E GetSystemPowerStatusEx
-      40F GetSystemPowerStatusEx2
-      14B GetUserDefaultUILanguage
+-      40E GetSystemPowerStatusEx -> power.inc
+-      40F GetSystemPowerStatusEx2 -> power.inc
       2D0 GetUserDirectory
       2D0 GetUserDirectory
       1B7 GetWindowTextWDirect
       1B7 GetWindowTextWDirect
       37E GiveKPhys
       37E GiveKPhys
@@ -381,7 +352,6 @@
        E8 IsExiting
        E8 IsExiting
       39B IsPrimaryThread
       39B IsPrimaryThread
         F IsProcessDying
         F IsProcessDying
-      339 IsProcessorFeaturePresent
       183 IsSystemFile
       183 IsSystemFile
       375 KernExtractIcons
       375 KernExtractIcons
       34C KernelIoControl
       34C KernelIoControl
@@ -391,8 +361,6 @@
       48B KeybdVKeyToUnicode
       48B KeybdVKeyToUnicode
       396 KillAllOtherThreads
       396 KillAllOtherThreads
       38E LeaveCritSec
       38E LeaveCritSec
-      525 LineTo
-      41E LoadAnimatedCursor
       3AA LoadDriver
       3AA LoadDriver
       151 LoadFSD
       151 LoadFSD
       152 LoadFSDEx
       152 LoadFSDEx
@@ -418,7 +386,6 @@
       30F NotifyForceCleanboot
       30F NotifyForceCleanboot
       410 NotifyWinUserSystem
       410 NotifyWinUserSystem
        C1 OpenDeviceKey
        C1 OpenDeviceKey
-      116 OpenMsgQueue
       395 OtherThreadsRunning
       395 OtherThreadsRunning
       3BB PPSHRestart
       3BB PPSHRestart
         C PSLNotify
         C PSLNotify
@@ -445,7 +412,6 @@
       267 PlaySoundW
       267 PlaySoundW
       48D PostKeybdMessage
       48D PostKeybdMessage
       3A3 PowerOffSystem
       3A3 PowerOffSystem
-      169 PowerPolicyNotify
       37C PrintTrackedItem
       37C PrintTrackedItem
       373 ProcessDetachAllDLLs
       373 ProcessDetachAllDLLs
        94 ProfileCaptureStatus
        94 ProfileCaptureStatus
@@ -483,9 +449,7 @@
       1F8 RasSetEntryDialParams
       1F8 RasSetEntryDialParams
       1FA RasSetEntryProperties
       1FA RasSetEntryProperties
       1FB RasValidateEntryName
       1FB RasValidateEntryName
-       F4 ReadFile
       181 ReadFileWithSeek
       181 ReadFileWithSeek
-      112 ReadMsgQueue
       3C0 ReadRegistryFromOEM
       3C0 ReadRegistryFromOEM
       52F RealizePalette
       52F RealizePalette
       1BE RectangleAnimation
       1BE RectangleAnimation
@@ -499,16 +463,9 @@
       3B8 RegisterAPISet
       3B8 RegisterAPISet
       33D RegisterDbgZones
       33D RegisterDbgZones
       4DB RegisterDesktop
       4DB RegisterDesktop
-      14F RegisterDevice
-      165 RegisterPowerRelationship
       1BD RegisterSIPanel
       1BD RegisterSIPanel
-      16B RegisterService
-      4D9 RegisterTaskBar
-      4DA RegisterTaskBarEx
       380 RegisterTrackedItem
       380 RegisterTrackedItem
         E ReinitLocale
         E ReinitLocale
-      166 ReleasePowerRelationship
-      161 ReleasePowerRequirement
        36 RemoteHeapAlloc
        36 RemoteHeapAlloc
        38 RemoteHeapFree
        38 RemoteHeapFree
        37 RemoteHeapReAlloc
        37 RemoteHeapReAlloc
@@ -517,8 +474,6 @@
        3D RemoteLocalFree
        3D RemoteLocalFree
        3B RemoteLocalReAlloc
        3B RemoteLocalReAlloc
        3C RemoteLocalSize
        3C RemoteLocalSize
-      155 RequestDeviceNotifications
-      162 RequestPowerNotifications
       15A ResourceCreateList
       15A ResourceCreateList
       15C ResourceRelease
       15C ResourceRelease
       15B ResourceRequest
       15B ResourceRequest
@@ -529,10 +484,6 @@
       2EC SHLoadDIBitmap
       2EC SHLoadDIBitmap
       2EB SHShowOutOfMemory
       2EB SHShowOutOfMemory
       482 SendInput
       482 SendInput
-      171 ServiceAddPort
-      175 ServiceClosePort
-      170 ServiceIoControl
-      172 ServiceUnbindPorts
       11B SetACP
       11B SetACP
       1C0 SetAssociatedMenu
       1C0 SetAssociatedMenu
       522 SetBrushOrgEx
       522 SetBrushOrgEx
@@ -540,7 +491,6 @@
       2CE SetCurrentUser
       2CE SetCurrentUser
       33E SetDaylightTime
       33E SetDaylightTime
       3A4 SetDbgZone
       3A4 SetDbgZone
-      167 SetDevicePower
       2FB SetEventData
       2FB SetEventData
       37F SetExceptionHandler
       37F SetExceptionHandler
       385 SetGwesOOMEvent
       385 SetGwesOOMEvent
@@ -555,16 +505,12 @@
       11C SetOEMCP
       11C SetOEMCP
       386 SetOOMEvent
       386 SetOOMEvent
       551 SetObjectOwner
       551 SetObjectOwner
-      10C SetPassword
-      10E SetPasswordActive
       10F SetPasswordStatus
       10F SetPasswordStatus
       3B3 SetPowerOffHandler
       3B3 SetPowerOffHandler
-      160 SetPowerRequirement
       39C SetProcPermissions
       39C SetProcPermissions
       372 SetRealTime
       372 SetRealTime
       135 SetSystemDefaultLCID
       135 SetSystemDefaultLCID
       17D SetSystemMemoryDivision
       17D SetSystemMemoryDivision
-      15F SetSystemPowerState
       3A0 SetTimeZoneBias
       3A0 SetTimeZoneBias
       2CF SetUserData
       2CF SetUserData
       137 SetUserDefaultLCID
       137 SetUserDefaultLCID
@@ -584,7 +530,6 @@
       659 SipStatus
       659 SipStatus
       361 SleepTillTick
       361 SleepTillTick
       156 StopDeviceNotifications
       156 StopDeviceNotifications
-      163 StopPowerNotifications
       648 StringCbCatA
       648 StringCbCatA
       64A StringCbCatExA
       64A StringCbCatExA
        82 StringCbCatExW
        82 StringCbCatExW
@@ -645,7 +590,6 @@
        16 ThreadBaseFunc
        16 ThreadBaseFunc
       367 ThreadDetachAllDLLs
       367 ThreadDetachAllDLLs
         B ThreadExceptionExit
         B ThreadExceptionExit
-      4C7 TouchCalibrate
       3A6 TurnOffProfiling
       3A6 TurnOffProfiling
       3A5 TurnOnProfiling
       3A5 TurnOnProfiling
       36C U_rclose
       36C U_rclose
@@ -662,7 +606,6 @@
       35E VirtualSetAttributes
       35E VirtualSetAttributes
       3C2 WriteDebugLED
       3C2 WriteDebugLED
       182 WriteFileWithSeek
       182 WriteFileWithSeek
-      113 WriteMsgQueue
       3C1 WriteRegistryToOEM
       3C1 WriteRegistryToOEM
       67B _CountLeadingOnes
       67B _CountLeadingOnes
       67C _CountLeadingOnes64
       67C _CountLeadingOnes64
@@ -2019,16 +1962,7 @@
       583 labs
       583 labs
       584 ldexp
       584 ldexp
       585 ldiv
       585 ldiv
-      586 log
-      587 log10
       589 longjmp
       589 longjmp
-      58E malloc
-       66 mbstowcs
-       2B memchr
-      591 memcmp
-      592 memcpy
-      594 memmove
-      595 memset
       2B2 mixerClose
       2B2 mixerClose
       2A9 mixerGetControlDetails
       2A9 mixerGetControlDetails
       2AA mixerGetDevCaps
       2AA mixerGetDevCaps
@@ -2127,24 +2061,6 @@
       26B waveOutSetVolume
       26B waveOutSetVolume
       26F waveOutUnprepareHeader
       26F waveOutUnprepareHeader
       270 waveOutWrite
       270 waveOutWrite
-       54 wcscat
-       55 wcschr
-       56 wcscmp
-       57 wcscpy
-       58 wcscspn
-       59 wcslen
-       5A wcsncat
-       5B wcsncmp
-       5C wcsncpy
-       5E wcspbrk
-       5F wcsrchr
-       62 wcsspn
-       63 wcsstr
-      5B5 wcstod
-       67 wcstok
-      5B6 wcstol
-       65 wcstombs
-      5B7 wcstoul
       632 wprintf
       632 wprintf
       631 wscanf
       631 wscanf
 
 
@@ -2173,7 +2089,7 @@ const
   CSIDL_DRIVES             = $0011;
   CSIDL_DRIVES             = $0011;
   CSIDL_NETWORK            = $0012;
   CSIDL_NETWORK            = $0012;
   CSIDL_NETHOOD            = $0013;
   CSIDL_NETHOOD            = $0013;
-  CSIDL_FONTS		           = $0014;
+  CSIDL_FONTS              = $0014;
   CSIDL_TEMPLATES          = $0015;
   CSIDL_TEMPLATES          = $0015;
   CSIDL_APPDATA            = $001a;
   CSIDL_APPDATA            = $001a;
   CSIDL_WINDOWS            = $0024;
   CSIDL_WINDOWS            = $0024;
@@ -2190,10 +2106,13 @@ const
 
 
 
 
 function AbortDoc(_para1:HDC):longint; external KernelDLL name 'AbortDoc';
 function AbortDoc(_para1:HDC):longint; external KernelDLL name 'AbortDoc';
+function ActivateDevice(lpszDevKey:LPCWSTR; dwClientInfo:DWORD):HANDLE; external KernelDLL name 'ActivateDevice'; // index 153
+function ActivateDeviceEx(lpszDevKey:LPCWSTR; lpRegEnts:LPCVOID; cRegEnts:DWORD; lpvParam:LPVOID):HANDLE; external KernelDLL name 'ActivateDeviceEx'; // index 154
 function ActivateKeyboardLayout(hkl:HKL; Flags:UINT):HKL; external KernelDLL name 'ActivateKeyboardLayout';
 function ActivateKeyboardLayout(hkl:HKL; Flags:UINT):HKL; external KernelDLL name 'ActivateKeyboardLayout';
 function AddFontResource(_para1:LPCWSTR):longint; external KernelDLL name 'AddFontResourceW';
 function AddFontResource(_para1:LPCWSTR):longint; external KernelDLL name 'AddFontResourceW';
 function AddFontResourceW(_para1:LPCWSTR):longint; external KernelDLL name 'AddFontResourceW';
 function AddFontResourceW(_para1:LPCWSTR):longint; external KernelDLL name 'AddFontResourceW';
 function AdjustWindowRectEx(lpRect:LPRECT; dwStyle:DWORD; bMenu:WINBOOL; dwExStyle:DWORD):WINBOOL; external KernelDLL name 'AdjustWindowRectEx';
 function AdjustWindowRectEx(lpRect:LPRECT; dwStyle:DWORD; bMenu:WINBOOL; dwExStyle:DWORD):WINBOOL; external KernelDLL name 'AdjustWindowRectEx';
+function AdvertiseInterface(devclass:LPGUID; name:LPCWSTR; fAdd:BOOL):BOOL; external KernelDLL name 'AdvertiseInterface'; // index 157
 function AppendMenu(hMenu:HMENU; uFlags:UINT; uIDNewItem:UINT; lpNewItem:LPCWSTR):WINBOOL; external KernelDLL name 'AppendMenuW';
 function AppendMenu(hMenu:HMENU; uFlags:UINT; uIDNewItem:UINT; lpNewItem:LPCWSTR):WINBOOL; external KernelDLL name 'AppendMenuW';
 function AppendMenuW(hMenu:HMENU; uFlags:UINT; uIDNewItem:UINT; lpNewItem:LPCWSTR):WINBOOL; external KernelDLL name 'AppendMenuW';
 function AppendMenuW(hMenu:HMENU; uFlags:UINT; uIDNewItem:UINT; lpNewItem:LPCWSTR):WINBOOL; external KernelDLL name 'AppendMenuW';
 function BeginDeferWindowPos(nNumWindows:longint):HDWP; external KernelDLL name 'BeginDeferWindowPos';
 function BeginDeferWindowPos(nNumWindows:longint):HDWP; external KernelDLL name 'BeginDeferWindowPos';
@@ -2219,6 +2138,7 @@ function CharUpperBuffW(lpsz:LPWSTR; cchLength:DWORD):DWORD; external KernelDLL
 function CheckDlgButton(hDlg:HWND; nIDButton:longint; uCheck:UINT):WINBOOL;
 function CheckDlgButton(hDlg:HWND; nIDButton:longint; uCheck:UINT):WINBOOL;
 function CheckMenuItem(hMenu:HMENU; uIDCheckItem:UINT; uCheck:UINT):DWORD; external KernelDLL name 'CheckMenuItem';
 function CheckMenuItem(hMenu:HMENU; uIDCheckItem:UINT; uCheck:UINT):DWORD; external KernelDLL name 'CheckMenuItem';
 function CheckMenuRadioItem(_para1:HMENU; _para2:UINT; _para3:UINT; _para4:UINT; _para5:UINT):WINBOOL; external KernelDLL name 'CheckMenuRadioItem';
 function CheckMenuRadioItem(_para1:HMENU; _para2:UINT; _para3:UINT; _para4:UINT; _para5:UINT):WINBOOL; external KernelDLL name 'CheckMenuRadioItem';
+function CheckPassword(lpszPassword:LPWSTR):BOOL;  external KernelDLL name 'CheckPassword'; // index 10B
 function CheckRadioButton(hDlg:HWND; nIDFirstButton:longint; nIDLastButton:longint; nIDCheckButton:longint):WINBOOL; external KernelDLL name 'CheckRadioButton';
 function CheckRadioButton(hDlg:HWND; nIDFirstButton:longint; nIDLastButton:longint; nIDCheckButton:longint):WINBOOL; external KernelDLL name 'CheckRadioButton';
 function ChildWindowFromPoint(hWndParent:HWND; Point:POINT):HWND; external KernelDLL name 'ChildWindowFromPoint';
 function ChildWindowFromPoint(hWndParent:HWND; Point:POINT):HWND; external KernelDLL name 'ChildWindowFromPoint';
 function ClearCommBreak(hFile:HANDLE):WINBOOL; external KernelDLL name 'ClearCommBreak';
 function ClearCommBreak(hFile:HANDLE):WINBOOL; external KernelDLL name 'ClearCommBreak';
@@ -2294,6 +2214,7 @@ function CreateWindowEx(dwExStyle:DWORD; lpClassName:LPCWSTR; lpWindowName:LPCWS
   external KernelDLL name 'CreateWindowExW';
   external KernelDLL name 'CreateWindowExW';
 function CreateWindowExW(dwExStyle:DWORD; lpClassName:LPCWSTR; lpWindowName:LPCWSTR; dwStyle:DWORD; X:longint;Y:longint; nWidth:longint; nHeight:longint; hWndParent:HWND; hMenu:HMENU;hInstance:HINST; lpParam:LPVOID):HWND;
 function CreateWindowExW(dwExStyle:DWORD; lpClassName:LPCWSTR; lpWindowName:LPCWSTR; dwStyle:DWORD; X:longint;Y:longint; nWidth:longint; nHeight:longint; hWndParent:HWND; hMenu:HMENU;hInstance:HINST; lpParam:LPVOID):HWND;
   external KernelDLL name 'CreateWindowExW';
   external KernelDLL name 'CreateWindowExW';
+function DeactivateDevice(hDevice:HANDLE):BOOL; external KernelDLL name 'DeactivateDevice'; // index 158
 function DebugActiveProcess(dwProcessId:DWORD):WINBOOL; external KernelDLL name 'DebugActiveProcess';
 function DebugActiveProcess(dwProcessId:DWORD):WINBOOL; external KernelDLL name 'DebugActiveProcess';
 function DefDlgProc(hDlg:HWND; Msg:UINT; wParam:WPARAM; lParam:LPARAM):LRESULT; external KernelDLL name 'DefDlgProcW';
 function DefDlgProc(hDlg:HWND; Msg:UINT; wParam:WPARAM; lParam:LPARAM):LRESULT; external KernelDLL name 'DefDlgProcW';
 function DefDlgProcW(hDlg:HWND; Msg:UINT; wParam:WPARAM; lParam:LPARAM):LRESULT; external KernelDLL name 'DefDlgProcW';
 function DefDlgProcW(hDlg:HWND; Msg:UINT; wParam:WPARAM; lParam:LPARAM):LRESULT; external KernelDLL name 'DefDlgProcW';
@@ -2307,6 +2228,7 @@ function DeleteFile(lpFileName:LPCWSTR):WINBOOL; external KernelDLL name 'Delete
 function DeleteFileW(lpFileName:LPCWSTR):WINBOOL; external KernelDLL name 'DeleteFileW';
 function DeleteFileW(lpFileName:LPCWSTR):WINBOOL; external KernelDLL name 'DeleteFileW';
 function DeleteMenu(hMenu:HMENU; uPosition:UINT; uFlags:UINT):WINBOOL; external KernelDLL name 'DeleteMenu';
 function DeleteMenu(hMenu:HMENU; uPosition:UINT; uFlags:UINT):WINBOOL; external KernelDLL name 'DeleteMenu';
 function DeleteObject(_para1:HGDIOBJ):WINBOOL; external KernelDLL name 'DeleteObject';
 function DeleteObject(_para1:HGDIOBJ):WINBOOL; external KernelDLL name 'DeleteObject';
+function DeregisterDevice(hDevice:HANDLE):BOOL; external KernelDLL name 'DeregisterDevice'; // index 150
 function DestroyAcceleratorTable(hAccel:HACCEL):WINBOOL; external KernelDLL name 'DestroyAcceleratorTable';
 function DestroyAcceleratorTable(hAccel:HACCEL):WINBOOL; external KernelDLL name 'DestroyAcceleratorTable';
 function DestroyCaret:WINBOOL; external KernelDLL name 'DestroyCaret';
 function DestroyCaret:WINBOOL; external KernelDLL name 'DestroyCaret';
 function DestroyIcon(hIcon:HICON):WINBOOL; external KernelDLL name 'DestroyIcon';
 function DestroyIcon(hIcon:HICON):WINBOOL; external KernelDLL name 'DestroyIcon';
@@ -2334,6 +2256,7 @@ function DuplicateHandle(hSourceProcessHandle:HANDLE; hSourceHandle:HANDLE; hTar
 function Ellipse(_para1:HDC; _para2:longint; _para3:longint; _para4:longint; _para5:longint):WINBOOL; external KernelDLL name 'Ellipse';
 function Ellipse(_para1:HDC; _para2:longint; _para3:longint; _para4:longint; _para5:longint):WINBOOL; external KernelDLL name 'Ellipse';
 function EqualRgn(_para1:HRGN; _para2:HRGN):WINBOOL; external KernelDLL name 'EqualRgn';
 function EqualRgn(_para1:HRGN; _para2:HRGN):WINBOOL; external KernelDLL name 'EqualRgn';
 function EmptyClipboard:WINBOOL; external KernelDLL name 'EmptyClipboard';
 function EmptyClipboard:WINBOOL; external KernelDLL name 'EmptyClipboard';
+function EnableHardwareKeyboard(bEnable:BOOL):BOOL; external KernelDLL name 'EnableHardwareKeyboard'; // index 486
 function EnableMenuItem(hMenu:HMENU; uIDEnableItem:UINT; uEnable:UINT):WINBOOL; external KernelDLL name 'EnableMenuItem';
 function EnableMenuItem(hMenu:HMENU; uIDEnableItem:UINT; uEnable:UINT):WINBOOL; external KernelDLL name 'EnableMenuItem';
 function EnableWindow(hWnd:HWND; bEnable:WINBOOL):WINBOOL; external KernelDLL name 'EnableWindow';
 function EnableWindow(hWnd:HWND; bEnable:WINBOOL):WINBOOL; external KernelDLL name 'EnableWindow';
 function EnumCalendarInfo(lpCalInfoEnumProc:CALINFO_ENUMPROC; Locale:LCID; Calendar:CALID; CalType:CALTYPE):WINBOOL; external KernelDLL name 'EnumCalendarInfoW';
 function EnumCalendarInfo(lpCalInfoEnumProc:CALINFO_ENUMPROC; Locale:LCID; Calendar:CALID; CalType:CALTYPE):WINBOOL; external KernelDLL name 'EnumCalendarInfoW';
@@ -2427,6 +2350,7 @@ function GetClipCursor(lpRect:LPRECT):WINBOOL; external KernelDLL name 'GetClipC
 function GetClipRgn(_para1:HDC; _para2:HRGN):longint; external KernelDLL name 'GetClipRgn';
 function GetClipRgn(_para1:HDC; _para2:HRGN):longint; external KernelDLL name 'GetClipRgn';
 function GetCommandLine : LPWSTR; external KernelDLL name 'GetCommandLineW';
 function GetCommandLine : LPWSTR; external KernelDLL name 'GetCommandLineW';
 function GetCommandLineW : LPWSTR; external KernelDLL name 'GetCommandLineW';
 function GetCommandLineW : LPWSTR; external KernelDLL name 'GetCommandLineW';
+function GetCommMask(hFile:HANDLE; lpEvtMask:LPDWORD):BOOL; external KernelDLL name 'GetCommMask'; // index B1
 function GetCommProperties(hFile:HANDLE; lpCommProp:LPCOMMPROP):WINBOOL; external KernelDLL name 'GetCommProperties';
 function GetCommProperties(hFile:HANDLE; lpCommProp:LPCOMMPROP):WINBOOL; external KernelDLL name 'GetCommProperties';
 function GetCommModemStatus(hFile:HANDLE; lpModemStat:PDWORD):WINBOOL; external KernelDLL name 'GetCommModemStatus';
 function GetCommModemStatus(hFile:HANDLE; lpModemStat:PDWORD):WINBOOL; external KernelDLL name 'GetCommModemStatus';
 function GetCommState(hFile:HANDLE; lpDCB:PDCB):WINBOOL; external KernelDLL name 'GetCommState';
 function GetCommState(hFile:HANDLE; lpDCB:PDCB):WINBOOL; external KernelDLL name 'GetCommState';
@@ -2475,10 +2399,12 @@ function GetFileVersionInfoSizeW(lptstrFilename:LPWSTR; lpdwHandle:LPDWORD):DWOR
 function GetFileVersionInfoSizeW(lptstrFilename:LPWSTR; var dwHandle:DWORD):DWORD; external KernelDLL name 'GetFileVersionInfoSizeW';
 function GetFileVersionInfoSizeW(lptstrFilename:LPWSTR; var dwHandle:DWORD):DWORD; external KernelDLL name 'GetFileVersionInfoSizeW';
 function GetFileVersionInfo(lptstrFilename:LPWSTR; dwHandle:DWORD; dwLen:DWORD; lpData:LPVOID):WINBOOL; external KernelDLL name 'GetFileVersionInfoW';
 function GetFileVersionInfo(lptstrFilename:LPWSTR; dwHandle:DWORD; dwLen:DWORD; lpData:LPVOID):WINBOOL; external KernelDLL name 'GetFileVersionInfoW';
 function GetFileVersionInfoW(lptstrFilename:LPWSTR; dwHandle:DWORD; dwLen:DWORD; lpData:LPVOID):WINBOOL; external KernelDLL name 'GetFileVersionInfoW';
 function GetFileVersionInfoW(lptstrFilename:LPWSTR; dwHandle:DWORD; dwLen:DWORD; lpData:LPVOID):WINBOOL; external KernelDLL name 'GetFileVersionInfoW';
+function GetIdleTime:DWORD; external KernelDLL name 'GetIdleTime'; // index 399
 function GetKeyboardLayout(dwLayout:DWORD):HKL; external KernelDLL name 'GetKeyboardLayout';
 function GetKeyboardLayout(dwLayout:DWORD):HKL; external KernelDLL name 'GetKeyboardLayout';
 function GetKeyboardLayoutList(nBuff:longint; var lpList:HKL):UINT; external KernelDLL name 'GetKeyboardLayoutList';
 function GetKeyboardLayoutList(nBuff:longint; var lpList:HKL):UINT; external KernelDLL name 'GetKeyboardLayoutList';
 function GetKeyboardLayoutName(pwszKLID:LPWSTR):WINBOOL; external KernelDLL name 'GetKeyboardLayoutNameW';
 function GetKeyboardLayoutName(pwszKLID:LPWSTR):WINBOOL; external KernelDLL name 'GetKeyboardLayoutNameW';
 function GetKeyboardLayoutNameW(pwszKLID:LPWSTR):WINBOOL; external KernelDLL name 'GetKeyboardLayoutNameW';
 function GetKeyboardLayoutNameW(pwszKLID:LPWSTR):WINBOOL; external KernelDLL name 'GetKeyboardLayoutNameW';
+function GetKeyboardStatus:DWORD; external KernelDLL name 'GetKeyboardStatus'; // index 488
 function GetKeyboardType(nTypeFlag:longint):longint; external KernelDLL name 'GetKeyboardType';
 function GetKeyboardType(nTypeFlag:longint):longint; external KernelDLL name 'GetKeyboardType';
 function GetKeyState(nVirtKey:longint):SHORT; external KernelDLL name 'GetKeyState';
 function GetKeyState(nVirtKey:longint):SHORT; external KernelDLL name 'GetKeyState';
 function GetLastError:DWORD; external KernelDLL name 'GetLastError';
 function GetLastError:DWORD; external KernelDLL name 'GetLastError';
@@ -2490,10 +2416,12 @@ function GetMenuItemInfoW(_para1:HMENU; _para2:UINT; _para3:WINBOOL; _para4:LPME
 function GetMessage(lpMsg:LPMSG; hWnd:HWND; wMsgFilterMin:UINT; wMsgFilterMax:UINT):WINBOOL; external KernelDLL name 'GetMessageW';
 function GetMessage(lpMsg:LPMSG; hWnd:HWND; wMsgFilterMin:UINT; wMsgFilterMax:UINT):WINBOOL; external KernelDLL name 'GetMessageW';
 function GetMessageW(lpMsg:LPMSG; hWnd:HWND; wMsgFilterMin:UINT; wMsgFilterMax:UINT):WINBOOL; external KernelDLL name 'GetMessageW';
 function GetMessageW(lpMsg:LPMSG; hWnd:HWND; wMsgFilterMin:UINT; wMsgFilterMax:UINT):WINBOOL; external KernelDLL name 'GetMessageW';
 function GetMessagePos:DWORD; external KernelDLL name 'GetMessagePos';
 function GetMessagePos:DWORD; external KernelDLL name 'GetMessagePos';
+function GetMessageSource:UINT; external KernelDLL name 'GetMessageSource';// index 4BF
 function GetModuleFileName(hModule:HMODULE; lpFilename:LPWSTR; nSize:DWORD):DWORD; external KernelDLL name 'GetModuleFileNameW';
 function GetModuleFileName(hModule:HMODULE; lpFilename:LPWSTR; nSize:DWORD):DWORD; external KernelDLL name 'GetModuleFileNameW';
 function GetModuleFileNameW(hModule:HMODULE; lpFilename:LPWSTR; nSize:DWORD):DWORD; external KernelDLL name 'GetModuleFileNameW';
 function GetModuleFileNameW(hModule:HMODULE; lpFilename:LPWSTR; nSize:DWORD):DWORD; external KernelDLL name 'GetModuleFileNameW';
 function GetModuleHandle(lpModuleName:LPCWSTR):HMODULE; external KernelDLL name 'GetModuleHandleW';
 function GetModuleHandle(lpModuleName:LPCWSTR):HMODULE; external KernelDLL name 'GetModuleHandleW';
 function GetModuleHandleW(lpModuleName:LPCWSTR):HMODULE; external KernelDLL name 'GetModuleHandleW';
 function GetModuleHandleW(lpModuleName:LPCWSTR):HMODULE; external KernelDLL name 'GetModuleHandleW';
+function GetMouseMovePoints(pptBuf:PPOINT; nBufPoints:UINT; pnPointsRetrieved:PUINT):BOOL; external KernelDLL name 'GetMouseMovePoints'; // index 481
 function GetNearestColor(_para1:HDC; _para2:COLORREF):COLORREF; external KernelDLL name 'GetNearestColor';
 function GetNearestColor(_para1:HDC; _para2:COLORREF):COLORREF; external KernelDLL name 'GetNearestColor';
 function GetNearestPaletteIndex(_para1:HPALETTE; _para2:COLORREF):UINT; external KernelDLL name 'GetNearestPaletteIndex';
 function GetNearestPaletteIndex(_para1:HPALETTE; _para2:COLORREF):UINT; external KernelDLL name 'GetNearestPaletteIndex';
 function GetNextDlgGroupItem(hDlg:HWND; hCtl:HWND; bPrevious:WINBOOL):HWND; external KernelDLL name 'GetNextDlgGroupItem';
 function GetNextDlgGroupItem(hDlg:HWND; hCtl:HWND; bPrevious:WINBOOL):HWND; external KernelDLL name 'GetNextDlgGroupItem';
@@ -2509,12 +2437,15 @@ function GetOpenFileName(_para1:LPOPENFILENAMEW):WINBOOL; external KernelDLL nam
 function GetOpenFileNameW(_para1:LPOPENFILENAMEW):WINBOOL; external KernelDLL name 'GetOpenFileNameW';
 function GetOpenFileNameW(_para1:LPOPENFILENAMEW):WINBOOL; external KernelDLL name 'GetOpenFileNameW';
 function GetPaletteEntries(_para1:HPALETTE; _para2:UINT; _para3:UINT; _para4:LPPALETTEENTRY):UINT; external KernelDLL name 'GetPaletteEntries';
 function GetPaletteEntries(_para1:HPALETTE; _para2:UINT; _para3:UINT; _para4:LPPALETTEENTRY):UINT; external KernelDLL name 'GetPaletteEntries';
 function GetParent(hWnd:HWND):HWND; external KernelDLL name 'GetParent';
 function GetParent(hWnd:HWND):HWND; external KernelDLL name 'GetParent';
+function GetPasswordActive:BOOL; external KernelDLL name 'GetPasswordActive'; // index 10D
 function GetPriorityClipboardFormat(var paFormatPriorityList:UINT; cFormats:longint):longint; external KernelDLL name 'GetPriorityClipboardFormat';
 function GetPriorityClipboardFormat(var paFormatPriorityList:UINT; cFormats:longint):longint; external KernelDLL name 'GetPriorityClipboardFormat';
 function GetPixel(_para1:HDC; _para2:longint; _para3:longint):COLORREF; external KernelDLL name 'GetPixel';
 function GetPixel(_para1:HDC; _para2:longint; _para3:longint):COLORREF; external KernelDLL name 'GetPixel';
 function GetProcAddressA(hModule:HINST; lpProcName:LPCSTR):FARPROC; external KernelDLL name 'GetProcAddressA';
 function GetProcAddressA(hModule:HINST; lpProcName:LPCSTR):FARPROC; external KernelDLL name 'GetProcAddressA';
 function GetProcAddress(hModule:HINST; lpProcName:LPCWSTR):FARPROC; external KernelDLL name 'GetProcAddressW';
 function GetProcAddress(hModule:HINST; lpProcName:LPCWSTR):FARPROC; external KernelDLL name 'GetProcAddressW';
 function GetProcAddressW(hModule:HINST; lpProcName:LPCWSTR):FARPROC; external KernelDLL name 'GetProcAddressW';
 function GetProcAddressW(hModule:HINST; lpProcName:LPCWSTR):FARPROC; external KernelDLL name 'GetProcAddressW';
 function GetProcessHeap:HANDLE; external KernelDLL name 'GetProcessHeap';
 function GetProcessHeap:HANDLE; external KernelDLL name 'GetProcessHeap';
+function GetProcessVersion(ProcessId:DWORD):DWORD; external KernelDLL name 'GetProcessVersion'; // index 32F
+function GetDllVersion(hMod:HMODULE):DWORD;
 function GetProp(hWnd:HWND; lpString:LPCWSTR):HWND; external KernelDLL name 'GetProp';
 function GetProp(hWnd:HWND; lpString:LPCWSTR):HWND; external KernelDLL name 'GetProp';
 function GetQueueStatus(flags:UINT):DWORD; external KernelDLL name 'GetQueueStatus';
 function GetQueueStatus(flags:UINT):DWORD; external KernelDLL name 'GetQueueStatus';
 function GetRegionData(_para1:HRGN; _para2:DWORD; _para3:LPRGNDATA):DWORD; external KernelDLL name 'GetRegionData';
 function GetRegionData(_para1:HRGN; _para2:DWORD; _para3:LPRGNDATA):DWORD; external KernelDLL name 'GetRegionData';
@@ -2534,7 +2465,9 @@ function GetSysColor(nIndex:longint):DWORD; external KernelDLL name 'GetSysColor
 function GetSysColorBrush(nIndex:longint):HBRUSH; external KernelDLL name 'GetSysColorBrush';
 function GetSysColorBrush(nIndex:longint):HBRUSH; external KernelDLL name 'GetSysColorBrush';
 function GetSystemDefaultLangID:LANGID; external KernelDLL name 'GetSystemDefaultLangID';
 function GetSystemDefaultLangID:LANGID; external KernelDLL name 'GetSystemDefaultLangID';
 function GetSystemDefaultLCID:LCID; external KernelDLL name 'GetSystemDefaultLCID';
 function GetSystemDefaultLCID:LCID; external KernelDLL name 'GetSystemDefaultLCID';
+function GetSystemDefaultUILanguage:LANGID; external KernelDLL name 'GetSystemDefaultUILanguage'; // index 14A
 procedure GetSystemInfo(lpSystemInfo:LPSYSTEM_INFO); external KernelDLL name 'GetSystemInfo';
 procedure GetSystemInfo(lpSystemInfo:LPSYSTEM_INFO); external KernelDLL name 'GetSystemInfo';
+function GetSystemMemoryDivision(lpdwStorePages:LPDWORD; lpdwRamPages:LPDWORD; lpdwPageSize:LPDWORD):BOOL; external KernelDLL name 'GetSystemMemoryDivision'; // index 17C
 function GetSystemMetrics(nIndex:longint):longint; external KernelDLL name 'GetSystemMetrics';
 function GetSystemMetrics(nIndex:longint):longint; external KernelDLL name 'GetSystemMetrics';
 procedure GetSystemTime(lpSystemTime:LPSYSTEMTIME); external KernelDLL name 'GetSystemTime';
 procedure GetSystemTime(lpSystemTime:LPSYSTEMTIME); external KernelDLL name 'GetSystemTime';
 function GetSystemPaletteEntries(_para1:HDC; _para2:UINT; _para3:UINT; _para4:LPPALETTEENTRY):UINT; external KernelDLL name 'GetSystemPaletteEntries';
 function GetSystemPaletteEntries(_para1:HDC; _para2:UINT; _para3:UINT; _para4:LPPALETTEENTRY):UINT; external KernelDLL name 'GetSystemPaletteEntries';
@@ -2563,6 +2496,7 @@ function GetUpdateRect(hWnd:HWND; lpRect:LPRECT; bErase:WINBOOL):WINBOOL; extern
 function GetUpdateRgn(hWnd:HWND; hRgn:HRGN; bErase:WINBOOL):longint; external KernelDLL name 'GetUpdateRgn';
 function GetUpdateRgn(hWnd:HWND; hRgn:HRGN; bErase:WINBOOL):longint; external KernelDLL name 'GetUpdateRgn';
 function GetUserDefaultLangID:LANGID; external KernelDLL name 'GetUserDefaultLangID';
 function GetUserDefaultLangID:LANGID; external KernelDLL name 'GetUserDefaultLangID';
 function GetUserDefaultLCID:LCID; external KernelDLL name 'GetUserDefaultLCID';
 function GetUserDefaultLCID:LCID; external KernelDLL name 'GetUserDefaultLCID';
+function GetUserDefaultUILanguage:LANGID; external KernelDLL name 'GetUserDefaultUILanguage'; // index 14B
 function GetUserNameEx(NameFormat:EXTENDED_NAME_FORMAT; lpNameBuffer:LPWSTR; nSize:PULONG):WINBOOL; external KernelDLL name 'GetUserNameExW';
 function GetUserNameEx(NameFormat:EXTENDED_NAME_FORMAT; lpNameBuffer:LPWSTR; nSize:PULONG):WINBOOL; external KernelDLL name 'GetUserNameExW';
 function GetUserNameExW(NameFormat:EXTENDED_NAME_FORMAT; lpNameBuffer:LPWSTR; nSize:PULONG):WINBOOL; external KernelDLL name 'GetUserNameExW';
 function GetUserNameExW(NameFormat:EXTENDED_NAME_FORMAT; lpNameBuffer:LPWSTR; nSize:PULONG):WINBOOL; external KernelDLL name 'GetUserNameExW';
 function GetVersionEx(VersionInformation:LPOSVERSIONINFOW):WINBOOL; external KernelDLL name 'GetVersionExW';
 function GetVersionEx(VersionInformation:LPOSVERSIONINFOW):WINBOOL; external KernelDLL name 'GetVersionExW';
@@ -2677,6 +2611,7 @@ function IsDBCSLeadByte(TestChar:BYTE):WINBOOL; external KernelDLL name 'IsDBCSL
 function IsDBCSLeadByteEx(CodePage:UINT; TestChar:BYTE):WINBOOL; external KernelDLL name 'IsDBCSLeadByteEx';
 function IsDBCSLeadByteEx(CodePage:UINT; TestChar:BYTE):WINBOOL; external KernelDLL name 'IsDBCSLeadByteEx';
 function IsDialogMessage(hDlg:HWND; lpMsg:LPMSG):WINBOOL; external KernelDLL name 'IsDialogMessageW';
 function IsDialogMessage(hDlg:HWND; lpMsg:LPMSG):WINBOOL; external KernelDLL name 'IsDialogMessageW';
 function IsDialogMessageW(hDlg:HWND; lpMsg:LPMSG):WINBOOL; external KernelDLL name 'IsDialogMessageW';
 function IsDialogMessageW(hDlg:HWND; lpMsg:LPMSG):WINBOOL; external KernelDLL name 'IsDialogMessageW';
+function IsProcessorFeaturePresent(dwProcessorFeature:DWORD):BOOL; external KernelDLL name 'IsProcessorFeaturePresent'; // index 339
 function IsRectEmpty(const lprc:RECT):WINBOOL; external KernelDLL name 'IsRectEmpty';
 function IsRectEmpty(const lprc:RECT):WINBOOL; external KernelDLL name 'IsRectEmpty';
 function IsValidCodePage(CodePage:UINT):WINBOOL; external KernelDLL name 'IsValidCodePage';
 function IsValidCodePage(CodePage:UINT):WINBOOL; external KernelDLL name 'IsValidCodePage';
 function IsValidLocale(Locale:LCID; dwFlags:DWORD):WINBOOL; external KernelDLL name 'IsValidLocale';
 function IsValidLocale(Locale:LCID; dwFlags:DWORD):WINBOOL; external KernelDLL name 'IsValidLocale';
@@ -2740,6 +2675,7 @@ function ListView_SortItems(hwndLV:HWND;_pfnCompare:PFNLVCOMPARE;_lPrm : LPARAM)
 function ListView_Update(hwndLV:HWND;i : longint) : LRESULT;
 function ListView_Update(hwndLV:HWND;i : longint) : LRESULT;
 function LoadAccelerators(hInstance:HINST; lpTableName:LPCWSTR):HACCEL; external KernelDLL name 'LoadAcceleratorsW';
 function LoadAccelerators(hInstance:HINST; lpTableName:LPCWSTR):HACCEL; external KernelDLL name 'LoadAcceleratorsW';
 function LoadAcceleratorsW(hInstance:HINST; lpTableName:LPCWSTR):HACCEL; external KernelDLL name 'LoadAcceleratorsW';
 function LoadAcceleratorsW(hInstance:HINST; lpTableName:LPCWSTR):HACCEL; external KernelDLL name 'LoadAcceleratorsW';
+function LoadAnimatedCursor(hInstance:HINST; ResourceId:DWORD; cFrames:longint; FrameTimeInterval:longint):HCURSOR; external KernelDLL name 'LoadAnimatedCursor'; // index 41E
 function LoadBitmap(hInstance:HINST; lpBitmapName:LPCWSTR):HBITMAP; external KernelDLL name 'LoadBitmapW';
 function LoadBitmap(hInstance:HINST; lpBitmapName:LPCWSTR):HBITMAP; external KernelDLL name 'LoadBitmapW';
 function LoadBitmapW(hInstance:HINST; lpBitmapName:LPCWSTR):HBITMAP; external KernelDLL name 'LoadBitmapW';
 function LoadBitmapW(hInstance:HINST; lpBitmapName:LPCWSTR):HBITMAP; external KernelDLL name 'LoadBitmapW';
 function LoadCursor(hInstance:HINST; lpCursorName:LPCWSTR):HCURSOR; external KernelDLL name 'LoadCursorW';
 function LoadCursor(hInstance:HINST; lpCursorName:LPCWSTR):HCURSOR; external KernelDLL name 'LoadCursorW';
@@ -2768,10 +2704,13 @@ function LocalLock(hMem:HLOCAL):LPVOID;
 function LocalReAlloc(hMem:HLOCAL; uBytes:UINT; uFlags:UINT):HLOCAL; external KernelDLL name 'LocalReAlloc';
 function LocalReAlloc(hMem:HLOCAL; uBytes:UINT; uFlags:UINT):HLOCAL; external KernelDLL name 'LocalReAlloc';
 function LocalSize(hMem:HLOCAL):UINT; external KernelDLL name 'LocalSize';
 function LocalSize(hMem:HLOCAL):UINT; external KernelDLL name 'LocalSize';
 function LocalUnlock(hMem:HLOCAL):WINBOOL;
 function LocalUnlock(hMem:HLOCAL):WINBOOL;
+function log(x:double):double; external KernelDLL name 'log'; // index 586
+function log10(x:double):double; external KernelDLL name 'log10'; // index 587
 function lstrcmp(lpString1:LPCWSTR; lpString2:LPCWSTR):longint; external KernelDLL name 'lstrcmpW';
 function lstrcmp(lpString1:LPCWSTR; lpString2:LPCWSTR):longint; external KernelDLL name 'lstrcmpW';
 function lstrcmpW(lpString1:LPCWSTR; lpString2:LPCWSTR):longint; external KernelDLL name 'lstrcmpW';
 function lstrcmpW(lpString1:LPCWSTR; lpString2:LPCWSTR):longint; external KernelDLL name 'lstrcmpW';
 function lstrcmpi(lpString1:LPCWSTR; lpString2:LPCWSTR):longint; external KernelDLL name 'lstrcmpiW';
 function lstrcmpi(lpString1:LPCWSTR; lpString2:LPCWSTR):longint; external KernelDLL name 'lstrcmpiW';
 function lstrcmpiW(lpString1:LPCWSTR; lpString2:LPCWSTR):longint; external KernelDLL name 'lstrcmpiW';
 function lstrcmpiW(lpString1:LPCWSTR; lpString2:LPCWSTR):longint; external KernelDLL name 'lstrcmpiW';
+function malloc(size:SIZE_T):LPVOID; external KernelDLL name 'malloc'; // index 58E
 function MapCallerPtr(ptr: LPVOID; dwLen: DWORD):LPVOID; external KernelDLL name 'MapCallerPtr';
 function MapCallerPtr(ptr: LPVOID; dwLen: DWORD):LPVOID; external KernelDLL name 'MapCallerPtr';
 function MapDialogRect(hDlg:HWND; lpRect:LPRECT):WINBOOL; external KernelDLL name 'MapDialogRect';
 function MapDialogRect(hDlg:HWND; lpRect:LPRECT):WINBOOL; external KernelDLL name 'MapDialogRect';
 function MapPtrToProcess(lpv: LPVOID; hProc: HANDLE ): LPVOID; external KernelDLL name 'MapPtrToProcess';
 function MapPtrToProcess(lpv: LPVOID; hProc: HANDLE ): LPVOID; external KernelDLL name 'MapPtrToProcess';
@@ -2782,6 +2721,12 @@ function MapVirtualKey(uCode:UINT; uMapType:UINT):UINT; external KernelDLL name
 function MapVirtualKeyW(uCode:UINT; uMapType:UINT):UINT; external KernelDLL name 'MapVirtualKeyW';
 function MapVirtualKeyW(uCode:UINT; uMapType:UINT):UINT; external KernelDLL name 'MapVirtualKeyW';
 function MapWindowPoints(hWndFrom:HWND; hWndTo:HWND; lpPoints:LPPOINT; cPoints:UINT):longint; external KernelDLL name 'MapWindowPoints';
 function MapWindowPoints(hWndFrom:HWND; hWndTo:HWND; lpPoints:LPPOINT; cPoints:UINT):longint; external KernelDLL name 'MapWindowPoints';
 function MaskBlt(_para1:HDC; _para2:longint; _para3:longint; _para4:longint; _para5:longint;_para6:HDC; _para7:longint; _para8:longint; _para9:HBITMAP; _para10:longint;_para11:longint; _para12:DWORD):WINBOOL; external KernelDLL name 'MaskBlt';
 function MaskBlt(_para1:HDC; _para2:longint; _para3:longint; _para4:longint; _para5:longint;_para6:HDC; _para7:longint; _para8:longint; _para9:HBITMAP; _para10:longint;_para11:longint; _para12:DWORD):WINBOOL; external KernelDLL name 'MaskBlt';
+function mbstowcs(wcstr:LPWSTR; mbstr:LPCSTR; count:SIZE_T):SIZE_T; external KernelDll name 'mbstowcs'; // index 66
+function memchr(buf:pointer; c:integer; count:SIZE_T):pointer; external KernelDll name 'memchr'; // index 2B
+function memcmp(buf1:LPCWSTR; buf2:LPCWSTR; count:SIZE_T):integer; external KernelDll name 'memcmp'; // index 591
+function memcpy(dest:pointer; src:pointer; count:SIZE_T):pointer; external KernelDll name 'memcpy';
+function memmove(dest:pointer; src:pointer; count:SIZE_T):pointer; external KernelDll name 'memmove';
+function memset(dest:LPWSTR; c:WideChar; count:SIZE_T):LPWSTR; external KernelDll name 'memset'; // index 595
 function MessageBeep(uType:UINT):WINBOOL; external KernelDLL name 'MessageBeep';
 function MessageBeep(uType:UINT):WINBOOL; external KernelDLL name 'MessageBeep';
 function MessageBox(hWnd:HWND; lpText:LPCWSTR; lpCaption:LPCWSTR; uType:UINT):longint; external KernelDLL name 'MessageBoxW'; //~winuser, result declared as int
 function MessageBox(hWnd:HWND; lpText:LPCWSTR; lpCaption:LPCWSTR; uType:UINT):longint; external KernelDLL name 'MessageBoxW'; //~winuser, result declared as int
 function MessageBoxW(hWnd:HWND; lpText:LPCWSTR; lpCaption:LPCWSTR; uType:UINT):longint; external KernelDLL name 'MessageBoxW'; //~winuser, result declared as int
 function MessageBoxW(hWnd:HWND; lpText:LPCWSTR; lpCaption:LPCWSTR; uType:UINT):longint; external KernelDLL name 'MessageBoxW'; //~winuser, result declared as int
@@ -2838,6 +2783,7 @@ function PurgeComm(hFile:HANDLE; dwFlags:DWORD):WINBOOL; external KernelDLL name
 function QueryPerformanceCounter(lpPerformanceCount:PLARGE_INTEGER):WINBOOL; external Kerneldll name 'QueryPerformanceCounter';
 function QueryPerformanceCounter(lpPerformanceCount:PLARGE_INTEGER):WINBOOL; external Kerneldll name 'QueryPerformanceCounter';
 function QueryPerformanceFrequency(lpFrequency:PLARGE_INTEGER):WINBOOL; external Kerneldll name 'QueryPerformanceFrequency';
 function QueryPerformanceFrequency(lpFrequency:PLARGE_INTEGER):WINBOOL; external Kerneldll name 'QueryPerformanceFrequency';
 procedure RaiseException(dwExceptionCode:DWORD; dwExceptionFlags:DWORD; nNumberOfArguments:DWORD; lpArguments:LPDWORD); external KernelDLL name 'RaiseException';
 procedure RaiseException(dwExceptionCode:DWORD; dwExceptionFlags:DWORD; nNumberOfArguments:DWORD; lpArguments:LPDWORD); external KernelDLL name 'RaiseException';
+function ReadFile(hFile:HANDLE; lpBuffer:LPVOID; nNumberOfBytesToRead:DWORD; lpNumberOfBytesRead:LPDWORD; lpOverlapped:LPOVERLAPPED):BOOL;  external KernelDLL name 'ReadFile'; // index F4
 function ReadProcessMemory(hProcess:HANDLE; lpBaseAddress:LPCVOID; lpBuffer:LPVOID; nSize:DWORD; lpNumberOfBytesRead:LPDWORD):WINBOOL; external KernelDLL name 'ReadProcessMemory';
 function ReadProcessMemory(hProcess:HANDLE; lpBaseAddress:LPCVOID; lpBuffer:LPVOID; nSize:DWORD; lpNumberOfBytesRead:LPDWORD):WINBOOL; external KernelDLL name 'ReadProcessMemory';
 function RealizePalette(_para1:HDC):UINT; external KernelDLL name 'RealizePalette';
 function RealizePalette(_para1:HDC):UINT; external KernelDLL name 'RealizePalette';
 function RectInRegion(_para1:HRGN; const _para2:RECT):WINBOOL; external KernelDLL name 'RectInRegion';
 function RectInRegion(_para1:HRGN; const _para2:RECT):WINBOOL; external KernelDLL name 'RectInRegion';
@@ -2864,6 +2810,9 @@ function RegisterClass(lpWndClass:LPWNDCLASS):ATOM; external KernelDLL name 'Reg
 function RegisterClassW(lpWndClass:LPWNDCLASS):ATOM; external KernelDLL name 'RegisterClassW';
 function RegisterClassW(lpWndClass:LPWNDCLASS):ATOM; external KernelDLL name 'RegisterClassW';
 function RegisterClipboardFormat(lpszFormat:LPCWSTR):UINT; external KernelDLL name 'RegisterClipboardFormatW';
 function RegisterClipboardFormat(lpszFormat:LPCWSTR):UINT; external KernelDLL name 'RegisterClipboardFormatW';
 function RegisterClipboardFormatW(lpszFormat:LPCWSTR):UINT; external KernelDLL name 'RegisterClipboardFormatW';
 function RegisterClipboardFormatW(lpszFormat:LPCWSTR):UINT; external KernelDLL name 'RegisterClipboardFormatW';
+function RegisterDevice(lpszType:LPCWSTR; dwIndex:DWORD; lpszLib:LPCWSTR; dwInfo:DWORD):HANDLE; external KernelDLL name 'RegisterDevice'; // index 14F
+function RegisterTaskBar(hwndTaskbar:HWND):BOOL; external KernelDLL name 'RegisterTaskBar'; // index 4D9
+function RegisterTaskBarEx(hwndTaskbar:HWND; bTaskBarOnTop:BOOL):BOOL; external KernelDLL name 'RegisterTaskBarEx'; // index 4DA
 function RegisterWindowMessage(lpString:LPCWSTR):UINT; external KernelDLL name 'RegisterWindowMessageW';
 function RegisterWindowMessage(lpString:LPCWSTR):UINT; external KernelDLL name 'RegisterWindowMessageW';
 function RegisterWindowMessageW(lpString:LPCWSTR):UINT; external KernelDLL name 'RegisterWindowMessageW';
 function RegisterWindowMessageW(lpString:LPCWSTR):UINT; external KernelDLL name 'RegisterWindowMessageW';
 function RegOpenKeyEx(hKey:HKEY; lpSubKey:LPCWSTR; ulOptions:DWORD; samDesired:REGSAM; phkResult:PHKEY):LONG; external KernelDLL name 'RegOpenKeyExW';
 function RegOpenKeyEx(hKey:HKEY; lpSubKey:LPCWSTR; ulOptions:DWORD; samDesired:REGSAM; phkResult:PHKEY):LONG; external KernelDLL name 'RegOpenKeyExW';
@@ -2888,6 +2837,7 @@ function RemoveFontResource(_para1:LPCWSTR):WINBOOL; external KernelDLL name 'Re
 function RemoveFontResourceW(_para1:LPCWSTR):WINBOOL; external KernelDLL name 'RemoveFontResourceW';
 function RemoveFontResourceW(_para1:LPCWSTR):WINBOOL; external KernelDLL name 'RemoveFontResourceW';
 function RemoveMenu(hMenu:HMENU; uPosition:UINT; uFlags:UINT):WINBOOL; external KernelDLL name 'RemoveMenu';
 function RemoveMenu(hMenu:HMENU; uPosition:UINT; uFlags:UINT):WINBOOL; external KernelDLL name 'RemoveMenu';
 function RemoveProp(hWnd:HWND; lpString:LPCWSTR):HANDLE; external KernelDLL name 'RemoveProp';
 function RemoveProp(hWnd:HWND; lpString:LPCWSTR):HANDLE; external KernelDLL name 'RemoveProp';
+function RequestDeviceNotifications(devclass:LPGUID; hMsgQ:HANDLE; fAll:BOOL):HANDLE; external KernelDLL name 'RequestDeviceNotifications'; // index 155
 function ResetEvent(hEvent:HANDLE):WINBOOL;
 function ResetEvent(hEvent:HANDLE):WINBOOL;
 function RestoreDC(_para1:HDC; _para2:longint):WINBOOL; external KernelDLL name 'RestoreDC';
 function RestoreDC(_para1:HDC; _para2:longint):WINBOOL; external KernelDLL name 'RestoreDC';
 function ResumeThread(hThread:HANDLE):DWORD; external KernelDLL name 'ResumeThread';
 function ResumeThread(hThread:HANDLE):DWORD; external KernelDLL name 'ResumeThread';
@@ -2946,6 +2896,8 @@ function SetMenuItemInfo(_para1:HMENU; _para2:UINT; _para3:WINBOOL; _para4:LPCME
 function SetMenuItemInfoW(_para1:HMENU; _para2:UINT; _para3:WINBOOL; _para4:LPCMENUITEMINFO):WINBOOL; external KernelDLL name 'SetMenuItemInfoW';
 function SetMenuItemInfoW(_para1:HMENU; _para2:UINT; _para3:WINBOOL; _para4:LPCMENUITEMINFO):WINBOOL; external KernelDLL name 'SetMenuItemInfoW';
 function SetPaletteEntries(_para1:HPALETTE; _para2:UINT; _para3:UINT; var _para4:PALETTEENTRY):UINT; external KernelDLL name 'SetPaletteEntries';
 function SetPaletteEntries(_para1:HPALETTE; _para2:UINT; _para3:UINT; var _para4:PALETTEENTRY):UINT; external KernelDLL name 'SetPaletteEntries';
 function SetParent(hWndChild:HWND; hWndNewParent:HWND):HWND; external KernelDLL name 'SetParent';
 function SetParent(hWndChild:HWND; hWndNewParent:HWND):HWND; external KernelDLL name 'SetParent';
+function SetPassword(lpszOldPassword:LPWSTR; lpszNewPassword:LPWSTR):BOOL; external KernelDLL name 'SetPassword'; // index 10C
+function SetPasswordActive(bActive:BOOL; lpszPassword:LPWSTR):BOOL; external KernelDLL name 'SetPasswordActive'; // index 10E
 function SetPixel(_para1:HDC; _para2:longint; _para3:longint; _para4:COLORREF):COLORREF; external KernelDLL name 'SetPixel';
 function SetPixel(_para1:HDC; _para2:longint; _para3:longint; _para4:COLORREF):COLORREF; external KernelDLL name 'SetPixel';
 function SetProp(hWnd:HWND; lpString:LPCWSTR; hData:HANDLE):WINBOOL; external KernelDLL name 'SetProp';
 function SetProp(hWnd:HWND; lpString:LPCWSTR; hData:HANDLE):WINBOOL; external KernelDLL name 'SetProp';
 function SetRect(lprc:LPRECT; xLeft:longint; yTop:longint; xRight:longint; yBottom:longint):WINBOOL; external KernelDLL name 'SetRect';
 function SetRect(lprc:LPRECT; xLeft:longint; yTop:longint; xRight:longint; yBottom:longint):WINBOOL; external KernelDLL name 'SetRect';
@@ -3024,6 +2976,7 @@ function TlsCall(p1:DWORD; p2:DWORD):DWORD; external KernelDLL name 'TlsCall';
 function TlsFree(dwTlsIndex:DWORD):WINBOOL;
 function TlsFree(dwTlsIndex:DWORD):WINBOOL;
 function TlsGetValue(dwTlsIndex:DWORD):LPVOID; external KernelDLL name 'TlsGetValue';
 function TlsGetValue(dwTlsIndex:DWORD):LPVOID; external KernelDLL name 'TlsGetValue';
 function TlsSetValue(dwTlsIndex:DWORD; lpTlsValue:LPVOID):WINBOOL; external KernelDLL name 'TlsSetValue';
 function TlsSetValue(dwTlsIndex:DWORD; lpTlsValue:LPVOID):WINBOOL; external KernelDLL name 'TlsSetValue';
+function TouchCalibrate:BOOL; external KernelDLL name 'TouchCalibrate'; // index 4C7
 function TrackPopupMenu(hMenu:HMENU; uFlags:UINT; x:longint; y:longint; nReserved:longint;hWnd:HWND; prcRect: PRect):WINBOOL;
 function TrackPopupMenu(hMenu:HMENU; uFlags:UINT; x:longint; y:longint; nReserved:longint;hWnd:HWND; prcRect: PRect):WINBOOL;
 function TrackPopupMenuEx(_para1:HMENU; _para2:UINT; _para3:longint; _para4:longint; _para5:HWND;_para6:LPTPMPARAMS):WINBOOL; external KernelDLL name 'TrackPopupMenuEx';
 function TrackPopupMenuEx(_para1:HMENU; _para2:UINT; _para3:longint; _para4:longint; _para5:HWND;_para6:LPTPMPARAMS):WINBOOL; external KernelDLL name 'TrackPopupMenuEx';
 function TranslateAccelerator(hWnd:HWND; hAccTable:HACCEL; lpMsg:LPMSG):longint; external KernelDLL name 'TranslateAcceleratorW';
 function TranslateAccelerator(hWnd:HWND; hAccTable:HACCEL; lpMsg:LPMSG):longint; external KernelDLL name 'TranslateAcceleratorW';
@@ -3115,6 +3068,27 @@ function WNetGetUser(lpName:LPCWSTR; lpUserName:LPWSTR; lpnLength:LPDWORD):DWORD
 function WNetGetUserW(lpName:LPCWSTR; lpUserName:LPWSTR; lpnLength:LPDWORD):DWORD; external KernelDLL name 'WNetGetUserW';
 function WNetGetUserW(lpName:LPCWSTR; lpUserName:LPWSTR; lpnLength:LPDWORD):DWORD; external KernelDLL name 'WNetGetUserW';
 function WNetOpenEnum(dwScope:DWORD; dwType:DWORD; dwUsage:DWORD; lpNetResource:LPNETRESOURCEW; lphEnum:LPHANDLE):DWORD; external KernelDLL name 'WNetOpenEnumW';
 function WNetOpenEnum(dwScope:DWORD; dwType:DWORD; dwUsage:DWORD; lpNetResource:LPNETRESOURCEW; lphEnum:LPHANDLE):DWORD; external KernelDLL name 'WNetOpenEnumW';
 function WNetOpenEnumW(dwScope:DWORD; dwType:DWORD; dwUsage:DWORD; lpNetResource:LPNETRESOURCEW; lphEnum:LPHANDLE):DWORD; external KernelDLL name 'WNetOpenEnumW';
 function WNetOpenEnumW(dwScope:DWORD; dwType:DWORD; dwUsage:DWORD; lpNetResource:LPNETRESOURCEW; lphEnum:LPHANDLE):DWORD; external KernelDLL name 'WNetOpenEnumW';
+function WriteFile(hFile:HANDLE; lpBuffer:LPCVOID; nNumberOfBytesToWrite:DWORD; lpNumberOfBytesWritten:LPDWORD; lpOverlapped:LPOVERLAPPED):BOOL; external KernelDLL name 'WriteFile';
+function wcscat(strDestination:PWideChar; strSource:PWideChar):PWideChar; external KernelDLL name 'wcscat'; // index 54
+function wcschr(_string:PWideChar; c:WideChar):PWideChar; external KernelDLL name 'wcschr'; // index 55
+function wcscmp(string1:PWideChar; string2:PWideChar):longint; external KernelDLL name 'wcscmp'; // index 56
+function wcscpy(strDestination:PWideChar; strSource:PWideChar):PWideChar; external KernelDLL name 'wcscpy'; // index 57
+function wcscspn(_string:PWideChar; strCharSet:PWideChar):SIZE_T; external KernelDLL name 'wcscspn'; // index 58
+
+// Returns the number of characters in string, excluding the terminal NULL.
+function wcslen(_string:PWideChar):SIZE_T; external KernelDLL name 'wcslen'; // index 59
+function wcsncat(strDest:PWideChar; strSource:PWideChar; _count:SIZE_T):PWideChar; external KernelDLL name 'wcsncat'; // index 5A
+function wcsncmp(string1:PWideChar; string2:PWideChar; _count:SIZE_T):longint; external KernelDLL name 'wcsncmp'; // index 5B
+function wcsncpy(strDest:PWideChar; strSource:PWideChar; _count:SIZE_T):PWideChar; external KernelDLL name 'wcsncpy'; // index 5C
+function wcspbrk(_string:PWideChar; strCharSet:PWideChar):PWideChar; external KernelDLL name 'wcspbrk'; // index 5E
+function wcsrchr(_string:PWideChar; c:longint):PWideChar; external KernelDLL name 'wcsrchr'; // index 5F
+function wcsspn(_string:PWideChar; strCharSet:PWideChar):SIZE_T; external KernelDLL name 'wcsspn'; // index 62
+function wcsstr(_string:PWideChar; strCharSet:PWideChar):PWideChar; external KernelDLL name 'wcsstr'; // index 63
+function wcstod(nptr:PWideChar; var endptr:PWideChar):double; external KernelDLL name 'wcstod'; // index 5B5
+function wcstok(strToken:PWideChar; strDelimit:PWideChar):PWideChar; external KernelDLL name 'wcstok'; // index 67
+function wcstol(nptr:PWideChar; var endptr:PWideChar; _base:longint):longint; external KernelDLL name 'wcstol'; // index 5B6
+function wcstombs(mbstr:PChar; wcstr:PWideChar; _count:SIZE_T):SIZE_T; external KernelDLL name 'wcstombs'; // index 65
+function wcstoul(nptr:PWideChar; var endptr:PWideChar; _base:longint):Cardinal; external KernelDLL name 'wcstoul'; // index 5B7
 function wsprintf(lpBuffer:LPWSTR; lpFormat:LPCWSTR; const args:array of const):longint; external KernelDLL name 'wsprintfW';
 function wsprintf(lpBuffer:LPWSTR; lpFormat:LPCWSTR; const args:array of const):longint; external KernelDLL name 'wsprintfW';
 function wsprintfW(lpBuffer:LPWSTR; lpFormat:LPCWSTR; const args:array of const):longint; external KernelDLL name 'wsprintfW';
 function wsprintfW(lpBuffer:LPWSTR; lpFormat:LPCWSTR; const args:array of const):longint; external KernelDLL name 'wsprintfW';
 function wsprintf(lpBuffer:LPWSTR; lpFormat:LPCWSTR):longint; external KernelDLL name 'wsprintfW';
 function wsprintf(lpBuffer:LPWSTR; lpFormat:LPCWSTR):longint; external KernelDLL name 'wsprintfW';
@@ -4206,6 +4180,13 @@ begin
   Result := ImageList_LoadImage(Instance, Bmp, CX, Grow, Mask, IMAGE_BITMAP, 0);
   Result := ImageList_LoadImage(Instance, Bmp, CX, Grow, Mask, IMAGE_BITMAP, 0);
 end;
 end;
 
 
+function GetDllVersion(hMod:HMODULE):DWORD; inline;
+begin
+ // GetProcessVersion now takes module handle
+ // as parameter as well as process id.
+  Result:=GetProcessVersion(DWORD(hMod));
+end;
+
 {$endif read_implementation}
 {$endif read_implementation}