Solved

CSIDL_DRIVES?

Posted on 1998-09-18
2
1,083 Views
Last Modified: 2008-03-10
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
Comment
Question by:seb24
  • 2
2 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 1340109
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
 
LVL 20

Expert Comment

by:Madshi
ID: 1340110
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question