Category: System Information
Title: Get the startmenu's directory
Date added: 15.03.2006
Hits: 1755
uses
ShlObj, ActiveX;
procedure FreePidl(pidl: PItemIDList);
var
allocator: IMalloc;
begin
if Succeeded(SHGetMalloc(allocator))
then
begin
allocator.Free(pidl);
{$IFDEF VER100}
allocator.Release;
{$ENDIF}
end;
end;
function GetStartMenu: string;
var
pidl: PItemIDList;
buf:
array[0..MAX_PATH]
of Char;
begin
if Succeeded(SHGetSpecialFolderLocation(Form1.Handle, CSIDL_STARTMENU, pidl))
then
SHGetPathFromIDList(pidl, buf);
Result := StrPas(buf);
FreePIDL(pidl);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := GetStartMenu;
end;