• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1192
  • Last Modified:

CSIDL_DRIVES?

procedure Tdemarrage.programmesClick(Sender: TObject);
var
ppidl:PItemIDList;
Path:array[0..MAX_PATH] of char;
begin
     SHGetSpecialFolderLocation(Handle,CSIDL_DRIVES,ppidl);
     SHGetPathFromIDList(ppidl,Path);
     ShellExecute(Handle,'open',path,'','',SW_show);
end;

 CSIDL_DESKTOP,CSIDL_STARTMENU work but the other CSIDL_... doesn't.
Why?
0
seb24
Asked:
seb24
  • 2
1 Solution
 
MadshiCommented:
seb24,

SHGetPathFromIDList does only return path names like "c:\windows\desktop" or "e:\".
CSIDL_Drives is the "MyComputer" pidl. There's no "normal" path for it.

Regards, Madshi.

P.S: It seems that you've forgotten to free the pidl! Please add the following line add the end of your procedure:

  FreePidl(ppidl);

And the following procedure to your unit:

procedure FreePidl(var pidl: PItemIDList);
var malloc : IMalloc;
begin
  if (pidl<>nil) and (SHGetMalloc(malloc)=NOERROR) then begin
    malloc.Free(pidl);
    pidl:=nil;
  end;
end;

P.P.S: You can use the IShellFolder interface to get the display name of CSIDL_Drives (and other). But that can't be done in a few lines...
0
 
MadshiCommented:
P.P.P.P.P.P.S: With ShellExecuteEx you can execute the pidl returned from SHGetSpecialFolderLocation directly. Perhaps that works with ShellExecute, too. I don't know. If not, then look at ShellExecuteEx.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now