AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Vergleich: SHGetSpecialFolderLocation - ShGetKnownFolderPath
Thema durchsuchen
Ansicht
Themen-Optionen

Vergleich: SHGetSpecialFolderLocation - ShGetKnownFolderPath

Ein Thema von hathor · begonnen am 11. Sep 2012 · letzter Beitrag vom 12. Sep 2012
Antwort Antwort
hathor
(Gast)

n/a Beiträge
 
#1

Vergleich: SHGetSpecialFolderLocation - ShGetKnownFolderPath

  Alt 11. Sep 2012, 10:30
Während es bei der älteren Version einfach ist, alle auf dem PC vorhandenen Specialfolder aufzulisten,
ist es bei der neuen Version aufwändiger. Vereinfachungen und Verbesserungen sind willkommen!
Gerne hätte ich in der Fehlermeldung den "Friendly name" statt die GUID.

Getestet unter WIN 7 64Bit.
Erstellt mit DELPHI 2009.

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls,
  ComObj,
  ActiveX, // IMalloc
  ShellAPI, // SHGetSpecialFolderLocation() und SHGetPathFromIDList()
  ShlObj; // CSIDL_-Konstanten

type
  KNOWNFOLDERID = TGuid;
  TSHGetKnownFolderPath = function(const rfid: KNOWNFOLDERID; dwFlags: DWord; hToken: THandle; var ppSzPath: LPWSTR) : HResult;
StdCall;
function SHGetFolderPath(hwnd: HWND; csidl: Integer; hToken: THandle; dwFlags: DWORD; pszPath: PChar): HResult; stdcall; external 'shfolder.dllname 'SHGetFolderPathA';

