Mike Pijl - 2006-11-22

Logged In: YES
user_id=627635
Originator: NO

program FindPalm;

uses
Registry,
Windows,
SysUtils;

{$R *.RES}

var
iResult,iLength:integer;
//sMsg,
sDll,sPath:String;
hDLL:THandle;
// dynamically load CondMgr.dll so we can specify which DLL to load
GetPath:function(pPath: PChar; var piSize: Integer): HResult; stdcall;
begin
sDll:=ExtractFilePath(ParamStr(0))+'CondMgr.dll';

hDLL:=LoadLibrary(PChar(sDLL));
if hDLL<>0 then
try
@GetPath:=GetProcAddress(hDLL,'CmGetHotSyncExecPath');

if @GetPath<>nil then
begin
SetLength(sPath,MAX_PATH);
iLength:=MAX_PATH;
iResult:=GetPath(PChar(sPath),iLength);

sPath:=PChar(sPath);

if iResult<>0 then
Raise Exception.CreateFmt('Error %d in GetHotSyncExecPath',[iResult]);
end
else
RaiseLastWin32Error;
finally
// unload DLL
FreeLibrary(hDLL);
end
else
Raise Exception.Create('Error loading DLL: '+sDLL);

//sMsg:='CondMgr.DLL reports path as: '+CleanDump(sPath);
//MessageBox(0,PChar(sMsg),'Info',MB_IconInformation+MB_OK);

sPath:=ExtractFileDir(sPath);

// c:\palm
//sMsg:='FindPalm converts to: '+sPath;
//MessageBox(0,PChar(sMsg),'Info',MB_IconInformation+MB_OK);

with TRegIniFile.Create(g_scPalmInfoRegistryKey) do
try
WriteString('Palm','PalmDir',sPath);
finally
Free;
end;
end.