⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pfgsyncmgr.pas

📁 delphi编写与Palm数据交换管道连接程序。
💻 PAS
📖 第 1 页 / 共 4 页
字号:
  SyncDeleteAllResourceRec: function (fHandle: Byte): Integer; cdecl; 
  SyncReadRecordById: function (const rInfo: CRawRecordInfo): Integer; cdecl; 
  SyncReadRecordByIndex: function (const rInfo: CRawRecordInfo): Integer; cdecl; 
  SyncReadResRecordByIndex: function (const rInfo: CRawRecordInfo; bBody: BOOL = True):
    Integer; cdecl; 
  SyncReadNextModifiedRec: function (const rInfo: CRawRecordInfo): Integer; cdecl; 
  SyncReadDBAppInfoBlock: function (fHandle: Byte; const rInfo: CDbGenInfo): Integer; cdecl; 
  SyncWriteDBAppInfoBlock: function (fHandle: Byte; const rInfo: CDbGenInfo): Integer; cdecl; 
  SyncWriteResourceRec: function (const rInfo: CRawRecordInfo): Integer; cdecl; 
  SyncRebootSystem: function: Integer; cdecl; 
  SyncReadSystemInfo: function (const rInfo: CSystemInfo): Integer; cdecl; 
  SyncReadSingleCardInfo: function (const rInfo: CCardInfo): Integer; cdecl; 
  SyncReadSysDateTime: function (var rDate: Long): Integer; cdecl; 
  SyncWriteSysDateTime: function (lDate: Long): Integer; cdecl; 
  SyncReadDBSortInfoBlock: function (fHandle: Byte; const rInfo: CDbGenInfo): Integer; cdecl; 
  SyncWriteDBSortInfoBlock: function (fHandle: Byte; const rInfo: CDbGenInfo): Integer; cdecl; 
  SyncCallApplication: function (var rOutParams: CCallAppParams; var rInParams:
    CCallAppParams): Integer; cdecl; 
  SyncChangeCategory: function (fHandle: Byte; bFrom, bTo: Byte): Integer; cdecl; 
  SyncReadPositionXMap: function (const rInfo: CPositionInfo): Integer; cdecl; 
  SyncYieldCycles: function (wMaxMiliSecs: Word): Integer; cdecl; 

  // Sync API v2.0 CALLS ADDED HERE:
  SyncReadNextRecInCategory: function (const rInfo: CRawRecordInfo): Integer; cdecl; 
  SyncReadNextModifiedRecInCategory: function (const rInfo: CRawRecordInfo): Integer; cdecl; 
  SyncReadAppPreference: function (const rInfo: CRawPreferenceInfo): Integer; cdecl; 
  SyncWriteAppPreference: function (const rInfo: CRawPreferenceInfo): Integer; cdecl; 
  SyncResetRecordIndex: function (fHandle: Byte): Integer; cdecl; 
  SyncPurgeAllRecsInCategory: function (fHandle: Byte; category: Shortint): Integer; cdecl; 
  SyncGetAPIVersion: function (var pdwMajor: DWORD; var pdwMinor: DWORD): Integer; cdecl; 

  // Sync API v2.1 CALLS ADDED HERE:
  SyncCallRemoteModule: function (const pParams: CCallModuleParams): Integer; cdecl; 
  SyncReadFeature: function (dwFtrCreator: DWORD; wFtrNum: WORD; var pdwFtrValue:
    DWORD): Integer; cdecl;
  SyncGetHHOSVersion: function (var pwRomVMinor: Word): Word; cdecl; 
  SyncHostToHHWord: function (wValue: Word): Word; cdecl; 
  SyncHHToHostWord: function (wValue: Word): Word; cdecl;
  SyncHostToHHDWord: function (dwValue: DWORD): DWORD; cdecl; 
  SyncHHToHostDWord: function (dwValue: DWORD): DWORD; cdecl; 

  //		Sync API v2.2 PUBLIC API:

  // Get the max record size that may be allocated
  // on the remote device (if sufficient free space exists).
  // ($FFFFFFFF = any size up to available free space; 0 = unknown)
  SyncMaxRemoteRecSize: function (var rdwMaxRecSize: DWORD): Integer; cdecl;

  // Looks for a database given its name and memory card number;
  // returns comprehensive information about the database, if found
  SyncFindDbByName: function (var rParam: SyncFindDbByNameParams;
     const rInfo: SyncDatabaseInfoType): Integer; cdecl;

  // Looks for a database given its type and creator; can be iterated; wild cards are
  // supported; returns comprehensive information about the database, if found
  SyncFindDbByTypeCreator: function (var rParam: SyncFindDbByTypeCreatorParams;
     const rInfo: SyncDatabaseInfoType): Integer; cdecl;

  // Returns comprehensive information about an open database
  SyncReadOpenDbInfo: function (var rParam: SyncReadOpenDbInfoParams;
     const rInfo: SyncDatabaseInfoType): Integer; cdecl;

  // Closes a database and optionally updates its backup
  // and/or modification date; bOptFlags may be zero or one
  // or more SYNC_CLOSE_DB_OPT_... flags bitwise or'ed
  // together (***non-zero bOptFlags may only be passed to PalmOS v3.0
  // or later; passing non-zero flags to older version will cause the
  // close command to fail***)
  SyncCloseDBEx: function (dbHandle: Byte; bOptFlags: Byte): Integer; cdecl;

  // Sync API v2.3 calls added here }
  SyncLoopBackTest: function(dwSizeSend: LongInt; pDataSend: PBYTE;
                             var pdwSizeRecv: LongInt;
                             var pDataRecv: BYTE): Integer; cdecl;

  // Sync API v2.5 PUBLIC API:
  SyncCallDeviceApplication: function (var rParams: CCallDeviceAppParams):
    Integer; cdecl;

implementation

uses Dialogs, pfgUserData;

var
  DllHandle : THandle;
  DllLoaded : Boolean;


function SYNCROMVMAJOR(l: LongWord): Byte;
begin
  Result := (l shr 24) and $FF;
end;

function SYNCROMVMINOR(l: LongWord): Byte;
begin
  Result := (l shr 20) and $F;
end;


procedure LoadDLL;
var
  OldCurrentDir: string;
begin
  if DLLLoaded then Exit;

  // We need to change the directory to the Palm one, since the stupid dum
  // sync20.dll can't find the cmds21.dll file otherwise
  OldCurrentDir := GetCurrentDir;
  try
    SetCurrentDir(PalmPath);
    DLLHandle := LoadLibrary('sync20.dll');
  finally
    SetCurrentDir(OldCurrentDir);
  end;
  DLLLoaded := DLLHandle >= 32;
  if DLLLoaded then
  begin
    @SyncAddLogEntry := GetProcAddress(DLLHandle,'SyncAddLogEntry');
    Assert(@SyncAddLogEntry <> nil);
    @SyncRegisterConduit := GetProcAddress(DLLHandle,'SyncRegisterConduit');
    Assert(@SyncRegisterConduit <> nil);
    @SyncUnRegisterConduit := GetProcAddress(DLLHandle,'SyncUnRegisterConduit');
    Assert(@SyncUnRegisterConduit <> nil);
    @SyncReadUserID := GetProcAddress(DLLHandle,'SyncReadUserID');
    Assert(@SyncReadUserID <> nil);
    @SyncOpenDB := GetProcAddress(DLLHandle,'SyncOpenDB');
    Assert(@SyncOpenDB <> nil);
    @SyncDeleteDB := GetProcAddress(DLLHandle,'SyncDeleteDB');
    Assert(@SyncDeleteDB <> nil);
    @SyncCreateDB := GetProcAddress(DLLHandle,'SyncCreateDB');
    Assert(@SyncCreateDB <> nil);
    @SyncCloseDB := GetProcAddress(DLLHandle,'SyncCloseDB');
    Assert(@SyncCloseDB <> nil);
    @SyncGetDBRecordCount := GetProcAddress(DLLHandle,'SyncGetDBRecordCount');
    Assert(@SyncGetDBRecordCount <> nil);
    @SyncPurgeDeletedRecs := GetProcAddress(DLLHandle,'SyncPurgeDeletedRecs');
    Assert(@SyncPurgeDeletedRecs <> nil);
    @SyncPurgeAllRecs := GetProcAddress(DLLHandle,'SyncPurgeAllRecs');
    Assert(@SyncPurgeAllRecs <> nil);
    @SyncResetSyncFlags := GetProcAddress(DLLHandle,'SyncResetSyncFlags');
    Assert(@SyncResetSyncFlags <> nil);
    @SyncReadDBList := GetProcAddress(DLLHandle,'SyncReadDBList');
    Assert(@SyncReadDBList <> nil);
    @SyncWriteRec := GetProcAddress(DLLHandle,'SyncWriteRec');
    Assert(@SyncWriteRec <> nil);
    @SyncDeleteRec := GetProcAddress(DLLHandle,'SyncDeleteRec');
    Assert(@SyncDeleteRec <> nil);
    @SyncDeleteResourceRec := GetProcAddress(DLLHandle,'SyncDeleteResourceRec');
    Assert(@SyncDeleteResourceRec <> nil);
    @SyncDeleteAllResourceRec := GetProcAddress(DLLHandle,'SyncDeleteAllResourceRec');
    Assert(@SyncDeleteAllResourceRec <> nil);
    @SyncReadRecordById := GetProcAddress(DLLHandle,'SyncReadRecordById');
    Assert(@SyncReadRecordById <> nil);
    @SyncReadRecordByIndex := GetProcAddress(DLLHandle,'SyncReadRecordByIndex');
    Assert(@SyncReadRecordByIndex <> nil);
    @SyncReadResRecordByIndex := GetProcAddress(DLLHandle,'SyncReadResRecordByIndex');
    Assert(@SyncReadResRecordByIndex <> nil);
    @SyncReadNextModifiedRec := GetProcAddress(DLLHandle,'SyncReadNextModifiedRec');
    Assert(@SyncReadNextModifiedRec <> nil);
    @SyncReadDBAppInfoBlock := GetProcAddress(DLLHandle,'SyncReadDBAppInfoBlock');
    Assert(@SyncReadDBAppInfoBlock <> nil);
    @SyncWriteDBAppInfoBlock := GetProcAddress(DLLHandle,'SyncWriteDBAppInfoBlock');
    Assert(@SyncWriteDBAppInfoBlock <> nil);
    @SyncWriteResourceRec := GetProcAddress(DLLHandle,'SyncWriteResourceRec');
    Assert(@SyncWriteResourceRec <> nil);
    @SyncRebootSystem := GetProcAddress(DLLHandle,'SyncRebootSystem');
    Assert(@SyncRebootSystem <> nil);
    @SyncReadSystemInfo := GetProcAddress(DLLHandle,'SyncReadSystemInfo');
    Assert(@SyncReadSystemInfo <> nil);
    @SyncReadSingleCardInfo := GetProcAddress(DLLHandle,'SyncReadSingleCardInfo');
    Assert(@SyncReadSingleCardInfo <> nil);
    @SyncReadSysDateTime := GetProcAddress(DLLHandle,'SyncReadSysDateTime');
    Assert(@SyncReadSysDateTime <> nil);
    @SyncWriteSysDateTime := GetProcAddress(DLLHandle,'SyncWriteSysDateTime');
    Assert(@SyncWriteSysDateTime <> nil);
    @SyncReadDBSortInfoBlock := GetProcAddress(DLLHandle,'SyncReadDBSortInfoBlock');
    Assert(@SyncReadDBSortInfoBlock <> nil);
    @SyncWriteDBSortInfoBlock := GetProcAddress(DLLHandle,'SyncWriteDBSortInfoBlock');
    Assert(@SyncWriteDBSortInfoBlock <> nil);
    @SyncCallApplication := GetProcAddress(DLLHandle,'SyncCallApplication');
//    Assert(@SyncCallApplication <> nil);  -- obselete function, so don't enforce
    @SyncChangeCategory := GetProcAddress(DLLHandle,'SyncChangeCategory');
    Assert(@SyncChangeCategory <> nil);
    @SyncReadPositionXMap := GetProcAddress(DLLHandle,'SyncReadPositionXMap');
    Assert(@SyncReadPositionXMap <> nil);
    @SyncYieldCycles := GetProcAddress(DLLHandle,'SyncYieldCycles');
    Assert(@SyncYieldCycles <> nil);
    @SyncReadNextRecInCategory := GetProcAddress(DLLHandle,'SyncReadNextRecInCategory');
    Assert(@SyncReadNextRecInCategory <> nil);
    @SyncReadNextModifiedRecInCategory := GetProcAddress(DLLHandle,'SyncReadNextModifiedRecInCategory');
    Assert(@SyncReadNextModifiedRecInCategory <> nil);
    @SyncReadAppPreference := GetProcAddress(DLLHandle,'SyncReadAppPreference');
    Assert(@SyncReadAppPreference <> nil);
    @SyncWriteAppPreference := GetProcAddress(DLLHandle,'SyncWriteAppPreference');
    Assert(@SyncWriteAppPreference <> nil);
    @SyncResetRecordIndex := GetProcAddress(DLLHandle,'SyncResetRecordIndex');
    Assert(@SyncResetRecordIndex <> nil);
    @SyncPurgeAllRecsInCategory := GetProcAddress(DLLHandle,'SyncPurgeAllRecsInCategory');
    Assert(@SyncPurgeAllRecsInCategory <> nil);
    @SyncGetAPIVersion := GetProcAddress(DLLHandle,'SyncGetAPIVersion');
    Assert(@SyncGetAPIVersion <> nil);
    @SyncCallRemoteModule := GetProcAddress(DLLHandle,'SyncCallRemoteModule');
    Assert(@SyncCallRemoteModule <> nil);
    @SyncReadFeature := GetProcAddress(DLLHandle,'SyncReadFeature');
    Assert(@SyncReadFeature <> nil);
    @SyncGetHHOSVersion := GetProcAddress(DLLHandle,'SyncGetHHOSVersion');
    Assert(@SyncGetHHOSVersion <> nil);
    @SyncHostToHHWord := GetProcAddress(DLLHandle,'SyncHostToHHWord');
    Assert(@SyncHostToHHWord <> nil);
    @SyncHHToHostWord := GetProcAddress(DLLHandle,'SyncHHToHostWord');
    Assert(@SyncHHToHostWord <> nil);
    @SyncHostToHHDWord := GetProcAddress(DLLHandle,'SyncHostToHHDWord');
    Assert(@SyncHostToHHDWord <> nil);
    @SyncHHToHostDWord := GetProcAddress(DLLHandle,'SyncHHToHostDWord');
    Assert(@SyncHHToHostDWord <> nil);
    @SyncMaxRemoteRecSize := GetProcAddress(DLLHandle,'SyncMaxRemoteRecSize');
    Assert(@SyncMaxRemoteRecSize <> nil);
    @SyncFindDbByName := GetProcAddress(DLLHandle,'SyncFindDbByName');
    Assert(@SyncFindDbByName <> nil);
    @SyncFindDbByTypeCreator := GetProcAddress(DLLHandle,'SyncFindDbByTypeCreator');
    Assert(@SyncFindDbByTypeCreator <> nil);
    @SyncReadOpenDbInfo := GetProcAddress(DLLHandle,'SyncReadOpenDbInfo');
    Assert(@SyncReadOpenDbInfo <> nil);
    @SyncCloseDBEx := GetProcAddress(DLLHandle,'SyncCloseDBEx');
    Assert(@SyncCloseDBEx <> nil);
    @SyncLoopBackTest := GetProcAddress(DLLHandle,'SyncLoopBackTest');
    //Assert(@SyncLoopBackTest <> nil);

    // Sync API 2.5 methods
    @SyncCallDeviceApplication := GetProcAddress(DLLHandle,'SyncCallDeviceApplication');
  end;
end;


initialization
  DLLLoaded := False;
  LoadDLL;

  if (not DllLoaded) then
  begin
    MessageDlg('pfgSyncMgr: Unable to load sync20.dll',mtError,[mbOk],0);
    Abort;
  end;

finalization
  if DLLLoaded then FreeLibrary(DLLHandle);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -