2007. március 5., hétfő

Create a Program Group for an application


Problem/Question/Abstract:

Is there a Delphi function or API function with which I can create a program group for an application?

Answer:

Yes, MkDir or CreateDir. The program "groups" are in fact simple directories under the users profile directory.

uses
  ShlObj;

procedure FreePidl(pidl: PItemIDList);
var
  allocator: IMalloc;
begin
  if Succeeded(ShGetMalloc(allocator)) then
  begin
    allocator.Free(pidl);
{$IFDEF VER90}
    allocator.Release;
{$ENDIF}
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  pidl: PItemIDList;
  buf: array[0..MAX_PATH] of Char;
begin
  if Succeeded(ShGetSpecialFolderLocation(Handle, CSIDL_PROGRAMS, pidl)) then
  begin
    if ShGetPathfromIDList(pidl, buf) then
      ShowMessage(buf); {buf has startmenu\programs folder}
    FreePIDL(pidl);
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése