Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#6

Re: Systemvariable SYSTEMROOT verwenden

  Alt 17. Okt 2005, 22:08
Also mit CSIDL_DESKTOP geht es:
Delphi-Quellcode:
uses
  ShlObj, ActiveX;


function GetShellFolder(CSIDL: integer): string;
var
  pidl : PItemIdList;
  FolderPath : string;
  SystemFolder : Integer;
  Malloc : IMalloc;
begin
  Malloc := nil;
  FolderPath := '';
  SHGetMalloc(Malloc);
  if Malloc = nil then
  begin
    Result := FolderPath;
    Exit;
  end;
  try
    SystemFolder := CSIDL;
    if SUCCEEDED(SHGetSpecialFolderLocation(0, SystemFolder, pidl)) then
    begin
      SetLength(FolderPath, max_path);
      if SHGetPathFromIDList(pidl, PChar(FolderPath)) then
      begin
        SetLength(FolderPath, length(PChar(FolderPath)));
      end;
    end;
    Result := FolderPath;
  finally
    Malloc.Free(pidl);
  end;

end;

const
  CSIDL_MYDOCUMENTS = $000C;
  CSIDL_DESKTOP = $0000;


procedure TForm1.Button1Click(Sender: TObject);
begin
  showMessage(GetShellFolder(CSIDL_DESKTOP) + '\test.txt');
end;
Mit CSIDL_MYDOCUMEBNTS bekomme ich das gleiche Ergebnis wie du.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat