Autor Beitrag
schitho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 288

XP Home SP2
D2005 Prof
BeitragVerfasst: Fr 10.10.03 00:25 
Hi,

Windows legt alle Dateien, die sich am Desktop befinden in einem eigenen Ordner ab.

Das Ermitteln des Pfades für den Desktop funktioniert tadellos.

Unter W2000 (XP?) werden aber scheinbar mehrere Pfade verwendet. Nämlich einen für Alle-User und einen für den aktuellen User.

Zum ermitteln des Pfades für den Desktop verwende ich folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
function GetSpecialFolder(hWindow: HWND; Folder: Integer): String;
// Systempfade ermitteln
var
  pMalloc: IMalloc;
  pidl: PItemIDList;
  Path: PChar;
begin
  // get IMalloc interface pointer
  if (SHGetMalloc(pMalloc) <> S_OK) then begin
    MessageBox(hWindow, 'Couldn''t get pointer to IMalloc interface.',
               'SHGetMalloc(pMalloc)'16);
    Exit;
  end;

  // retrieve path
  SHGetSpecialFolderLocation(hWindow, Folder, pidl);
  GetMem(Path, MAX_PATH);
  SHGetPathFromIDList(pidl, Path);
  Result := Path;
  FreeMem(Path);

  // free memory allocated by SHGetSpecialFolderLocation
  pMalloc.Free(pidl);
end;


Aufgerufen wird es so:

ausblenden Delphi-Quelltext
1:
dirPfad:=GetSpecialFolder(Handle, CSIDL_DESKTOPDIRECTORY);					


Unter W98 funktioniert das auch.

Unter W2000 aber nicht, weil eben nur der Pfad für den aktuellen User ermittelt wird. Zur vollständigen Anzeige benötige ich aber auch den Pfad für den Desktop aller User. Wie komme ich zu diesem??

Gruß
Thomas

_________________
(Sorry! Leider ewiger Delphi-Neuling)
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 10.10.03 01:03 
Bestimmt nicht im Offtopic. :roll:
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 10.10.03 11:11 
Hallo!

Dann benutze doch die Konstante CSIDL_COMMON_DESKTOPDIRECTORY.
MDSN hat folgendes geschrieben:
CSIDL_COMMON_DESKTOPDIRECTORY (0x0019)
The file system directory that contains files and folders that appear on the desktop for all users. A typical path is C:\Documents and Settings\All Users\Desktop. Valid only for Windows NT systems.

Gruß
Tino