Hallo ich muss aus einem 32 Bit Programm heraus ermitteln
ob ein ein angeebener Pfad dem Programme Verzeichnis entspricht bzw. darin liegt.
Das muss auch funktionieren wenn das Programm auf einem 64Bit Betriebsystem läuft.
Ich mache das wie folgt:
Delphi-Quellcode:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Registry,
ActiveX,
ComObj,
ShlObj;
Function CheckForProgramFilesPath(aPath:
String):Boolean;
var Ppath:
String;
hPath: PChar;
pIdl: PItemIDList
Begin
aPath := ExpandUNCFileName(aPath);
PPath := '
';
if SUCCEEDED(SHGetSpecialFolderLocation(0, CSIDL_PROGRAM_FILES, pidl))
then
begin
hPath := StrAlloc(MAX_PATH);
SHGetPathFromIDList(pIdl, hPath);
PPath := hPath;
StrDispose(hPath);
end;
FreePIDL(pIdl);
Result := Ansipos(PPath, aPath) = 1;
End;
Ich bin mir nicht ganz sicher, kann es hier auch nicht testen, aber kann es sein das dieser Code auf einem 64Bit Betriebssystem nicht funktioniert?
Was gibt SHGetSpecialFolderLocation für CSIDL_PROGRAM_FILES zurrück wenn man es auf einem 64 Bit Betriebsystem mit einer 32 Bit Anwendung abfragt?