Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Delphi & WinCE

Posted on 1998-08-14
4
1,658 Views
Last Modified: 2008-02-01
Can D4 be used to write applications (even simple ones) that will run on WinCE devices?
0
Comment
Question by:Raven1155
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 100 total points
ID: 1362153
Raven1155,

You can't. 1) Windows CE uses a subset of the Windows 32 API, and
Delphi uses the full API; 2) many Windows CE machines don't run onIntel processors, and the Delphi compiler produces Intel machine code.
Many, many people have requested that Borland produce a Delphi version which supports CE, but Borland hasn't formally announced any plans to do so.

So, I guess the answer to your question is, pittyful NO. Sorry.

Regards, Zif.
0
 

Author Comment

by:Raven1155
ID: 1362154
Thank you very much for your answer.  It's what I expected, but you gave me details that I didn't know!
0
 

Expert Comment

by:scrossen
ID: 1362155
I wrote a delphi API to RAPI, the remote API for wince. It allows you to connect to a win ce device and then copy files, update the registry, etc.  Here it is if you're interested:
unit rapi;

interface

uses Windows, Sysutils;
//
// Module:
//
//     rapi.h
//
// Purpose:
//
//    Master include file for Pegasus Remote API
//    Converted to Delphi by Scott Crossen  2/27/97
//    If you make changes to this file, please e-mail me so that I can add the
//    changes to this file. - mailto:scrossen@hotmail.com
//    I release this file to the public domain
// --------------------------------------------------------------------------

const
FAF_ATTRIBUTES      = $00000001;
FAF_CREATION_TIME   = $00000002;
FAF_LASTACCESS_TIME = $00000004;
FAF_LASTWRITE_TIME  = $00000008;
FAF_SIZE_HIGH       = $00000010;
FAF_SIZE_LOW        = $00000020;
FAF_OID             = $00000040;
FAF_NAME            = $00000080;
FAF_FLAG_COUNT      = 8;
FAF_ATTRIB_CHILDREN = $00001000;
FAF_ATTRIB_NO_HIDDEN = $00002000;
FAF_FOLDERS_ONLY    = $00004000;
FAF_NO_HIDDEN_SYS_ROMMODULES = $00008000;

FAD_OID             =$1;
FAD_FLAGS           =$2;
FAD_NAME            =$4;
FAD_TYPE            =$8;
FAD_NUM_RECORDS     =$10;
FAD_NUM_SORT_ORDER  =$20;
FAD_SIZE            =$40;
FAD_LAST_MODIFIED   =$80;
FAD_SORT_SPECS      =$100;
FAD_FLAG_COUNT      =$9;

PEGDB_SORT_DESCENDING       =  $00000001 ;
PEGDB_SORT_CASEINSENSITIVE  =  $00000002 ;
PEGDB_SORT_UNKNOWNFIRST     =  $00000004 ;
PEGDB_SORT_GENERICORDER     =  $00000008 ;

PEGDB_MAXDBASENAMELEN  =32 ;
PEGDB_MAXSORTORDER     =4  ;

PEGDB_VALIDNAME     =$0001 ;
PEGDB_VALIDTYPE     =$0002 ;
PEGDB_VALIDSORTSPEC =$0004 ;
PEGDB_VALIDMODTIME  =$0008 ;
OBJTYPE_INVALID     =0;
OBJTYPE_FILE        =1;
OBJTYPE_DIRECTORY   =2;
OBJTYPE_DATABASE    =3;
OBJTYPE_RECORD      =4;

PEGDB_AUTOINCREMENT    = $00000001;

PEGDB_SEEK_PEGOID      = $00000001 ;
PEGDB_SEEK_BEGINNING   = $00000002 ;
PEGDB_SEEK_END         = $00000004 ;
PEGDB_SEEK_CURRENT     = $00000008 ;
PEGDB_SEEK_VALUESMALLER    = $00000010 ;
PEGDB_SEEK_VALUEFIRSTEQUAL = $00000020 ;
PEGDB_SEEK_VALUEGREATER    = $00000040 ;
PEGDB_SEEK_VALUENEXTEQUAL  = $00000080  ;
PEGVT_I2       =2 ;
PEGVT_UI2      =18;
PEGVT_I4       =3 ;
PEGVT_UI4      =19;
PEGVT_FILETIME =64;
PEGVT_LPWSTR   =31;
PEGVT_BLOB     =65;
PEGDB_PROPNOTFOUND =$0100;
PEGDB_PROPDELETE   =$0200;
PEGDB_MAXDATABLOCKSIZE  =4092 ;
PEGDB_MAXPROPDATASIZE   =(PEGDB_MAXDATABLOCKSIZE*16);
PEGDB_MAXRECORDSIZE     =(128*1024);

PEGDB_ALLOWREALLOC  =$00000001;

SYSMEM_CHANGED      =0;
SYSMEM_MUSTREBOOT =1;
SYSMEM_REBOOTPENDING =2;
SYSMEM_FAILED =3;
AC_LINE_OFFLINE                = $00;
AC_LINE_ONLINE                 = $01;
AC_LINE_BACKUP_POWER           = $02;
AC_LINE_UNKNOWN                = $FF;

BATTERY_FLAG_HIGH               =$01 ;
BATTERY_FLAG_LOW                =$02 ;
BATTERY_FLAG_CRITICAL           =$04 ;
BATTERY_FLAG_CHARGING           =$08 ;
BATTERY_FLAG_NO_BATTERY         =$80 ;
BATTERY_FLAG_UNKNOWN            =$FF ;

BATTERY_PERCENTAGE_UNKNOWN      =$FF;

BATTERY_LIFE_UNKNOWN        =$FFFFFFFF;

type

//
// The Pegasus WIN32_FIND_DATA structure differs from the
// Windows WIN32_FIND_DATA stucture so we copy the Pegasus
// definition to here so that both sides match.
//

PPeg_Find_Data = ^TPeg_Find_Data;
TPeg_Find_Data = record
    dwFileAttributes:DWORD;
    ftCreationTime:TFileTime;
    ftLastAccessTime:TFileTime;
    ftLastWriteTime:TFileTime;
    nFileSizeHigh:DWORD;
    nFileSizeLow:DWORD;
    dwOID:DWord;
    cFileName: array[0..MAX_PATH - 1] of WideChar;
end;
TPeg_Find_Data_array = array[0..MaxInt div sizeof(TPeg_Find_Data)-1] of TPeg_Find_Data;
PPeg_Find_Data_array = ^TPeg_Find_Data_array;

PStore_Information = ^TStore_Information;
TStore_Information = record
      dwStoreSize:DWORD;
      dwFreeSize:DWORD;
end;

PEGPROPID = DWORD;
PPEGPROPID = ^PPEGPROPID;
TPeg_PropID_array = array[0..MaxInt div sizeof(PEGPROPID)-1] of PEGPROPID;
PPeg_PropID_array = ^TPeg_PropID_array;

PEGOID=DWORD;
PPEGOID = ^PEGOID;

TPegFileInfo = record
    dwAttributes:DWORD;
    oidParent:PEGOID;
    szFileName: array [0..MAX_PATH-1] of WCHAR;
    ftLastChanged:TFileTime;
    dwLength:DWORD;
end;

TPegDirInfo = record
    dwAttributes:DWORD;
    oidParent:PEGOID;
    szDirName:array [0..MAX_PATH-1] of WCHAR;
end;

TPegRecordInfo = record
    oidParent:PEGOID;
end;

TSortOrderSpec= record
    propid:PEGPROPID;
    dwFlags:DWORD;
end;

TPegDBaseInfo = record
    dwFlags:DWORD;
    szDbaseName:array [0..PEGDB_MAXDBASENAMELEN-1] of WCHAR  ;
    dwDbaseType:DWORD;
    wNumRecords:WORD;
    wNumSortOrder:WORD;
    dwSize:DWORD;
    ftLastModified:TFileTime;
    rgSortSpecs:array [0..PEGDB_MAXSORTORDER-1] of TSortOrderSpec;
end;

TPegDB_File_Data = record
    OidDb:PEGOID ;
    DbInfo:TPegDBaseInfo ;
end;
PPegDB_File_Data=^TPegDB_File_Data;

TPegDB_File_Data_Array = array [0..MaxInt div sizeof(TPegDB_File_Data) -1] of TPegDB_File_Data;
PPegDB_File_Data_Array = ^TPegDB_File_Data_Array;

TPegOIdInfo = record
    wObjType:WORD;
    wPad:WORD;
    case Integer of
    0:(
        infFile:TPegFileInfo );
    1: (
        infDirectory:TPEGDIRINFO);
    2: (
        infDatabase:TPEGDBASEINFO );
    3: (
        infRecord:TPEGRECORDINFO);
end;

TPegBlob = record
    dwCount:DWORD;
    lpb:DWORD;
end;


TPegValUnion = record
    iVal:SHORT;
    uiVal:WORD;
    lVal:LongInt  ;
    ulVal:ULONG ;
    fletime:TFileTime;
    lpwstr:LPWSTR;
    blob:TPegBlob ;
end;

TPEGPROPVAL = record
    propid:PegPROPID ;
    wLenData:Word;
    wFlags:WORD;
    val:TPEGVALUNION;
end;


TPegOSVersionInfo= record
   wOSVersionInfoSize:DWORD;
   dwMajorVersion:DWORD;
   dwMinorVersion:DWORD;
   dwBuildNumber:DWORD;
   dwPlatformId:DWORD;
   szCSDVersion:array[ 0..128-1 ] of WCHAR;
end;
PPegOSVersionInfo = ^TPegOSVersionInfo;

TSystem_Power_Status_Ex = record
    ACLineStatus:BYTE;
    BatteryFlag:BYTE;
    BatteryLifePercent:BYTE;
    Reserved1:BYTE;
    BatteryLifeTime:BYTE;
    BatteryFullLifeTime:BYTE;
    Reserved2:BYTE;
    BackupBatteryFlag:BYTE;
    BackupBatteryLifePercent:BYTE;
    Reserved3:BYTE;
    BackupBatteryLifeTime:DWORD;
    BackupBatteryFullLifeTime:DWORD;
end;
PSystem_Power_Status_Ex=^TSystem_Power_Status_Ex;
TSystem_Power_Status_ExArray = array [0..MaxInt div Sizeof(TSystem_Power_Status_Ex) -1] of TSystem_Power_Status_Ex;
PSystem_Power_Status_ExArray =^TSystem_Power_Status_ExArray;

TRapiInit = record
    cbSize:DWORD;
    heRapiInit:THandle;
    hrRapiInit:HResult;
end;



TPegRapiInit = function : LongInt stdcall;
TPegRapiInitEx = function(var RInit:TRapiInit) : LongInt stdcall;
TPegCreateDatabase  = function  (lpszName:LPWSTR; dwDbaseType:DWORD; wNumSortOrder:WORD;
   var rgSortSpecs:TSortOrderSpec):PEGOID stdcall;
TPegDeleteDatabase = function(oidDBase:PegOId):BOOL stdcall;
TPegDeleteRecord = function(hDatabase:THandle; oidRecord:PEGOID):BOOL stdcall;
TPegFindFirstDatabase = function(dwDbaseType:DWORD):THandle stdcall;
TPegFindNextDatabase  =function(hEnum:THandle):PEGOID stdcall;
TPegOidGetInfo        =function(oid:PEGOID; var poidInfo:TPEGOIDINFO):BOOL stdcall;
TPegOpenDatabase      =function(var poid:PEGOID; lpszName:LPWSTR; propid:PEGPROPID;
        dwFlags:DWORD; hwndNotify:HWND):THandle stdcall;
TPegReadRecordProps   =function(hDbase:THandle; dwFlags:DWORD;var cPropID :WORD;
     var rgPropID :PPeg_PropID_array;Buffer:Pointer; var cbBuffer:DWORD):PEGOID stdcall;
TPegSeekDatabase      =function(hDatabase:THandle; dwSeekType:DWORD; dwValue:LongInt;
  dwIndex:PDWORD):PEGOID stdcall;
TPegSetDatabaseInfo   =function(oidDbase:PEGOID; var NewInfo:TPegDBaseInfo):BOOL stdcall;
TPegWriteRecordProps  =function(hDbase:THandle; oidRecord:PEGOID; cPropID:WORD; PropVal:TPEGPROPVAL):PEGOID stdcall;
TPegFindFirstFile     =function(lpFileName:LPCWSTR; lpFindFileData:PPEG_FIND_DATA):THandle stdcall;
TPegFindNextFile      =function(hFindFile:THandle; lpFindFileData:PPEG_FIND_DATA):BOOL stdcall;
TPegFindClose         =function(hFindFile:THandle):BOOL stdcall;
TPegGetFileAttributes =function(lpFileName:LPCWSTR):DWORD stdcall;
TPegSetFileAttributes =function(FileName:LPCWSTR; dwFileAttributes:DWORD):BOOL stdcall;
TPegCreateFile        =function(lpFileName:LPCWSTR; dwDesiredAccess:DWORD; dwShareMode: DWORD;
     lpSecurityAttributes: PSecurityAttributes; dwCreationDistribution:DWORD;
     dwFlagsAndAttributes:DWORD;hTemplateFile:THandle):THandle stdcall;
TPegReadFile          =function(hFile:THandle; lpBuffer:Pointer; nNumberOfBytesToRead:DWORD;
     var NumberOfBytesRead :DWORD; Overlapped:POVERLAPPED):BOOL stdcall;
TPegWriteFile         =function(hFile:THandle; Buffer:Pointer; NumberOfBytesToWrite:DWORD;
     var NumberOfBytesWritten:DWORD; OverLapped:POVERLAPPED):BOOL stdcall;
TPegCloseHandle       =function(hObject:THandle):BOOL stdcall;
TPegFindAllDatabases  =function(dwDbaseType:DWORD; wFlags:WORD; var cFindData:DWORD; var ppFindData:PPegDB_File_Data_Array):BOOL stdcall;
TPegGetLastError      =function :DWORD stdcall;
TGetRapiError         = function : LongInt stdcall ;
TPegSetFilePointer    =function(hFile:THandle; DistanceToMove:LongInt; DistanceToMoveHigh:PULONG;
     dwMoveMethod:DWORD):DWORD stdcall;
TPegSetEndOfFile      =function(hFile:THandle):BOOL stdcall;
TPegCreateDirectory   =function(lpPathName:LPCWSTR; lpSecurityAttributes:PSecurityAttributes):BOOL stdcall;
TPegRemoveDirectory   =function(PathName:LPCWSTR):BOOL stdcall;
TPegCreateProcess     =function(lpApplicationName:LPCWSTR;lpCommandLine:LPCWSTR; lpProcessAttributes:PSecurityAttributes;
   lpThreadAttributes:PSecurityAttributes;bInheritHandles :BOOL;dwCreateFlags :DWORD; lpEnvironment:Pointer; lpCurrentDirectory :LPWSTR;
   lpStartupInfo:PSTARTUPINFO; lpProcessInformation:PProcessInformation):BOOL stdcall;
TPegMoveFile          =function(lpExistingFileName:LPCWSTR; lpNewFileName:LPCWSTR):BOOL stdcall;
TPegCopyFile          =function(lpExistingFileName:LPCWSTR; lpNewFileName:LPCWSTR; bFailIfExists:BOOL):BOOL stdcall;
TPegDeleteFile        =function(lpFileName:LPCWSTR):BOOL stdcall;
TPegGetFileSize       =function(hFile:THandle; lpFileSizeHigh:PDWORD):DWORD stdcall;
TPegRegOpenKeyEx      =function(hKey:HKEY; SubKey:LPCWSTR; Reserved:DWORD; samDesired:REGSAM;
     Result:PHKEY):LongInt stdcall;
TPegRegEnumKeyEx      =function(hKey:HKEY; dwIndex:DWORD; KeyName:LPWSTR; chName:PDWORD;
  reserved:PDWORD; szClass:LPWSTR; cchClass:PDWORD; ftLastWrite:PFILETIME):LongInt stdcall;
TPegRegCreateKeyEx    =function(hKey:HKEY; lpSzSubKey:LPCWSTR; dwReserved:DWORD;
     lpszClass:LPWSTR; dwOption:DWORD; samDesired:REGSAM; lpSecurityAttributes:PSecurityAttributes;
      phkResult:PHKEY; lpdwDisposition:PDWORD):LongInt stdcall;
TPegRegCloseKey       =function(hKey:HKEY):LongInt stdcall;
TPegRegDeleteKey      =function(hKey:HKEY; lpszSubKey:LPCWSTR):LongInt stdcall;
TPegRegEnumValue      =function(hKey:HKEY; dwIndex:DWORD; lpszName:LPWSTR; lpcchName:PDWORD;
     lpReserved:PDWORD; lpszClass:PDWORD; lpcchClass:PBYTE; lpftLastWrite:PDWORD):LongInt stdcall;
TPegRegDeleteValue    =function(hKey:HKEY; lpszValueName:LPCWSTR):LongInt stdcall;
TPegRegQueryInfoKey   =function(hKey:HKEY; ClassName:LPWSTR; cchClass:PDWORD; Reserved:PDWORD;
     cSubKeys:PDWORD; cchMaxSubKeyLen:PDWORD; cchMaxClassLen:PDWORD; cValues:PDWORD;
     cchMaxValueNameLen:PDWORD; cbMaxValueData:PDWORD; cbSecurityDescriptor:PDWORD;
     LastWriteTime:PFILETIME):LongInt stdcall;
TPegRegQueryValueEx   =function(hKey:HKEY; ValueName:LPCWSTR; Reserved:PDWORD; pType:PDWORD;
     pData:PBYTE; cbData:PDWORD):LongInt stdcall;
TPegRegSetValueEx     =function(hKey:HKEY; ValueName:LPCWSTR; reserved:DWORD;
     dwType:DWORD; pData:PBYTE; cbData:DWORD):LongInt stdcall;
TPegGetStoreInformation=function(lpsi:PSTORE_INFORMATION):BOOL stdcall;
TPegGetSystemMetrics  =function(nIndex:Integer):Integer stdcall;
TPegGetDesktopDeviceCaps=function(nIndedx:Integer):LongInt stdcall;
TPegGetSystemInfo     =procedure (lpSystemInfo:PSystemInfo)stdcall;
TPegSHCreateShortcut  =function(ShortCut:LPWSTR; Target:LPWSTR):DWORD stdcall;
TPegSHGetShortcutTarget=function(ShortCut:LPWSTR; Target:LPWSTR; cbMax:integer):BOOL stdcall;
TPegCheckPassword     =function(lpszPassword:LPWSTR):BOOL stdcall;
TPegGetFileTime       =function(hFile:THandle; lpCreationTime:PFILETIME;
  lpLastAccessTime:PFILETIME; lpLastWriteTime:PFILETIME):BOOL stdcall;
TPegSetFileTime       =function(hFile:THandle; CreationTime:PFILETIME;
     LastAccessTime:PFILETIME; lastWriteTime:PFILETIME):BOOL stdcall;
TPegGetVersionEx      =function(lpVersionInfo:PPEGOSVERSIONINFO):BOOL stdcall;
TPegGetWindow         =function(hWnd:HWND; uCmd:UINT):HWND stdcall;
TPegGetWindowLong     =function(hWnd:HWND; nIndex:integer):LongInt stdcall;
TPegGetWindowText     =function(hWnd:HWND; lpString:LPWSTR; nMaxCount:integer):Integer stdcall;
TPegGetClassName      =function(hWnd:HWND; lpClassName:LPWSTR; nMaxCount:integer):Integer stdcall;
TPegGlobalMemoryStatus = procedure(lpmst:PMemoryStatus)stdcall;
TPegGetSystemPowerStatusEx=function(pStatus:PSYSTEM_POWER_STATUS_EX; fUpdate:BOOL):BOOL stdcall;



TPegRapiUnInit = function : LongInt stdcall;
TPegFindAllFiles =function(Path:PWideChar; Attr:DWORD; var Count:DWord;
        var FindData: PPeg_Find_Data_array):BOOL stdcall;
TRapiFreeBuffer = procedure (p:Pointer) stdcall;

function PegRapiInit:LongInt;
function PegRapiUnInit:LongInt;
function PegFindAllFiles(Path:PWideChar; Attr:DWORD;
        var Count:DWord; var FindData:PPeg_Find_Data_array):BOOL;
procedure RapiFreeBuffer(p:Pointer);
function PegRapiInitEx(var RInit:TRapiInit) : LongInt ;
function PegCreateDatabase (lpszName:LPWSTR; dwDbaseType:DWORD; wNumSortOrder:WORD;
   var rgSortSpecs:TSortOrderSpec):PEGOID ;
function PegDeleteDatabase (oidDBase:PegOId):BOOL ;
function PegDeleteRecord (hDatabase:THandle; oidRecord:PEGOID):BOOL ;
function PegFindFirstDatabase (dwDbaseType:DWORD):THandle ;
function PegFindNextDatabase(hEnum:THandle):PEGOID ;
function PegOidGetInfo (oid:PEGOID; var poidInfo:TPegOIDINFO):BOOL ;
function PegOpenDatabase    (var poid:PEGOID; lpszName:LPWSTR; propid:PEGPROPID;
        dwFlags:DWORD; hwndNotify:HWND):THandle ;
function PegReadRecordProps (hDbase:THandle; dwFlags:DWORD;var cPropID :WORD;
     var rgPropID :PPeg_PropID_array; Buffer:Pointer; var cbBuffer:DWORD):PEGOID ;
function PegSeekDatabase    (hDatabase:THandle; dwSeekType:DWORD; dwValue:LongInt;
  dwIndex:PDWORD):PEGOID ;
function PegSetDatabaseInfo (oidDbase:PEGOID; var NewInfo:TPegDBaseInfo):BOOL ;
function PegWriteRecordProps(hDbase:THandle; oidRecord:PEGOID; cPropID:WORD; PropVal:TPegPROPVAL):PEGOID ;
function PegFindFirstFile(lpFileName:LPCWSTR; lpFindFileData:PPEG_FIND_DATA):THandle ;
function PegFindNextFile(hFindFile:THandle; lpFindFileData:PPEG_FIND_DATA):BOOL ;
function PegFindClose       (hFindFile:THandle):BOOL ;
function PegGetFileAttributes (lpFileName:LPCWSTR):DWORD ;
function PegSetFileAttributes (FileName:LPCWSTR; dwFileAttributes:DWORD):BOOL ;
function PegCreateFile      (lpFileName:LPCWSTR; dwDesiredAccess:DWORD; dwShareMode: DWORD;
     lpSecurityAttributes: PSecurityAttributes; dwCreationDistribution:DWORD;
     dwFlagsAndAttributes:DWORD;hTemplateFile:THandle):THandle ;
function PegReadFile (hFile:THandle; lpBuffer:Pointer; nNumberOfBytesToRead:DWORD;
     var NumberOfBytesRead :DWORD; Overlapped:POVERLAPPED):BOOL ;
function PegWriteFile       (hFile:THandle; Buffer:Pointer; NumberOfBytesToWrite:DWORD;
     var NumberOfBytesWritten:DWORD; OverLapped:POVERLAPPED):BOOL ;
function PegCloseHandle     (hObject:THandle):BOOL ;
function PegFindAllDatabases(dwDbaseType:DWORD; wFlags:WORD; var cFindData:DWORD;var ppFindData:PPegDB_File_Data_Array):BOOL ;
function PegGetLastError       :DWORD ;
function GetRapiError : LongInt  ;
function PegSetFilePointer  (hFile:THandle; DistanceToMove:LongInt; DistanceToMoveHigh:PULONG;
     dwMoveMethod:DWORD):DWORD ;
function PegSetEndOfFile    (hFile:THandle):BOOL ;
function PegCreateDirectory (lpPathName:LPCWSTR; lpSecurityAttributes:PSecurityAttributes):BOOL ;
function PegRemoveDirectory (PathName:LPCWSTR):BOOL ;
function PegCreateProcess   (lpApplicationName:LPCWSTR;lpCommandLine:LPCWSTR; lpProcessAttributes:PSecurityAttributes;
   lpThreadAttributes:PSecurityAttributes;bInheritHandles :BOOL;dwCreateFlags :DWORD; lpEnvironment:Pointer; lpCurrentDirectory :LPWSTR;
   lpStartupInfo:PSTARTUPINFO; lpProcessInformation:PProcessInformation):BOOL ;
function PegMoveFile(lpExistingFileName:LPCWSTR; lpNewFileName:LPCWSTR):BOOL ;
function PegCopyFile (lpExistingFileName:LPCWSTR; lpNewFileName:LPCWSTR; bFailIfExists:BOOL):BOOL ;
function PegDeleteFile      (lpFileName:LPCWSTR):BOOL ;
function PegGetFileSize     (hFile:THandle; lpFileSizeHigh:PDWORD):DWORD ;
function PegRegOpenKeyEx    (hKey:HKEY; SubKey:LPCWSTR; Reserved:DWORD; samDesired:REGSAM;
     pResult:PHKEY):LongInt ;
function PegRegEnumKeyEx    (hKey:HKEY; dwIndex:DWORD; KeyName:LPWSTR; chName:PDWORD;
  reserved:PDWORD; szClass:LPWSTR; cchClass:PDWORD; ftLastWrite:PFILETIME):LongInt ;
function PegRegCreateKeyEx  (hKey:HKEY; lpSzSubKey:LPCWSTR; dwReserved:DWORD;
     lpszClass:LPWSTR; dwOption:DWORD; samDesired:REGSAM; lpSecurityAttributes:PSecurityAttributes;
      phkResult:PHKEY; lpdwDisposition:PDWORD):LongInt ;
function PegRegCloseKey     (hKey:HKEY):LongInt ;
function PegRegDeleteKey    (hKey:HKEY; lpszSubKey:LPCWSTR):LongInt ;
function PegRegEnumValue    (hKey:HKEY; dwIndex:DWORD; lpszName:LPWSTR; lpcchName:PDWORD;
     lpReserved:PDWORD; lpszClass:PDWORD; lpcchClass:PBYTE; lpftLastWrite:PDWORD):LongInt ;
function PegRegDeleteValue  (hKey:HKEY; lpszValueName:LPCWSTR):LongInt ;
function PegRegQueryInfoKey (hKey:HKEY; ClassName:LPWSTR; cchClass:PDWORD; Reserved:PDWORD;
     cSubKeys:PDWORD; cchMaxSubKeyLen:PDWORD; cchMaxClassLen:PDWORD; cValues:PDWORD;
     cchMaxValueNameLen:PDWORD; cbMaxValueData:PDWORD; cbSecurityDescriptor:PDWORD;
     LastWriteTime:PFILETIME):LongInt ;
function PegRegQueryValueEx (hKey:HKEY; ValueName:LPCWSTR; Reserved:PDWORD; pType:PDWORD;
     pData:PBYTE; cbData:PDWORD):LongInt ;
function PegRegSetValueEx   (hKey:HKEY; ValueName:LPCWSTR; reserved:DWORD;
     dwType:DWORD; pData:PBYTE; cbData:DWORD):LongInt ;
function PegGetStoreInformation(lpsi:PSTORE_INFORMATION):BOOL ;
function PegGetSystemMetrics(nIndex:Integer):Integer ;
function PegGetDesktopDeviceCaps(nIndedx:Integer):LongInt ;
procedure PegGetSystemInfo (lpSystemInfo:PSystemInfo);
function PegSHCreateShortcut(ShortCut:LPWSTR; Target:LPWSTR):DWORD ;
function PegSHGetShortcutTarget(ShortCut:LPWSTR; Target:LPWSTR; cbMax:integer):BOOL ;
function PegCheckPassword   (lpszPassword:LPWSTR):BOOL ;
function PegGetFileTime     (hFile:THandle; lpCreationTime:PFILETIME;
  lpLastAccessTime:PFILETIME; lpLastWriteTime:PFILETIME):BOOL ;
function PegSetFileTime     (hFile:THandle; CreationTime:PFILETIME;
     LastAccessTime:PFILETIME; lastWriteTime:PFILETIME):BOOL ;
function PegGetVersionEx    (lpVersionInfo:PPEGOSVERSIONINFO):BOOL ;
function PegGetWindow       (hWnd:HWND; uCmd:UINT):HWND ;
function PegGetWindowLong   (hWnd:HWND; nIndex:integer):LongInt ;
function PegGetWindowText   (hWnd:HWND; lpString:LPWSTR; nMaxCount:integer):Integer ;
function PegGetClassName    (hWnd:HWND; lpClassName:LPWSTR; nMaxCount:integer):Integer ;
procedure PegGlobalMemoryStatus(lpmst:PMemoryStatus);
function PegGetSystemPowerStatusEx(pStatus:PSYSTEM_POWER_STATUS_EX; fUpdate:BOOL):BOOL ;

implementation

var
  mPegRapiInit : TPegRapiInit;
  mPegRapiUnInit : TPegRapiUnInit;
  mPegFindAllFiles:TPegFindAllFiles;
  mRapiFreeBuffer : TRapiFreeBuffer;

mPegRapiInitEx:TPegRapiInitEx;
mPegCreateDatabase:TPegCreateDatabase;
mPegDeleteDatabase:TPegDeleteDatabase ;
mPegDeleteRecord:TPegDeleteRecord ;
mPegFindFirstDatabase:TPegFindFirstDatabase;
mPegFindNextDatabase:TPegFindNextDatabase  ;
mPegOidGetInfo:TPegOidGetInfo        ;
mPegOpenDatabase:TPegOpenDatabase      ;
mPegReadRecordProps:TPegReadRecordProps ;
mPegSeekDatabase:TPegSeekDatabase ;
mPegSetDatabaseInfo:TPegSetDatabaseInfo ;
mPegWriteRecordProps:TPegWriteRecordProps ;
mPegFindFirstFile:TPegFindFirstFile  ;
mPegFindNextFile:TPegFindNextFile    ;
mPegFindClose:TPegFindClose  ;
mPegGetFileAttributes:TPegGetFileAttributes ;
mPegSetFileAttributes:TPegSetFileAttributes ;
mPegCreateFile:TPegCreateFile     ;
mPegReadFile:TPegReadFile ;
mPegWriteFile:TPegWriteFile;
mPegCloseHandle:TPegCloseHandle ;
mPegFindAllDatabases:TPegFindAllDatabases ;
mPegGetLastError:TPegGetLastError      ;
mGetRapiError:TGetRapiError       ;
mPegSetFilePointer:TPegSetFilePointer  ;
mPegSetEndOfFile:TPegSetEndOfFile ;
mPegCreateDirectory:TPegCreateDirectory ;
mPegRemoveDirectory:TPegRemoveDirectory  ;
mPegCreateProcess:TPegCreateProcess   ;
mPegMoveFile:TPegMoveFile ;
mPegCopyFile:TPegCopyFile  ;
mPegDeleteFile:TPegDeleteFile;
mPegGetFileSize:TPegGetFileSize;
mPegRegOpenKeyEx:TPegRegOpenKeyEx;
mPegRegEnumKeyEx:TPegRegEnumKeyEx;
mPegRegCreateKeyEx:TPegRegCreateKeyEx ;
mPegRegCloseKey:TPegRegCloseKey ;
mPegRegDeleteKey:TPegRegDeleteKey ;
mPegRegEnumValue:TPegRegEnumValue;
mPegRegDeleteValue:TPegRegDeleteValue;
mPegRegQueryInfoKey:TPegRegQueryInfoKey;
mPegRegQueryValueEx:TPegRegQueryValueEx;
mPegRegSetValueEx:TPegRegSetValueEx;
mPegGetStoreInformation:TPegGetStoreInformation;
mPegGetSystemMetrics:TPegGetSystemMetrics ;
mPegGetDesktopDeviceCaps:TPegGetDesktopDeviceCaps;
mPegGetSystemInfo:TPegGetSystemInfo  ;
mPegSHCreateShortcut:TPegSHCreateShortcut;
mPegSHGetShortcutTarget:TPegSHGetShortcutTarget;
mPegCheckPassword:TPegCheckPassword  ;
mPegGetFileTime:TPegGetFileTime ;
mPegSetFileTime:TPegSetFileTime;
mPegGetVersionEx:TPegGetVersionEx;
mPegGetWindow:TPegGetWindow    ;
mPegGetWindowLong:TPegGetWindowLong ;
mPegGetWindowText:TPegGetWindowText  ;
mPegGetClassName:TPegGetClassName    ;
mPegGlobalMemoryStatus:TPegGlobalMemoryStatus;
mPegGetSystemPowerStatusEx:TPegGetSystemPowerStatusEx;

  RapiModule    : THandle;

  function RapiLoaded : BOOL;
    {-Assure that TAPI is loaded and globals are set}
  begin
    if RapiModule <> 0 then begin
      Result := True;
      Exit;
    end;

    {Load RAPI}
    RapiModule := LoadLibrary('RAPI.DLL');

    if RapiModule > HINSTANCE_ERROR then
    begin
      {Say it's loaded...}
      Result := True;

      {...and load all globals}
      @mPegRapiInit := GetProcAddress(RapiModule, 'PegRapiInit');
      @mPegRapiUnInit := GetProcAddress(RapiModule, 'PegRapiUnInit');
      @mPegFindAllFiles := GetProcAddress(RapiModule, 'PegFindAllFiles');
      @mRapiFreeBuffer :=  GetProcAddress(RapiModule, 'RapiFreeBuffer');


      @mPegCreateDatabase:=  GetProcAddress(RapiModule, 'PegCreateDatabase');
      @mPegDeleteDatabase:=  GetProcAddress(RapiModule, 'PegDeleteDatabase');
      @mPegDeleteRecord:=  GetProcAddress(RapiModule, 'PegDeleteRecord');
      @mPegFindFirstDatabase:=  GetProcAddress(RapiModule, 'PegFindFirstDatabase');
      @mPegFindNextDatabase:=  GetProcAddress(RapiModule, 'PegFindNextDatabase');
      @mPegOidGetInfo:=  GetProcAddress(RapiModule, 'PegOidGetInfo');
      @mPegOpenDatabase:=  GetProcAddress(RapiModule, 'PegOpenDatabase');
      @mPegReadRecordProps:=  GetProcAddress(RapiModule, 'PegReadRecordProps');
      @mPegSeekDatabase:=  GetProcAddress(RapiModule, 'PegSeekDatabase');
      @mPegSetDatabaseInfo:=  GetProcAddress(RapiModule, 'PegSetDatabaseInfo');
      @mPegWriteRecordProps:=  GetProcAddress(RapiModule, 'PegWriteRecordProps');
      @mPegFindFirstFile:=  GetProcAddress(RapiModule, 'PegFindFirstFile');
      @mPegFindNextFile:=  GetProcAddress(RapiModule, 'PegFindNextFile');
      @mPegFindClose:=  GetProcAddress(RapiModule, 'PegFindClose');
      @mPegGetFileAttributes:=  GetProcAddress(RapiModule, 'PegGetFileAttributes');
      @mPegSetFileAttributes:=  GetProcAddress(RapiModule, 'PegSetFileAttributes');
      @mPegCreateFile:=  GetProcAddress(RapiModule, 'PegCreateFile');
      @mPegReadFile:=  GetProcAddress(RapiModule, 'PegReadFile');
      @mPegWriteFile:=  GetProcAddress(RapiModule, 'PegWriteFile');
      @mPegCloseHandle:=  GetProcAddress(RapiModule, 'PegCloseHandle');
      @mPegFindAllDatabases:=  GetProcAddress(RapiModule, 'PegFindAllDatabases');
      @mPegGetLastError:=  GetProcAddress(RapiModule, 'PegGetLastError');
      @mGetRapiError:=  GetProcAddress(RapiModule, 'GetRapiError');
      @mPegSetFilePointer:=  GetProcAddress(RapiModule, 'PegSetFilePointer');
      @mPegSetEndOfFile:=  GetProcAddress(RapiModule, 'PegSetEndOfFile');
      @mPegCreateDirectory:=  GetProcAddress(RapiModule, 'PegCreateDirectory');
      @mPegRemoveDirectory:=  GetProcAddress(RapiModule, 'PegRemoveDirectory');
      @mPegCreateProcess:=  GetProcAddress(RapiModule, 'PegCreateProcess');
      @mPegMoveFile:=  GetProcAddress(RapiModule, 'PegMoveFile');
      @mPegCopyFile:=  GetProcAddress(RapiModule, 'PegCopyFile');
      @mPegDeleteFile:=  GetProcAddress(RapiModule, 'PegDeleteFile');
      @mPegGetFileSize:=  GetProcAddress(RapiModule, 'PegGetFileSize');
      @mPegRegOpenKeyEx:=  GetProcAddress(RapiModule, 'PegRegOpenKeyEx');
      @mPegRegEnumKeyEx:=  GetProcAddress(RapiModule, 'PegRegEnumKeyEx');
      @mPegRegCreateKeyEx:=  GetProcAddress(RapiModule, 'PegRegCreateKeyEx');
      @mPegRegCloseKey:=  GetProcAddress(RapiModule, 'PegRegCloseKey');
      @mPegRegDeleteKey:=  GetProcAddress(RapiModule, 'PegRegDeleteKey');
      @mPegRegEnumValue:=  GetProcAddress(RapiModule, 'PegRegEnumValue');
      @mPegRegDeleteValue:=  GetProcAddress(RapiModule, 'PegRegDeleteValue');
      @mPegRegQueryInfoKey:=  GetProcAddress(RapiModule, 'PegRegQueryInfoKey');
      @mPegRegQueryValueEx:=  GetProcAddress(RapiModule, 'PegRegQueryValueEx');
      @mPegRegSetValueEx:=  GetProcAddress(RapiModule, 'PegRegSetValueEx');
      @mPegGetStoreInformation:=  GetProcAddress(RapiModule, 'PegGetStoreInformation');
      @mPegGetSystemMetrics:=  GetProcAddress(RapiModule, 'PegGetSystemMetrics');
      @mPegGetDesktopDeviceCaps:=  GetProcAddress(RapiModule, 'PegGetDesktopDeviceCaps');
      @mPegGetSystemInfo:=  GetProcAddress(RapiModule, 'PegGetSystemInfo');
      @mPegSHCreateShortcut:=  GetProcAddress(RapiModule, 'PegSHCreateShortcut');
      @mPegSHGetShortcutTarget:=  GetProcAddress(RapiModule, 'PegSHGetShortcutTarget');
      @mPegCheckPassword:=  GetProcAddress(RapiModule, 'PegCheckPassword');
      @mPegGetFileTime:=  GetProcAddress(RapiModule, 'PegGetFileTime');
      @mPegSetFileTime:=  GetProcAddress(RapiModule, 'PegSetFileTime');
      @mPegGetVersionEx:=  GetProcAddress(RapiModule, 'PegGetVersionEx');
      @mPegGetWindow:=  GetProcAddress(RapiModule, 'PegGetWindow');
      @mPegGetWindowLong:=  GetProcAddress(RapiModule, 'PegGetWindowLong');
      @mPegGetWindowText:=  GetProcAddress(RapiModule, 'PegGetWindowText');
      @mPegGetClassName:=  GetProcAddress(RapiModule, 'PegGetClassName');
      @mPegGlobalMemoryStatus:=  GetProcAddress(RapiModule, 'PegGlobalMemoryStatus');
      @mPegGetSystemPowerStatusEx:=  GetProcAddress(RapiModule, 'PegGetSystemPowerStatusEx');

    end
    else
      Result := False;
  end;

function PegFindAllFiles(Path:PWideChar; Attr:DWORD; var Count:DWord;
     var FindData:PPeg_Find_Data_array):BOOL;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegFindAllFiles <> nil then
     Result := mPegFindAllFiles(Path,Attr,Count,FindData)
  else
     Result := False;
end;

procedure RapiFreeBuffer (p:Pointer);
begin
  if not RapiLoaded then begin
     Exit;
  end;

  if @mRapiFreeBuffer <> nil then
     mRapiFreeBuffer(p);
end;
function PegRapiInit : LongInt;
    {-Initialize a line device}
begin
    if not RapiLoaded then begin
      Result := -1;
      Exit;
    end;

    if @mPegRapiInit <> nil then
      Result := mPegRapiInit
    else
      Result := -1;
end;
function PegRapiUnInit : LongInt;
    {-Initialize a line device}
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRapiUnInit <> nil then
     Result := mPegRapiUnInit
  else
     Result := -1;
end;

function PegRapiInitEx(var RInit:TRapiInit) : LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRapiInitEx <> nil then
     Result := mPegRapiInitEx(RInit)
  else
     Result := -1;
end;
function PegCreateDatabase (lpszName:LPWSTR; dwDbaseType:DWORD; wNumSortOrder:WORD;
   var rgSortSpecs:TSortOrderSpec):PEGOID ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegCreateDatabase <> nil then
     Result := mPegCreateDatabase (lpszName, dwDbaseType, wNumSortOrder,rgSortSpecs)
  else
     Result := -1;
end;
function PegDeleteDatabase (oidDBase:PegOId):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegDeleteDatabase <> nil then
     Result := mPegDeleteDatabase (oidDBase)
  else
     Result := False;
end;
function PegDeleteRecord (hDatabase:THandle; oidRecord:PEGOID):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegDeleteRecord <> nil then
     Result := mPegDeleteRecord (hDatabase, oidRecord)
  else
     Result := False;
end;
function PegFindFirstDatabase (dwDbaseType:DWORD):THandle ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegFindFirstDatabase <> nil then
     Result := mPegFindFirstDatabase (dwDbaseType)
  else
     Result := -1;
end;
function PegFindNextDatabase(hEnum:THandle):PEGOID ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegFindNextDatabase <> nil then
     Result := mPegFindNextDatabase(hEnum)
  else
     Result := -1;
end;
function PegOidGetInfo (oid:PEGOID; var poidInfo:TPegOIDINFO):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegOidGetInfo <> nil then
     Result := mPegOidGetInfo (oid,poidInfo)
  else
     Result := False;
end;
function PegOpenDatabase    (var poid:PEGOID; lpszName:LPWSTR; propid:PEGPROPID;
        dwFlags:DWORD; hwndNotify:HWND):THandle ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegOpenDatabase <> nil then
     Result := mPegOpenDatabase    (poid,lpszName, propid,
        dwFlags, hwndNotify)
  else
     Result := -1;
end;
function PegReadRecordProps (hDbase:THandle; dwFlags:DWORD;var cPropID :WORD;
     var rgPropID :PPeg_PropID_array; Buffer:Pointer; var cbBuffer:DWORD):PEGOID ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegReadRecordProps <> nil then
     Result := mPegReadRecordProps (hDbase,dwFlags, cPropID, rgPropID,Buffer,cbBuffer)
  else
     Result := -1;
end;
function PegSeekDatabase    (hDatabase:THandle; dwSeekType:DWORD; dwValue:LongInt;
  dwIndex:PDWORD):PEGOID ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegSeekDatabase <> nil then
     Result := mPegSeekDatabase(hDatabase, dwSeekType, dwValue, dwIndex)
  else
     Result := -1;
end;
function PegSetDatabaseInfo (oidDbase:PEGOID; var NewInfo:TPegDBaseInfo):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegSetDatabaseInfo <> nil then
     Result := mPegSetDatabaseInfo (oidDbase,NewInfo)
  else
     Result := False;
end;
function PegWriteRecordProps(hDbase:THandle; oidRecord:PEGOID; cPropID:WORD; PropVal:TPegPROPVAL):PEGOID ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegWriteRecordProps <> nil then
     Result := mPegWriteRecordProps(hDbase,oidRecord,cPropID, PropVal)
  else
     Result := -1;
end;
function PegFindFirstFile(lpFileName:LPCWSTR; lpFindFileData:PPEG_FIND_DATA):THandle ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegFindFirstFile <> nil then
     Result := mPegFindFirstFile(lpFileName, lpFindFileData)
  else
     Result := -1;
end;
function PegFindNextFile(hFindFile:THandle; lpFindFileData:PPEG_FIND_DATA):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegFindNextFile <> nil then
     Result := mPegFindNextFile(hFindFile,lpFindFileData)
  else
     Result := False;
end;
function PegFindClose       (hFindFile:THandle):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegFindClose <> nil then
     Result := mPegFindClose(hFindFile)
  else
     Result := False;
end;
function PegGetFileAttributes (lpFileName:LPCWSTR):DWORD ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetFileAttributes <> nil then
     Result := mPegGetFileAttributes (lpFileName)
  else
     Result := -1;
end;
function PegSetFileAttributes (FileName:LPCWSTR; dwFileAttributes:DWORD):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegSetFileAttributes <> nil then
     Result := mPegSetFileAttributes (FileName, dwFileAttributes)
  else
     Result := False;
end;
function PegCreateFile      (lpFileName:LPCWSTR; dwDesiredAccess:DWORD; dwShareMode: DWORD;
     lpSecurityAttributes: PSecurityAttributes; dwCreationDistribution:DWORD;
     dwFlagsAndAttributes:DWORD;hTemplateFile:THandle):THandle ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegCreateFile <> nil then
     Result := mPegCreateFile      (lpFileName,dwDesiredAccess, dwShareMode,
     lpSecurityAttributes, dwCreationDistribution,
     dwFlagsAndAttributes,hTemplateFile)
  else
     Result := -1;
end;
function PegReadFile (hFile:THandle; lpBuffer:Pointer; nNumberOfBytesToRead:DWORD;
     var NumberOfBytesRead :DWORD; Overlapped:POVERLAPPED):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegReadFile <> nil then
     Result := mPegReadFile        (hFile, lpBuffer, nNumberOfBytesToRead,
           NumberOfBytesRead, Overlapped)
  else
     Result := False;
end;
function PegWriteFile       (hFile:THandle; Buffer:Pointer; NumberOfBytesToWrite:DWORD;
     var NumberOfBytesWritten:DWORD; OverLapped:POVERLAPPED):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegWriteFile <> nil then
     Result := mPegWriteFile       (hFile, Buffer, NumberOfBytesToWrite,
     NumberOfBytesWritten, OverLapped)
  else
     Result := False;
end;
function PegCloseHandle     (hObject:THandle):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegCloseHandle <> nil then
     Result := mPegCloseHandle     (hObject)
  else
     Result := False;
end;
function PegFindAllDatabases(dwDbaseType:DWORD; wFlags:WORD; var cFindData:DWORD; var ppFindData:PPegDB_File_Data_Array):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegFindAllDatabases <> nil then
     Result := mPegFindAllDatabases(dwDbaseType,wFlags,cFindData,ppFindData)
  else
     Result := False;
end;
function PegGetLastError       :DWORD ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetLastError <> nil then
     Result := mPegGetLastError
  else
     Result := -1;
end;
function GetRapiError : LongInt  ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mGetRapiError <> nil then
     Result := mGetRapiError
  else
     Result := -1;
end;
function PegSetFilePointer  (hFile:THandle; DistanceToMove:LongInt; DistanceToMoveHigh:PULONG;
     dwMoveMethod:DWORD):DWORD ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegSetFilePointer <> nil then
     Result := mPegSetFilePointer  (hFile, DistanceToMove, DistanceToMoveHigh,
     dwMoveMethod)
  else
     Result := -1;
end;
function PegSetEndOfFile    (hFile:THandle):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegSetEndOfFile <> nil then
     Result := mPegSetEndOfFile    (hFile)
  else
     Result := False;
end;
function PegCreateDirectory (lpPathName:LPCWSTR; lpSecurityAttributes:PSecurityAttributes):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegCreateDirectory <> nil then
     Result := mPegCreateDirectory (lpPathName,lpSecurityAttributes)
  else
     Result := False;
end;
function PegRemoveDirectory (PathName:LPCWSTR):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegRemoveDirectory <> nil then
     Result := mPegRemoveDirectory (PathName)
  else
     Result := False;
end;
function PegCreateProcess   (lpApplicationName:LPCWSTR;lpCommandLine:LPCWSTR; lpProcessAttributes:PSecurityAttributes;
   lpThreadAttributes:PSecurityAttributes;bInheritHandles :BOOL;dwCreateFlags :DWORD; lpEnvironment:Pointer; lpCurrentDirectory :LPWSTR;
   lpStartupInfo:PSTARTUPINFO; lpProcessInformation:PProcessInformation):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegCreateProcess <> nil then
     Result := mPegCreateProcess   (lpApplicationName,lpCommandLine, lpProcessAttributes,
   lpThreadAttributes,bInheritHandles,dwCreateFlags, lpEnvironment,lpCurrentDirectory,
   lpStartupInfo, lpProcessInformation)
  else
     Result :=False;
end;
function PegMoveFile(lpExistingFileName:LPCWSTR; lpNewFileName:LPCWSTR):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegMoveFile <> nil then
     Result := mPegMoveFile(lpExistingFileName,lpNewFileName)
  else
     Result := False;
end;
function PegCopyFile (lpExistingFileName:LPCWSTR; lpNewFileName:LPCWSTR; bFailIfExists:BOOL):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegCopyFile <> nil then
     Result := mPegCopyFile (lpExistingFileName,lpNewFileName,bFailIfExists)
  else
     Result := False;
end;
function PegDeleteFile      (lpFileName:LPCWSTR):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegDeleteFile <> nil then
     Result := mPegDeleteFile(lpFileName)
  else
     Result := False;
end;
function PegGetFileSize     (hFile:THandle; lpFileSizeHigh:PDWORD):DWORD ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetFileSize <> nil then
     Result := mPegGetFileSize     (hFile, lpFileSizeHigh)
  else
     Result := -1;
end;
function PegRegOpenKeyEx    (hKey:HKEY; SubKey:LPCWSTR; Reserved:DWORD; samDesired:REGSAM;
     pResult:PHKEY):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegOpenKeyEx <> nil then
     Result := mPegRegOpenKeyEx    (hKey,SubKey,Reserved,samDesired, pResult)
  else
     Result := -1;
end;
function PegRegEnumKeyEx    (hKey:HKEY; dwIndex:DWORD; KeyName:LPWSTR; chName:PDWORD;
  reserved:PDWORD; szClass:LPWSTR; cchClass:PDWORD; ftLastWrite:PFILETIME):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegEnumKeyEx <> nil then
     Result := mPegRegEnumKeyEx    (hKey,dwIndex,KeyName,chName,
  reserved, szClass,cchClass,ftLastWrite)
  else
     Result := -1;
end;
function PegRegCreateKeyEx  (hKey:HKEY; lpSzSubKey:LPCWSTR; dwReserved:DWORD;
     lpszClass:LPWSTR; dwOption:DWORD; samDesired:REGSAM; lpSecurityAttributes:PSecurityAttributes;
      phkResult:PHKEY; lpdwDisposition:PDWORD):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegCreateKeyEx <> nil then
     Result := mPegRegCreateKeyEx  (hKey, lpSzSubKey, dwReserved,
     lpszClass, dwOption, samDesired,lpSecurityAttributes,
      phkResult,lpdwDisposition)
  else
     Result := -1;
end;
function PegRegCloseKey     (hKey:HKEY):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegCloseKey <> nil then
     Result := mPegRegCloseKey (hKey)
  else
     Result := -1;
end;
function PegRegDeleteKey    (hKey:HKEY; lpszSubKey:LPCWSTR):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegDeleteKey <> nil then
     Result := mPegRegDeleteKey    (hKey,lpszSubKey)
  else
     Result := -1;
end;
function PegRegEnumValue    (hKey:HKEY; dwIndex:DWORD; lpszName:LPWSTR; lpcchName:PDWORD;
     lpReserved:PDWORD; lpszClass:PDWORD; lpcchClass:PBYTE; lpftLastWrite:PDWORD):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegEnumValue <> nil then
     Result := mPegRegEnumValue    (hKey, dwIndex,lpszName, lpcchName,
     lpReserved,lpszClass, lpcchClass, lpftLastWrite)
  else
     Result := -1;
end;
function PegRegDeleteValue  (hKey:HKEY; lpszValueName:LPCWSTR):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegDeleteValue <> nil then
     Result := mPegRegDeleteValue  (hKey,lpszValueName)
  else
     Result := -1;
end;
function PegRegQueryInfoKey (hKey:HKEY; ClassName:LPWSTR; cchClass:PDWORD; Reserved:PDWORD;
     cSubKeys:PDWORD; cchMaxSubKeyLen:PDWORD; cchMaxClassLen:PDWORD; cValues:PDWORD;
     cchMaxValueNameLen:PDWORD; cbMaxValueData:PDWORD; cbSecurityDescriptor:PDWORD;
     LastWriteTime:PFILETIME):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegQueryInfoKey <> nil then
     Result := mPegRegQueryInfoKey (hKey,ClassName,cchClass,Reserved,
     cSubKeys,cchMaxSubKeyLen,cchMaxClassLen, cValues,
     cchMaxValueNameLen,cbMaxValueData,cbSecurityDescriptor,
     LastWriteTime)
  else
     Result := -1;
end;
function PegRegQueryValueEx (hKey:HKEY; ValueName:LPCWSTR; Reserved:PDWORD; pType:PDWORD;
     pData:PBYTE; cbData:PDWORD):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegQueryValueEx <> nil then
     Result := mPegRegQueryValueEx (hKey, ValueName, Reserved,pType,
     pData,cbData)
  else
     Result := -1;
end;
function PegRegSetValueEx   (hKey:HKEY; ValueName:LPCWSTR; reserved:DWORD;
     dwType:DWORD; pData:PBYTE; cbData:DWORD):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegRegSetValueEx <> nil then
     Result := mPegRegSetValueEx   (hKey,ValueName,reserved,
     dwType,pData,cbData)
  else
     Result := -1;
end;
function PegGetStoreInformation(lpsi:PSTORE_INFORMATION):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegGetStoreInformation <> nil then
     Result := mPegGetStoreInformation(lpsi)
  else
     Result := False;
end;
function PegGetSystemMetrics(nIndex:Integer):Integer ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetSystemMetrics <> nil then
     Result := mPegGetSystemMetrics(nIndex)
  else
     Result := -1;
end;
function PegGetDesktopDeviceCaps(nIndedx:Integer):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetDesktopDeviceCaps <> nil then
     Result := mPegGetDesktopDeviceCaps(nIndedx)
  else
     Result := -1;
end;
procedure PegGetSystemInfo (lpSystemInfo:PSystemInfo);
begin
  if not RapiLoaded then begin
     Exit;
  end;

  if @mPegGetSystemInfo <> nil then
     mPegGetSystemInfo (lpSystemInfo);
end;
function PegSHCreateShortcut(ShortCut:LPWSTR; Target:LPWSTR):DWORD ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegSHCreateShortcut <> nil then
     Result := mPegSHCreateShortcut(ShortCut,Target)
  else
     Result := -1;
end;
function PegSHGetShortcutTarget(ShortCut:LPWSTR; Target:LPWSTR; cbMax:integer):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegSHGetShortcutTarget <> nil then
     Result := mPegSHGetShortcutTarget(ShortCut, Target, cbMax)
  else
     Result :=False;
end;
function PegCheckPassword   (lpszPassword:LPWSTR):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegCheckPassword <> nil then
     Result := mPegCheckPassword (lpszPassword)
  else
     Result := False;
end;
function PegGetFileTime     (hFile:THandle; lpCreationTime:PFILETIME;
  lpLastAccessTime:PFILETIME; lpLastWriteTime:PFILETIME):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegGetFileTime <> nil then
     Result := mPegGetFileTime( hFile,lpCreationTime,
        lpLastAccessTime,lpLastWriteTime)
  else
     Result := False;
end;
function PegSetFileTime     (hFile:THandle; CreationTime:PFILETIME;
     LastAccessTime:PFILETIME; lastWriteTime:PFILETIME):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegSetFileTime <> nil then
     Result := mPegSetFileTime     (hFile,CreationTime,
        LastAccessTime, lastWriteTime)
  else
     Result := False;
end;
function PegGetVersionEx    (lpVersionInfo:PPEGOSVERSIONINFO):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegGetVersionEx <> nil then
     Result := mPegGetVersionEx    (lpVersionInfo)
  else
     Result := False;
end;
function PegGetWindow       (hWnd:HWND; uCmd:UINT):HWND ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetWindow <> nil then
     Result := mPegGetWindow(hWnd, uCmd)
  else
     Result := -1;
end;
function PegGetWindowLong   (hWnd:HWND; nIndex:integer):LongInt ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetWindowLong <> nil then
     Result := mPegGetWindowLong   (hWnd ,nIndex)
  else
     Result := -1;
end;
function PegGetWindowText   (hWnd:HWND; lpString:LPWSTR; nMaxCount:integer):Integer ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetWindowText <> nil then
     Result := mPegGetWindowText   (hWnd, lpString, nMaxCount)
  else
     Result := -1;
end;
function PegGetClassName    (hWnd:HWND; lpClassName:LPWSTR; nMaxCount:integer):Integer ;
begin
  if not RapiLoaded then begin
     Result := -1;
     Exit;
  end;

  if @mPegGetClassName <> nil then
     Result := mPegGetClassName(hWnd,lpClassName, nMaxCount)
  else
     Result := -1;
end;
procedure PegGlobalMemoryStatus(lpmst:PMemoryStatus);
begin
  if not RapiLoaded then begin
     Exit;
  end;

  if @mPegGlobalMemoryStatus <> nil then
     mPegGlobalMemoryStatus(lpmst);
end;
function PegGetSystemPowerStatusEx(pStatus:PSYSTEM_POWER_STATUS_EX; fUpdate:BOOL):BOOL ;
begin
  if not RapiLoaded then begin
     Result := False;
     Exit;
  end;

  if @mPegGetSystemPowerStatusEx <> nil then
     Result := mPegGetSystemPowerStatusEx(pStatus, fUpdate)
  else
     Result := False;
end;

end.




0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362156
Hey great! thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question