ShGetSpecialFolderLocation

19:44
unit Unit1;
 
interface
 
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShlObj, ActiveX,shellapi;
 
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
 
var
Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
function GetShellFoldername(folderID: Integer): string;
var
pidl: PItemIDList;
buf: array[0..MAX_PATH] of Char;
begin
Result := '';
if Succeeded(ShGetSpecialFolderLocation(0, folderID, pidl))
then begin
if ShGetPathfromIDList(pidl, buf) then
Result := buf;
CoTaskMemFree(pidl);
end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
shellexecute(handle,'open','explorer.exe',PChar(GetShellFoldername(CSIDL_DRIVES)),'',SW_SHOW);
end;
 
end.


Константы пространства имен для SHGetSpecialFolderLocation:
http://www.firststeps.ru/mfc/detail/r.php?48