const
  FOLDERID_AddNewPrograms: KNOWNFOLDERID = '{de61d971-5ebc-4f02-a3a9-6c82895e5c04}';
  FOLDERID_AdminTools: KNOWNFOLDERID = '{724EF170-A42D-4FEF-9F26-B60E846FBA4F}';
  FOLDERID_AppUpdates: KNOWNFOLDERID = '{a305ce99-f527-492b-8b1a-7e76fa98d6e4}';
  FOLDERID_CDBurning: KNOWNFOLDERID = '{9E52AB10-F80D-49DF-ACB8-4330F5687855}';
  FOLDERID_ChangeRemovePrograms: KNOWNFOLDERID = '{df7266ac-9274-4867-8d55-3bd661de872d}';
  FOLDERID_CommonAdminTools: KNOWNFOLDERID = '{D0384E7D-BAC3-4797-8F14-CBA229B392B5}';
  FOLDERID_CommonOEMLinks: KNOWNFOLDERID = '{C1BAE2D0-10DF-4334-BEDD-7AA20B227A9D}';
  FOLDERID_CommonPrograms: KNOWNFOLDERID = '{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8}';
  FOLDERID_CommonStartMenu: KNOWNFOLDERID = '{A4115719-D62E-491D-AA7C-E74B8BE3B067}';
  FOLDERID_CommonStartup: KNOWNFOLDERID = '{82A5EA35-D9CD-47C5-9629-E15D2F714E6E}';
  FOLDERID_CommonTemplates: KNOWNFOLDERID = '{B94237E7-57AC-4347-9151-B08C6C32D1F7}';
  FOLDERID_ComputerFolder: KNOWNFOLDERID = '{0AC0837C-BBF8-452A-850D-79D08E667CA7}';
  FOLDERID_ConflictFolder: KNOWNFOLDERID = '{4bfefb45-347d-4006-a5be-ac0cb0567192}';
  FOLDERID_ConnectionsFolder: KNOWNFOLDERID = '{6F0CD92B-2E97-45D1-88FF-B0D186B8DEDD}';
  FOLDERID_Contacts: KNOWNFOLDERID = '{56784854-C6CB-462b-8169-88E350ACB882}';
  FOLDERID_ControlPanelFolder: KNOWNFOLDERID = '{82A74AEB-AEB4-465C-A014-D097EE346D63}';
  FOLDERID_Cookies: KNOWNFOLDERID = '{2B0F765D-C0E9-4171-908E-08A611B84FF6}';
  FOLDERID_Desktop: KNOWNFOLDERID = '{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}';
  FOLDERID_DeviceMetadataStore: KNOWNFOLDERID = '{5CE4A5E9-E4EB-479D-B89F-130C02886155}';
  FOLDERID_DocumentsLibrary: KNOWNFOLDERID = '{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}';
  FOLDERID_Downloads: KNOWNFOLDERID = '{374DE290-123F-4565-9164-39C4925E467B}';
  FOLDERID_Favorites: KNOWNFOLDERID = '{1777F761-68AD-4D8A-87BD-30B759FA33DD}';
  FOLDERID_Fonts : KNOWNFOLDERID ='{FD228CB7-AE11-4AE3-864C-16F3910AB8FE}';
  FOLDERID_Games : KNOWNFOLDERID ='{CAC52C1A-B53D-4edc-92D7-6B2E8AC19434}';
  FOLDERID_GameTasks : KNOWNFOLDERID ='{054FAE61-4DD8-4787-80B6-090220C4B700}';
  FOLDERID_History : KNOWNFOLDERID ='{D9DC8A3B-B784-432E-A781-5A1130A75963}';
  FOLDERID_HomeGroup : KNOWNFOLDERID ='{52528A6B-B9E3-4ADD-B60D-588C2DBA842D}';
  FOLDERID_ImplicitAppShortcuts : KNOWNFOLDERID ='{BCB5256F-79F6-4CEE-B725-DC34E402FD46}';
  FOLDERID_InternetCache : KNOWNFOLDERID ='{352481E8-33BE-4251-BA85-6007CAEDCF9D}';
  FOLDERID_InternetFolder : KNOWNFOLDERID ='{4D9F7874-4E0C-4904-967B-40B0D20C3E4B}';
  FOLDERID_Libraries : KNOWNFOLDERID ='{1B3EA5DC-B587-4786-B4EF-BD1DC332AEAE}';
  FOLDERID_Links : KNOWNFOLDERID ='{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}';
  FOLDERID_LocalAppData : KNOWNFOLDERID ='{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}';
  FOLDERID_LocalAppDataLow : KNOWNFOLDERID ='{A520A1A4-1780-4FF6-BD18-167343C5AF16}';
  FOLDERID_LocalizedResourcesDir : KNOWNFOLDERID ='{2A00375E-224C-49DE-B8D1-440DF7EF3DDC}';
  FOLDERID_Music : KNOWNFOLDERID ='{4BD8D571-6D19-48D3-BE97-422220080E43}';
  FOLDERID_MusicLibrary : KNOWNFOLDERID ='{2112AB0A-C86A-4FFE-A368-0DE96E47012E}';
  FOLDERID_NetHood : KNOWNFOLDERID ='{C5ABBF53-E17F-4121-8900-86626FC2C973}';
  FOLDERID_NetworkFolder : KNOWNFOLDERID ='{D20BEEC4-5CA8-4905-AE3B-BF251EA09B53}';
  FOLDERID_OriginalImages : KNOWNFOLDERID ='{2C36C0AA-5812-4b87-BFD0-4CD0DFB19B39}';
  FOLDERID_PhotoAlbums : KNOWNFOLDERID ='{69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C}';
  FOLDERID_PicturesLibrary : KNOWNFOLDERID ='{A990AE9F-A03B-4E80-94BC-9912D7504104}';
  FOLDERID_Pictures : KNOWNFOLDERID ='{33E28130-4E1E-4676-835A-98395C3BC3BB}';
  FOLDERID_Playlists : KNOWNFOLDERID ='{DE92C1C7-837F-4F69-A3BB-86E631204A23}';
  FOLDERID_PrintersFolder : KNOWNFOLDERID ='{76FC4E2D-D6AD-4519-A663-37BD56068185}';
  FOLDERID_PrintHood : KNOWNFOLDERID ='{9274BD8D-CFD1-41C3-B35E-B13F55A758F4}';
  FOLDERID_Profile : KNOWNFOLDERID ='{5E6C858F-0E22-4760-9AFE-EA3317B67173}';
  FOLDERID_ProgramData : KNOWNFOLDERID ='{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}';
  FOLDERID_ProgramFiles: KNOWNFOLDERID ='{905e63b6-c1bf-494e-b29c-65b732d3d21a}';
  FOLDERID_ProgramFilesX64: KNOWNFOLDERID ='{6D809377-6AF0-444b-8957-A3773F02200E}';
  FOLDERID_ProgramFilesX86: KNOWNFOLDERID ='{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}';
  FOLDERID_ProgramFilesCommon: KNOWNFOLDERID ='{F7F1ED05-9F6D-47A2-AAAE-29D317C6F066}';
  FOLDERID_ProgramFilesCommonX64: KNOWNFOLDERID ='{6365D5A7-0F0D-45E5-87F6-0DA56B6A4F7D}';
  FOLDERID_ProgramFilesCommonX86: KNOWNFOLDERID ='{DE974D24-D9C6-4D3E-BF91-F4455120B917}';
  FOLDERID_Programs : KNOWNFOLDERID ='{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}';
  FOLDERID_Public : KNOWNFOLDERID ='{DFDF76A2-C82A-4D63-906A-5644AC457385}';
  FOLDERID_PublicDesktop : KNOWNFOLDERID ='{C4AA340D-F20F-4863-AFEF-F87EF2E6BA25}';
  FOLDERID_PublicDocuments : KNOWNFOLDERID ='{ED4824AF-DCE4-45A8-81E2-FC7965083634}';
  FOLDERID_PublicDownloads : KNOWNFOLDERID ='{3D644C9B-1FB8-4f30-9B45-F670235F79C0}';
  FOLDERID_PublicGameTasks : KNOWNFOLDERID ='{DEBF2536-E1A8-4c59-B6A2-414586476AEA}';
  FOLDERID_PublicLibraries : KNOWNFOLDERID ='{48DAF80B-E6CF-4F4E-B800-0E69D84EE384}';
  FOLDERID_PublicMusic : KNOWNFOLDERID ='{3214FAB5-9757-4298-BB61-92A9DEAA44FF}';
  FOLDERID_PublicPictures : KNOWNFOLDERID ='{B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5}';
  FOLDERID_PublicRingtones : KNOWNFOLDERID ='{E555AB60-153B-4D17-9F04-A5FE99FC15EC}';
  FOLDERID_PublicVideos : KNOWNFOLDERID ='{2400183A-6185-49FB-A2D8-4A392A602BA3}';
  FOLDERID_QuickLaunch : KNOWNFOLDERID ='{52a4f021-7b75-48a9-9f6b-4b87a210bc8f}';
  FOLDERID_Recent : KNOWNFOLDERID ='{AE50C081-EBD2-438A-8655-8A092E34987A}';
  FOLDERID_RecordedTVLibrary : KNOWNFOLDERID ='{1A6FDBA2-F42D-4358-A798-B74D745926C5}';
  FOLDERID_RecycleBinFolder : KNOWNFOLDERID ='{B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC}';
  FOLDERID_ResourceDir : KNOWNFOLDERID ='{8AD10C31-2ADB-4296-A8F7-E4701232C972}';
  FOLDERID_Ringtones : KNOWNFOLDERID ='{C870044B-F49E-4126-A9C3-B52A1FF411E8}';
  FOLDERID_RoamingAppData : KNOWNFOLDERID ='{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}';
  FOLDERID_SampleMusic : KNOWNFOLDERID ='{B250C668-F57D-4EE1-A63C-290EE7D1AA1F}';
  FOLDERID_SamplePictures : KNOWNFOLDERID ='{C4900540-2379-4C75-844B-64E6FAF8716B}';
  FOLDERID_SamplePlaylists : KNOWNFOLDERID ='{15CA69B3-30EE-49C1-ACE1-6B5EC372AFB5}';
  FOLDERID_SampleVideos : KNOWNFOLDERID ='{859EAD94-2E85-48AD-A71A-0969CB56A6CD}';
  FOLDERID_SavedGames : KNOWNFOLDERID ='{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}';
  FOLDERID_SavedSearches : KNOWNFOLDERID ='{7d1d3a04-debb-4115-95cf-2f29da2920da}';
  FOLDERID_SEARCH_CSC : KNOWNFOLDERID ='{ee32e446-31ca-4aba-814f-a5ebd2fd6d5e}';
  FOLDERID_SEARCH_MAPI : KNOWNFOLDERID ='{98ec0e18-2098-4d44-8644-66979315a281}';
  FOLDERID_SearchHome : KNOWNFOLDERID ='{190337d1-b8ca-4121-a639-6d472d16972a}';
  FOLDERID_SendTo : KNOWNFOLDERID ='{8983036C-27C0-404B-8F08-102D10DCFD74}';
  FOLDERID_SidebarDefaultParts : KNOWNFOLDERID ='{7B396E54-9EC5-4300-BE0A-2482EBAE1A26}';
  FOLDERID_SidebarParts : KNOWNFOLDERID ='{A75D362E-50FC-4fb7-AC2C-A8BEAA314493}';
  FOLDERID_StartMenu : KNOWNFOLDERID ='{625B53C3-AB48-4EC1-BA1F-A1EF4146FC19}';
  FOLDERID_Startup : KNOWNFOLDERID ='{B97D20BB-F46A-4C97-BA10-5E3608430854}';
  FOLDERID_SyncManagerFolder : KNOWNFOLDERID ='{43668BF8-C14E-49B2-97C9-747784D784B7}';
  FOLDERID_SyncResultsFolder : KNOWNFOLDERID ='{289a9a43-be44-4057-a41b-587a76d7e7f9}';
  FOLDERID_SyncSetupFolder : KNOWNFOLDERID ='{0F214138-B1D3-4a90-BBA9-27CBC0C5389A}';
  FOLDERID_System : KNOWNFOLDERID ='{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}';
  FOLDERID_SystemX86 : KNOWNFOLDERID ='{D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27}';
  FOLDERID_Templates : KNOWNFOLDERID ='{A63293E8-664E-48DB-A079-DF759E0509F7}';
  FOLDERID_UserPinned : KNOWNFOLDERID ='{9E3995AB-1F9C-4F13-B827-48B24B6C7174}';
  FOLDERID_UserProfiles : KNOWNFOLDERID ='{0762D272-C50A-4BB0-A382-697DCD729B80}';
  FOLDERID_UserProgramFiles : KNOWNFOLDERID ='{5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}';
  FOLDERID_UserProgramFilesCommon : KNOWNFOLDERID ='{BCBD3057-CA5C-4622-B42D-BC56DB0AE516}';
  FOLDERID_UsersFiles : KNOWNFOLDERID ='{f3ce0f7c-4901-4acc-8648-d5d44b04ef8f}';
  FOLDERID_UsersLibraries : KNOWNFOLDERID ='{A302545D-DEFF-464b-ABE8-61C8648D939B}';
  FOLDERID_Videos : KNOWNFOLDERID ='{18989B1D-99B5-455B-841C-AB7C74E4DDFC}';
  FOLDERID_VideosLibrary : KNOWNFOLDERID ='{491E922F-5643-4AF4-A7EB-4E7A138D8174}';
  FOLDERID_Windows : KNOWNFOLDERID ='{F38BF404-1D43-42F2-9305-67DE0B28FC23}';

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function GetSpecialFolder(hWindow: HWND; Folder: Integer): String;
var
pMalloc: IMalloc;
pidl: PItemIDList;
Path: PChar;
begin
if (SHGetMalloc(pMalloc) <> S_OK) then
  begin
    MessageBox(hWindow, 'Couldn''t get pointer to IMalloc interface.','SHGetMalloc(pMalloc)', 16);
    Exit;
  end;
