Einzelnen Beitrag anzeigen

fishly

Registriert seit: 30. Okt 2008
31 Beiträge
 
Delphi 5 Standard
 
#4

Re: "Arbeitsplatz" als FileName in TOpenDialog

  Alt 16. Jan 2010, 22:01
Delphi-Quellcode:
function GetSpecialFolder(const AFolder: Integer): string;
(* const
CSIDL_Desktop für Desktop,
CSIDL_Controls für Systemsteuerung,
CSIDL_Printers für Drucker,
CSIDL_Personal für Eigene Dateien,
CSIDL_Drives für Arbeitsplatz,
CSIDL_Network für Netzwerkumgebung*)


type
_SHELLEXECUTEINFOA = record
  cbSize: DWORD;
  fMask: ULONG;
  Wnd: HWND;
  lpVerb: PAnsiChar;
  lpFile: PAnsiChar;
  lpParameters: PAnsiChar;
  lpDirectory: PAnsiChar;
  nShow: Integer;
  hInstApp: HINST;
  { Optional fields }
  lpIDList: Pointer;
  lpClass: PAnsiChar;
  hkeyClass: HKEY;
  dwHotKey: DWORD;
  hIcon: THandle;
  hProcess: THandle;
end;

ShellExecuteInfo = _SHELLEXECUTEINFOA;

var
  ItemIDList: PItemIDList;
  hPath: PChar;
  ShellH: IMalloc;
begin
  if SUCCEEDED(SHGetSpecialFolderLocation(Application.Handle, AFolder, ItemIDList)) then
  begin
    try
      hPath:= StrAlloc(max_path);
      try
        if SHGetPathFromIDList (ItemIDList, hPath) then
          Result:=hPath;
      finally
        StrDispose(hPath);
      end;
    finally
     if SHGetMalloc(ShellH) = NOERROR then
       ShellH.Free(ItemIDList);
    end;
  end
  else
    RaiseLastWin32Error;
end;
Also so sieht meine Deklaration dann aus.
Wenn ich jetzt das Verzeichnis für Arbeitsplatz haben will, gibt die Funktion einen leeren String zurück. Warum? Hab ich einen Fehler in der Deklaration?
  Mit Zitat antworten Zitat