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

📄 pfguserdata.pas

📁 delphi编写与Palm数据交换管道连接程序。
💻 PAS
字号:
unit pfgUserData;
{**************************************************************************}
{                                                                          }
{    This C DLL header file first (automatic) conversion generated by:     }
{    HeadConv 4.0 (c) 2000 by Bob Swart (aka Dr.Bob - www.drbob42.com)     }
{      Final Delphi-Jedi (Darth) command-line units edition                }
{                                                                          }
{    Generated Date: 2001-05-13                                            }
{    Generated Time: 12:18:40                                              }
{                                                                          }
{**************************************************************************}

interface
uses
  pfgWTypes,

  Windows;



{=> c:\palmdev\cdk401\c++\include\USERDATA.H <=}

{+//**************************************************************************** }
{-* }
{-* Copyright (c) 1998-2000 Palm, Inc. or its subsidiaries. }
{-* All rights reserved. }
{-* }
{=*************************************************************************** }

{$IFNDEF _USER_DATA_HEADER_}
{$DEFINE _USER_DATA_HEADER_}

type
  UmUserSyncAction = (
    Synchronize {= 0},
    PCToHH,
    HHToPC,
    DoNothing,
    Custom  );

var

  UmGetLibVersion: function (var pdwMajor: LongInt;
                         var pdwMinor: LongInt): LongInt  stdcall ;


  UmGetUserCount: function : SmallInt  stdcall ;

  UmGetUserID: function (sIndex: SmallInt;
                     var pdwUserID: LongInt): LongInt  stdcall ;

  UmGetUserName: function (dwUserID: LongInt;
                       pUserNameBuffer: PChar;
                       var psUserNameBufSize: SmallInt): LongInt  stdcall ;

  UmGetUserDirectory: function (dwUserID: LongInt;
                            pUserDirBuffer: PChar;
                            var psUserDirBufSize: SmallInt): LongInt  stdcall ;

  UmGetUserPassword: function (dwUserID: LongInt;
                           pUserPasswordBuffer: PChar;
                           var psUserPasswordBufSize: SmallInt): LongInt  stdcall ;


  UmIsUserInstalled: function (dwUserID: LongInt): LongInt  stdcall ;

  UmIsUserProfile: function (dwUserID: LongInt): LongInt  stdcall ;


  UmSetUserName: function (dwUserID: LongInt;
                       const pUserName: PChar): LongInt  stdcall ;

  UmSetUserDirectory: function (dwUserID: LongInt;
                            const pUserDir: PTCHAR): LongInt  stdcall ;


  UmSetUserInstall: function (dwUserID: LongInt;
                          bUserInstall: Bool): LongInt  stdcall ;


  UmSetUserPermSyncPreferences: function (dwUserID: LongInt;
                                      dwCreatorID: LongInt;
                                      usaAction: LongInt): LongInt  stdcall ;

  UmSetUserTempSyncPreferences: function (dwUserID: LongInt;
                                      dwCreatorID: LongInt;
                                      usaAction: LongInt): LongInt  stdcall ;


  UmGetUserPermSyncPreferences: function (dwUserID: LongInt;
                                      dwCreatorID: LongInt;
                                      var pUsaAction: LongInt): LongInt  stdcall ;

  UmGetUserTempSyncPreferences: function (dwUserID: LongInt;
                                      dwCreatorID: LongInt;
                                      var pUsaAction: LongInt): LongInt  stdcall ;


  UmRemoveUserTempSyncPreferences: function (dwUserID: LongInt;
                                         dwCreatorID: LongInt): LongInt  stdcall ;

  UmDeleteUserPermSyncPreferences: function (dwUserID: LongInt;
                                         dwCreatorID: LongInt): LongInt  stdcall ;

  UmDeleteUserTempSyncPreferences: function (dwUserID: LongInt;
                                         dwCreatorID: LongInt): LongInt  stdcall ;

  UmAddUser: function (const pUser: PChar;
                   bProfileUser: Bool): LongInt  stdcall ;

  UmDeleteUser: function (dwUserID: LongInt): LongInt  stdcall ;


  UmGetRootDirectory: function (pRootDirBuffer: PChar;
                            var psRootDirBufSize: SmallInt): LongInt  stdcall ;

{/// install conduit user calls }

  UmIsInstallMaskSet: function (dwUserID: LongInt;
                            dwMask: LongInt): LongInt  stdcall ;

  UmClearInstallMask: function (dwUserID: LongInt;
                            dwMask: LongInt): LongInt  stdcall ;

  UmSetInstallMask: function (dwUserID: LongInt;
                          dwMask: LongInt): LongInt  stdcall ;


  UmGetString: function (dwUserID: LongInt;
                     const pszSection: PTCHAR;
                     const pszKey: PTCHAR;
                     var pBuf: TCHAR;
                     var lSize: LongInt;
                     const pszDefault: PTCHAR): LongInt  stdcall ;

  UmSetString: function (dwUserID: LongInt;
                     const pszSection: PTCHAR;
                     const pszKey: PTCHAR;
                     const pszValue: PTCHAR): LongInt  stdcall ;

  UmGetInteger: function (dwUserID: LongInt;
                      const pszSection: PTCHAR;
                      const pszKey: PTCHAR;
                      var pBuf: LongInt;
                      lDefault: LongInt): LongInt  stdcall ;

  UmSetInteger: function (dwUserID: LongInt;
                      const pszSection: PTCHAR;
                      const pszKey: PTCHAR;
                      lValue: LongInt): LongInt  stdcall ;

  UmDeleteKey: function (dwUserID: LongInt;
                     const pszSection: PTCHAR;
                     const pszKey: PTCHAR): LongInt  stdcall ;

  UmGetIDFromPath: function (const pszPath: PTCHAR;
                         var pdwUserID: LongInt): LongInt  stdcall ;

  UmGetIDFromName: function (const pszName: PTCHAR;
                         var pdwUserID: LongInt): LongInt  stdcall ;

{/// Expansion slot info calls }

  UmSlotGetExpMgrVersion: function (dwUserId: LongInt;
                                var pdwExpMgrVersion: LongInt): LongInt  stdcall ;


  UmSlotGetSlotCount: function (dwUserId: LongInt;
                            var pwNumSlots: Word): LongInt  stdcall ;

  UmSlotGetInfo: function (dwUserId: LongInt;
                       var pdwSlotIdList: LongInt;
                       var pwNumEntries: Word): LongInt  stdcall ;

  UmSlotGetMediaType: function (dwUserId: LongInt;
                            dwSlotId: LongInt;
                            var pdwSlotMediaType: LongInt): LongInt  stdcall ;

  UmSlotGetDisplayName: function (dwUserId: LongInt;
                              dwSlotId: LongInt;
                              var pszSlotDisplayName: TCHAR;
                              var plSize: LongInt): LongInt  stdcall ;

  UmSlotGetInstallDirectory: function (dwUserId: LongInt;
                                   dwSlotId: LongInt;
                                   var pszSlotInstallDir: TCHAR;
                                   var plSize: LongInt): LongInt  stdcall ;

{/// Error codes }
const
  ERR_UM_NO_USERSDAT_FILE = -500;
const
  ERR_UM_NO_USERS = -501;
const
  ERR_UM_USERSDAT_ALREADY_EXISTS = -502; {// not used}
const
  ERR_UM_INVALID_USER_INDEX = -503; {// commented out}
const
  ERR_UM_BUFSIZE_TOO_SMALL = -504;
const
  ERR_UM_INVALID_USER = -505;
const
  ERR_UM_INVALID_REGISTRY = -506; {// not used}
const
  ERR_UM_INVALID_INDEX = -507; {// not used}
const
  ERR_UM_INVALID_BUFFER = -508; {// not used}
const
  ERR_UM_INVALID_USER_NAME = -509;
const
  ERR_UM_INVALID_USER_DIR = -510;
const
  ERR_UM_NO_DIRECTORY = -511; {// not used}
const
  ERR_UM_NO_USER_FOUND = -512; {// not used}
const
  ERR_UM_NOT_FOUND = -513;
const
  ERR_UM_BAD_FILENAME = -514; {// not used}
const
  ERR_UM_USER_ACCESS = -515; {// not used}
const
  ERR_UM_SAVE_ERR = -516;
const
  ERR_UM_BASE = -517; {// don't understand}
const
  ERR_UM_OTHER_USERSDAT_ACCESS_PROBLEM = -518;
const
  ERR_UM_SEMAPHORE_ACCESS = -519;
const
  ERR_UM_UNABLE_TO_CREATE_NEW_FILE = -520; {// commented out}
const
  ERR_UM_NO_CORE_PATH = -521;
const
  ERR_UM_INVALID_POINTER = -522;
const
  ERR_UM_USER_ALREADY_EXISTS = -523;
const
  ERR_UM_USER_DIR_ALREADY_IN_USE = -524;



const
  ERR_UM_CANNOT_WRITE_TO_STORE = -525;
const
  ERR_UM_SYNC_PATH_TOO_BIG = -526;
const
  ERR_UM_STRING_TOO_BIG = -527;
const
  ERR_UM_FUNCTION_NOT_SUPPORTED = -528;
const
  ERR_UM_DEV_CFG_DATA_NOT_AVAILABLE = -529;

{$ENDIF // _USER_DATA_HEADER_}

function PalmPath: string;

implementation

uses
  Registry, SysUtils, Dialogs;

var
  Int_PalmPath: string = '';
  DllHandle : THandle;
  DllLoaded : Boolean;

function DLLPath: string;
var
 Buffer: array[0..MAX_PATH- 1] of char;
begin
 GetModuleFileName(hInstance, Buffer, MAX_PATH);
 Result := StrPas(Buffer);
end;

function PalmPath : string;
var
  TheHandle: HANDLE;
  Len: Smallint;
  Buffer: Array [0..MAX_PATH-1] of Char;
begin
  if Int_PalmPath = '' then
  begin
    if FileExists(DLLPath + 'userdata.dll') then
    begin
      // Get the Palm directory from the copy of the UserData.dll file
      TheHandle := LoadLibrary(PChar(DLLPath + 'userdata.dll'));
      if TheHandle >= 32 then
      begin
        @UmGetRootDirectory:= GetProcAddress(TheHandle,'UmGetRootDirectory');
        Len := MAX_PATH;
        UmGetRootDirectory(Buffer, Len);
        Int_PalmPath := StrPas(Buffer);
        FreeLibrary(TheHandle);
      end;
    end;

    if Int_PalmPath = '' then
    begin
      with TRegistry.Create do
        try
          if OpenKeyReadOnly('Software\U.S. Robotics\Pilot Desktop\Core') then
          Int_PalmPath := ExtractFilePath(ReadString('HotSyncPath'));
        finally
          Free;
        end;
    end;

    if (Int_PalmPath <> '') and (Int_PalmPath[Length(Int_PalmPath)] <> '\') then
      Int_PalmPath := Int_PalmPath + '\';
  end;

  Result := Int_PalmPath;
end;

procedure LoadDll;
begin
  if DllLoaded then Exit;

  DllHandle := LoadLibrary(PChar(PalmPath + 'userdata.dll'));
  DllLoaded := DllHandle >= 32;

  if DllLoaded then
  begin
    @UmGetLibVersion:= GetProcAddress(DLLHandle,'UmGetLibVersion');
    //Assert(@UmGetLibVersion <> nil);
    @UmGetUserCount:= GetProcAddress(DLLHandle,'UmGetUserCount');
    Assert(@UmGetUserCount <> nil);
    @UmGetUserID:= GetProcAddress(DLLHandle,'UmGetUserID');
    Assert(@UmGetUserID <> nil);
    @UmGetUserName:= GetProcAddress(DLLHandle,'UmGetUserName');
    Assert(@UmGetUserName <> nil);
    @UmGetUserDirectory:= GetProcAddress(DLLHandle,'UmGetUserDirectory');
    Assert(@UmGetUserDirectory <> nil);
    @UmGetUserPassword:= GetProcAddress(DLLHandle,'UmGetUserPassword');
    Assert(@UmGetUserPassword <> nil);
    @UmIsUserInstalled:= GetProcAddress(DLLHandle,'UmIsUserInstalled');
    Assert(@UmIsUserInstalled <> nil);
    @UmIsUserProfile:= GetProcAddress(DLLHandle,'UmIsUserProfile');
    Assert(@UmIsUserProfile <> nil);
    @UmSetUserName:= GetProcAddress(DLLHandle,'UmSetUserName');
    Assert(@UmSetUserName <> nil);
    @UmSetUserDirectory:= GetProcAddress(DLLHandle,'UmSetUserDirectory');
    Assert(@UmSetUserDirectory <> nil);
    @UmSetUserInstall:= GetProcAddress(DLLHandle,'UmSetUserInstall');
    Assert(@UmSetUserInstall <> nil);
    @UmSetUserPermSyncPreferences:= GetProcAddress(DLLHandle,'UmSetUserPermSyncPreferences');
    Assert(@UmSetUserPermSyncPreferences <> nil);
    @UmSetUserTempSyncPreferences:= GetProcAddress(DLLHandle,'UmSetUserTempSyncPreferences');
    Assert(@UmSetUserTempSyncPreferences <> nil);
    @UmGetUserPermSyncPreferences:= GetProcAddress(DLLHandle,'UmGetUserPermSyncPreferences');
    Assert(@UmGetUserPermSyncPreferences <> nil);
    @UmGetUserTempSyncPreferences:= GetProcAddress(DLLHandle,'UmGetUserTempSyncPreferences');
    Assert(@UmGetUserTempSyncPreferences <> nil);
    @UmRemoveUserTempSyncPreferences:= GetProcAddress(DLLHandle,'UmRemoveUserTempSyncPreferences');
    Assert(@UmRemoveUserTempSyncPreferences <> nil);
    @UmDeleteUserPermSyncPreferences:= GetProcAddress(DLLHandle,'UmDeleteUserPermSyncPreferences');
    Assert(@UmDeleteUserPermSyncPreferences <> nil);
    @UmDeleteUserTempSyncPreferences:= GetProcAddress(DLLHandle,'UmDeleteUserTempSyncPreferences');
    Assert(@UmDeleteUserTempSyncPreferences <> nil);
    @UmAddUser:= GetProcAddress(DLLHandle,'UmAddUser');
    Assert(@UmAddUser <> nil);
    @UmDeleteUser:= GetProcAddress(DLLHandle,'UmDeleteUser');
    Assert(@UmDeleteUser <> nil);
    @UmGetRootDirectory:= GetProcAddress(DLLHandle,'UmGetRootDirectory');
    Assert(@UmGetRootDirectory <> nil);
    @UmIsInstallMaskSet:= GetProcAddress(DLLHandle,'UmIsInstallMaskSet');
    Assert(@UmIsInstallMaskSet <> nil);
    @UmClearInstallMask:= GetProcAddress(DLLHandle,'UmClearInstallMask');
    Assert(@UmClearInstallMask <> nil);
    @UmSetInstallMask:= GetProcAddress(DLLHandle,'UmSetInstallMask');
    Assert(@UmSetInstallMask <> nil);
    @UmGetString:= GetProcAddress(DLLHandle,'UmGetString');
    Assert(@UmGetString <> nil);
    @UmSetString:= GetProcAddress(DLLHandle,'UmSetString');
    Assert(@UmSetString <> nil);
    @UmGetInteger:= GetProcAddress(DLLHandle,'UmGetInteger');
    Assert(@UmGetInteger <> nil);
    @UmSetInteger:= GetProcAddress(DLLHandle,'UmSetInteger');
    Assert(@UmSetInteger <> nil);
    @UmDeleteKey:= GetProcAddress(DLLHandle,'UmDeleteKey');
    Assert(@UmDeleteKey <> nil);
    @UmGetIDFromPath:= GetProcAddress(DLLHandle,'UmGetIDFromPath');
    Assert(@UmGetIDFromPath <> nil);
    @UmGetIDFromName:= GetProcAddress(DLLHandle,'UmGetIDFromName');
    Assert(@UmGetIDFromName <> nil);
    @UmSlotGetExpMgrVersion:= GetProcAddress(DLLHandle,'UmSlotGetExpMgrVersion');
    //Assert(@UmSlotGetExpMgrVersion <> nil);
    @UmSlotGetSlotCount:= GetProcAddress(DLLHandle,'UmSlotGetSlotCount');
    //Assert(@UmSlotGetSlotCount <> nil);
    @UmSlotGetInfo:= GetProcAddress(DLLHandle,'UmSlotGetInfo');
    //Assert(@UmSlotGetInfo <> nil);
    @UmSlotGetMediaType:= GetProcAddress(DLLHandle,'UmSlotGetMediaType');
    //Assert(@UmSlotGetMediaType <> nil);
    @UmSlotGetDisplayName:= GetProcAddress(DLLHandle,'UmSlotGetDisplayName');
    //Assert(@UmSlotGetDisplayName <> nil);
    @UmSlotGetInstallDirectory:= GetProcAddress(DLLHandle,'UmSlotGetInstallDirectory');
    //Assert(@UmSlotGetInstallDirectory <> nil);
  end;
end;


initialization
  DllLoaded := False;
  LoadDll;

  if (not DllLoaded) then
    MessageDlg('pfgUserData: Unable to load userdata.dll',mtError,[mbOk],0);

finalization
  if DllLoaded then FreeLibrary(DllHandle);
end.

⌨️ 快捷键说明

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