SHGetSpecialFolderLocation(hWindow, Folder, pidl);
GetMem(Path, MAX_PATH);
SHGetPathFromIDList(pidl, Path);
Result := Path;
FreeMem(Path);
pMalloc.Free(pidl);
end;
//---------------------------------------------------------------------
function ShGetKnownFolderPath (const rfid: TGUID; dwFlags: DWord;
    hToken: THandle; out ppszPath: PWideChar): HResult;
var
    Shell: HModule;
    Fn: TShGetKnownFolderPath;
begin
    Shell := LoadLibrary ('shell32.dll');
    Win32Check(Shell <> 0);
    try
        @Fn := GetProcAddress (Shell, 'SHGetKnownFolderPath');
        Win32Check (Assigned (Fn));
        Result := Fn (rfid, dwFlags, hToken, ppszPath);
    finally
        FreeLibrary (Shell);
    end;
end;

function GetKnownFolderPath(const rfid: KNOWNFOLDERID; dwFlags: DWord; hToken: THandle): WideString;
var buffer: LPWSTR;
begin
  buffer := nil;
  try
    OleCheck(ShGetKnownFolderPath(rfid, dwFlags, hToken, buffer));
    try Result := buffer; finally CoTaskMemFree(buffer); end;
  except
    Result := 'ERROR';
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i : Integer;
begin //oder 255
for i := 0 to 63 do Memo1.Lines.add(IntToStr(i)+' : '+
GetSpecialFolder(Form1.Handle,i));
end;

procedure TForm1.Button2Click(Sender: TObject);
var i : Integer; RFID : TGUID; FID : Array[1..101] of KNOWNFOLDERID;
begin
  FID[1]:= FOLDERID_AddNewPrograms;// : KNOWNFOLDERID = '{de61d971-5ebc-4f02-a3a9-6c82895e5c04}';
  FID[2]:= FOLDERID_AdminTools;// : KNOWNFOLDERID = '{724EF170-A42D-4FEF-9F26-B60E846FBA4F}';
  FID[3]:= FOLDERID_AppUpdates;// : KNOWNFOLDERID = '{a305ce99-f527-492b-8b1a-7e76fa98d6e4}';
  FID[4]:= FOLDERID_CDBurning;// : KNOWNFOLDERID = '{9E52AB10-F80D-49DF-ACB8-4330F5687855}';
  FID[5]:= FOLDERID_ChangeRemovePrograms;// : KNOWNFOLDERID = '{df7266ac-9274-4867-8d55-3bd661de872d}';
  FID[6]:= FOLDERID_CommonAdminTools;// : KNOWNFOLDERID = '{D0384E7D-BAC3-4797-8F14-CBA229B392B5}';
  FID[7]:= FOLDERID_CommonOEMLinks;// : KNOWNFOLDERID = '{C1BAE2D0-10DF-4334-BEDD-7AA20B227A9D}';
  FID[8]:= FOLDERID_CommonPrograms;// : KNOWNFOLDERID = '{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8}';
  FID[9]:= FOLDERID_CommonStartMenu;// : KNOWNFOLDERID = '{A4115719-D62E-491D-AA7C-E74B8BE3B067}';
  FID[10]:= FOLDERID_CommonStartup;// : KNOWNFOLDERID = '{82A5EA35-D9CD-47C5-9629-E15D2F714E6E}';
  FID[11]:= FOLDERID_CommonTemplates;// : KNOWNFOLDERID = '{B94237E7-57AC-4347-9151-B08C6C32D1F7}';
  FID[12]:= FOLDERID_ComputerFolder;// : KNOWNFOLDERID = '{0AC0837C-BBF8-452A-850D-79D08E667CA7}';
  FID[13]:= FOLDERID_ConflictFolder;// : KNOWNFOLDERID = '{4bfefb45-347d-4006-a5be-ac0cb0567192}';
  FID[14]:= FOLDERID_ConnectionsFolder;// : KNOWNFOLDERID = '{6F0CD92B-2E97-45D1-88FF-B0D186B8DEDD}';
  FID[15]:= FOLDERID_Contacts;// : KNOWNFOLDERID = '{56784854-C6CB-462b-8169-88E350ACB882}';
  FID[16]:= FOLDERID_ControlPanelFolder;// : KNOWNFOLDERID = '{82A74AEB-AEB4-465C-A014-D097EE346D63}';
  FID[17]:= FOLDERID_Cookies;// : KNOWNFOLDERID = '{2B0F765D-C0E9-4171-908E-08A611B84FF6}';
  FID[18]:= FOLDERID_Desktop;// : KNOWNFOLDERID = '{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}';
  FID[19]:= FOLDERID_DeviceMetadataStore;// : KNOWNFOLDERID = '{5CE4A5E9-E4EB-479D-B89F-130C02886155}';
  FID[20]:= FOLDERID_DocumentsLibrary;// : KNOWNFOLDERID = '{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}';
  FID[21]:= FOLDERID_Downloads;// : KNOWNFOLDERID = '{374DE290-123F-4565-9164-39C4925E467B}';
  FID[22]:= FOLDERID_Favorites;// : KNOWNFOLDERID = '{1777F761-68AD-4D8A-87BD-30B759FA33DD}';
  FID[23]:= FOLDERID_Fonts ;// : KNOWNFOLDERID ='{FD228CB7-AE11-4AE3-864C-16F3910AB8FE}';
  FID[24]:= FOLDERID_Games ;// : KNOWNFOLDERID ='{CAC52C1A-B53D-4edc-92D7-6B2E8AC19434}';
  FID[25]:= FOLDERID_GameTasks ;// : KNOWNFOLDERID ='{054FAE61-4DD8-4787-80B6-090220C4B700}';
  FID[26]:= FOLDERID_History ;// : KNOWNFOLDERID ='{D9DC8A3B-B784-432E-A781-5A1130A75963}';
  FID[27]:= FOLDERID_HomeGroup ;// : KNOWNFOLDERID ='{52528A6B-B9E3-4ADD-B60D-588C2DBA842D}';
  FID[28]:= FOLDERID_ImplicitAppShortcuts ;// : KNOWNFOLDERID ='{BCB5256F-79F6-4CEE-B725-DC34E402FD46}';
  FID[29]:= FOLDERID_InternetCache ;// : KNOWNFOLDERID ='{352481E8-33BE-4251-BA85-6007CAEDCF9D}';
  FID[30]:= FOLDERID_InternetFolder ;// : KNOWNFOLDERID ='{4D9F7874-4E0C-4904-967B-40B0D20C3E4B}';
  FID[31]:= FOLDERID_Libraries ;// : KNOWNFOLDERID ='{1B3EA5DC-B587-4786-B4EF-BD1DC332AEAE}';
  FID[32]:= FOLDERID_Links ;// : KNOWNFOLDERID ='{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}';
  FID[33]:= FOLDERID_LocalAppData ;// : KNOWNFOLDERID ='{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}';
  FID[34]:= FOLDERID_LocalAppDataLow ;// : KNOWNFOLDERID ='{A520A1A4-1780-4FF6-BD18-167343C5AF16}';
  FID[35]:= FOLDERID_LocalizedResourcesDir ;// : KNOWNFOLDERID ='{2A00375E-224C-49DE-B8D1-440DF7EF3DDC}';
  FID[36]:= FOLDERID_Music ;// : KNOWNFOLDERID ='{4BD8D571-6D19-48D3-BE97-422220080E43}';
  FID[37]:= FOLDERID_MusicLibrary ;// : KNOWNFOLDERID ='{2112AB0A-C86A-4FFE-A368-0DE96E47012E}';
  FID[38]:= FOLDERID_NetHood ;// : KNOWNFOLDERID ='{C5ABBF53-E17F-4121-8900-86626FC2C973}';
  FID[39]:= FOLDERID_NetworkFolder ;// : KNOWNFOLDERID ='{D20BEEC4-5CA8-4905-AE3B-BF251EA09B53}';
  FID[40]:= FOLDERID_OriginalImages ;// : KNOWNFOLDERID ='{2C36C0AA-5812-4b87-BFD0-4CD0DFB19B39}';
  FID[41]:= FOLDERID_PhotoAlbums ;// : KNOWNFOLDERID ='{69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C}';
  FID[42]:= FOLDERID_PicturesLibrary ;// : KNOWNFOLDERID ='{A990AE9F-A03B-4E80-94BC-9912D7504104}';
  FID[43]:= FOLDERID_Pictures ;// : KNOWNFOLDERID ='{33E28130-4E1E-4676-835A-98395C3BC3BB}';
  FID[44]:= FOLDERID_Playlists ;// : KNOWNFOLDERID ='{DE92C1C7-837F-4F69-A3BB-86E631204A23}';
  FID[45]:= FOLDERID_PrintersFolder ;// : KNOWNFOLDERID ='{76FC4E2D-D6AD-4519-A663-37BD56068185}';
  FID[46]:= FOLDERID_PrintHood ;// : KNOWNFOLDERID ='{9274BD8D-CFD1-41C3-B35E-B13F55A758F4}';
  FID[47]:= FOLDERID_Profile ;// : KNOWNFOLDERID ='{5E6C858F-0E22-4760-9AFE-EA3317B67173}';
  FID[48]:= FOLDERID_ProgramData ;// : KNOWNFOLDERID ='{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}';
  FID[49]:= FOLDERID_ProgramFiles;// : KNOWNFOLDERID ='{905e63b6-c1bf-494e-b29c-65b732d3d21a}';
  FID[50]:= FOLDERID_ProgramFilesX64;// : KNOWNFOLDERID ='{6D809377-6AF0-444b-8957-A3773F02200E}';
  FID[51]:= FOLDERID_ProgramFilesX86;// : KNOWNFOLDERID ='{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}';
  FID[52]:= FOLDERID_ProgramFilesCommon;// : KNOWNFOLDERID ='{F7F1ED05-9F6D-47A2-AAAE-29D317C6F066}';
  FID[53]:= FOLDERID_ProgramFilesCommonX64;// : KNOWNFOLDERID ='{6365D5A7-0F0D-45E5-87F6-0DA56B6A4F7D}';
  FID[54]:= FOLDERID_ProgramFilesCommonX86;// : KNOWNFOLDERID ='{DE974D24-D9C6-4D3E-BF91-F4455120B917}';
  FID[55]:= FOLDERID_Programs ;// : KNOWNFOLDERID ='{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}';
  FID[56]:= FOLDERID_Public ;// : KNOWNFOLDERID ='{DFDF76A2-C82A-4D63-906A-5644AC457385}';
  FID[57]:= FOLDERID_PublicDesktop ;// : KNOWNFOLDERID ='{C4AA340D-F20F-4863-AFEF-F87EF2E6BA25}';
  FID[58]:= FOLDERID_PublicDocuments ;// : KNOWNFOLDERID ='{ED4824AF-DCE4-45A8-81E2-FC7965083634}';
  FID[59]:= FOLDERID_PublicDownloads ;// : KNOWNFOLDERID ='{3D644C9B-1FB8-4f30-9B45-F670235F79C0}';
  FID[60]:= FOLDERID_PublicGameTasks ;// : KNOWNFOLDERID ='{DEBF2536-E1A8-4c59-B6A2-414586476AEA}';
  FID[61]:= FOLDERID_PublicLibraries ;// : KNOWNFOLDERID ='{48DAF80B-E6CF-4F4E-B800-0E69D84EE384}';
  FID[62]:= FOLDERID_PublicMusic ;// : KNOWNFOLDERID ='{3214FAB5-9757-4298-BB61-92A9DEAA44FF}';
  FID[63]:= FOLDERID_PublicPictures ;// : KNOWNFOLDERID ='{B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5}';
  FID[64]:= FOLDERID_PublicRingtones ;// : KNOWNFOLDERID ='{E555AB60-153B-4D17-9F04-A5FE99FC15EC}';
  FID[65]:= FOLDERID_PublicVideos ;// : KNOWNFOLDERID ='{2400183A-6185-49FB-A2D8-4A392A602BA3}';
  FID[66]:= FOLDERID_QuickLaunch ;// : KNOWNFOLDERID ='{52a4f021-7b75-48a9-9f6b-4b87a210bc8f}';
  FID[67]:= FOLDERID_Recent ;// : KNOWNFOLDERID ='{AE50C081-EBD2-438A-8655-8A092E34987A}';
  FID[68]:= FOLDERID_RecordedTVLibrary ;// : KNOWNFOLDERID ='{1A6FDBA2-F42D-4358-A798-B74D745926C5}';
  FID[69]:= FOLDERID_RecycleBinFolder ;// : KNOWNFOLDERID ='{B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC}';
  FID[70]:= FOLDERID_ResourceDir ;// : KNOWNFOLDERID ='{8AD10C31-2ADB-4296-A8F7-E4701232C972}';
  FID[71]:= FOLDERID_Ringtones ;// : KNOWNFOLDERID ='{C870044B-F49E-4126-A9C3-B52A1FF411E8}';
  FID[72]:= FOLDERID_RoamingAppData ;// : KNOWNFOLDERID ='{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}';
  FID[73]:= FOLDERID_SampleMusic ;// : KNOWNFOLDERID ='{B250C668-F57D-4EE1-A63C-290EE7D1AA1F}';
  FID[74]:= FOLDERID_SamplePictures ;// : KNOWNFOLDERID ='{C4900540-2379-4C75-844B-64E6FAF8716B}';
  FID[75]:= FOLDERID_SamplePlaylists ;// : KNOWNFOLDERID ='{15CA69B3-30EE-49C1-ACE1-6B5EC372AFB5}';
  FID[76]:= FOLDERID_SampleVideos ;// : KNOWNFOLDERID ='{859EAD94-2E85-48AD-A71A-0969CB56A6CD}';
  FID[77]:= FOLDERID_SavedGames ;// : KNOWNFOLDERID ='{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}';
  FID[78]:= FOLDERID_SavedSearches ;// : KNOWNFOLDERID ='{7d1d3a04-debb-4115-95cf-2f29da2920da}';
  FID[79]:= FOLDERID_SEARCH_CSC ;// : KNOWNFOLDERID ='{ee32e446-31ca-4aba-814f-a5ebd2fd6d5e}';
  FID[80]:= FOLDERID_SEARCH_MAPI ;// : KNOWNFOLDERID ='{98ec0e18-2098-4d44-8644-66979315a281}';
  FID[81]:= FOLDERID_SearchHome ;// : KNOWNFOLDERID ='{190337d1-b8ca-4121-a639-6d472d16972a}';
  FID[82]:= FOLDERID_SendTo ;// : KNOWNFOLDERID ='{8983036C-27C0-404B-8F08-102D10DCFD74}';
  FID[83]:= FOLDERID_SidebarDefaultParts ;// : KNOWNFOLDERID ='{7B396E54-9EC5-4300-BE0A-2482EBAE1A26}';
  FID[84]:= FOLDERID_SidebarParts ;// : KNOWNFOLDERID ='{A75D362E-50FC-4fb7-AC2C-A8BEAA314493}';
  FID[85]:= FOLDERID_StartMenu ;// : KNOWNFOLDERID ='{625B53C3-AB48-4EC1-BA1F-A1EF4146FC19}';
  FID[86]:= FOLDERID_Startup ;// : KNOWNFOLDERID ='{B97D20BB-F46A-4C97-BA10-5E3608430854}';
  FID[87]:= FOLDERID_SyncManagerFolder ;// : KNOWNFOLDERID ='{43668BF8-C14E-49B2-97C9-747784D784B7}';
  FID[88]:= FOLDERID_SyncResultsFolder ;// : KNOWNFOLDERID ='{289a9a43-be44-4057-a41b-587a76d7e7f9}';
  FID[89]:= FOLDERID_SyncSetupFolder ;// : KNOWNFOLDERID ='{0F214138-B1D3-4a90-BBA9-27CBC0C5389A}';
  FID[90]:= FOLDERID_System ;// : KNOWNFOLDERID ='{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}';
  FID[91]:= FOLDERID_SystemX86 ;// : KNOWNFOLDERID ='{D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27}';
  FID[92]:= FOLDERID_Templates ;// : KNOWNFOLDERID ='{A63293E8-664E-48DB-A079-DF759E0509F7}';
  FID[93]:= FOLDERID_UserPinned ;// : KNOWNFOLDERID ='{9E3995AB-1F9C-4F13-B827-48B24B6C7174}';
  FID[94]:= FOLDERID_UserProfiles ;// : KNOWNFOLDERID ='{0762D272-C50A-4BB0-A382-697DCD729B80}';
  FID[95]:= FOLDERID_UserProgramFiles ;// : KNOWNFOLDERID ='{5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}';
  FID[96]:= FOLDERID_UserProgramFilesCommon ;// : KNOWNFOLDERID ='{BCBD3057-CA5C-4622-B42D-BC56DB0AE516}';
  FID[97]:= FOLDERID_UsersFiles ;// : KNOWNFOLDERID ='{f3ce0f7c-4901-4acc-8648-d5d44b04ef8f}';
  FID[98]:= FOLDERID_UsersLibraries ;// : KNOWNFOLDERID ='{A302545D-DEFF-464b-ABE8-61C8648D939B}';
  FID[99]:= FOLDERID_Videos;// : KNOWNFOLDERID ='{18989B1D-99B5-455B-841C-AB7C74E4DDFC}';
  FID[100]:= FOLDERID_VideosLibrary;// : KNOWNFOLDERID ='{491E922F-5643-4AF4-A7EB-4E7A138D8174}';
  FID[101]:= FOLDERID_Windows;// : KNOWNFOLDERID ='{F38BF404-1D43-42F2-9305-67DE0B28FC23}';

for i := 1 to 101 do
  BEGIN
    RFID:= FID[i];
    if GetKnownFolderPath(RFID, 0, 0)='ERRORthen
    Memo1.Lines.add(IntToStr(i)+' : '+'No such directory : '+ GUIDtoString(RFID))
   else
    Memo1.Lines.add(IntToStr(i)+' : '+ GetKnownFolderPath(RFID, 0, 0));
  END;
end;

End.
Angehängte Dateien
Dateityp: zip SpecialFolder.zip (286,6 KB, 66x aufgerufen)
  Mit Zitat antworten Zitat
hathor
(Gast)

n/a Beiträge
 
#2

AW: Vergleich: SHGetSpecialFolderLocation - ShGetKnownFolderPath

  Alt 12. Sep 2012, 10:51
Leider scheint mein Anliegen:
"Gerne hätte ich in der Fehlermeldung den "Friendly name" statt die GUID."
untergegangen zu sein.

Es geht um diese Zeile:
Memo1.Lines.add(IntToStr(i)+' : '+'No such directory : '+ GUIDtoString(RFID))

Deshalb noch einmal konkret gefragt:
Wie bekomme ich in der Fehlermeldung die Antwort "FOLDERID_AddNewPrograms" statt "{de61d971-5ebc-4f02-a3a9-6c82895e5c04}"?

Vielen Dank!
  Mit Zitat antworten Zitat
Benutzerbild von p80286
p80286

Registriert seit: 28. Apr 2008
Ort: Stolberg (Rhl)
6.659 Beiträge
 
FreePascal / Lazarus
 
#3

AW: Vergleich: SHGetSpecialFolderLocation - ShGetKnownFolderPath

  Alt 12. Sep 2012, 13:22
Ich vermute, Du mußt das hier ausschlachten.
Nicht unwichtig scheint auch der Hinweis auf die virtuellen Verzeichnisse zu sein.

Gruß
K-H
Programme gehorchen nicht Deinen Absichten sondern Deinen Anweisungen
R.E.D retired error detector
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:36 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz