Solved

CSIDL_DRIVES?

Posted on 1998-09-18
2
1,086 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Delphi IDE crash without error message ... 7 119
Typecasting TBytes to Integer in Delphi XE8 2 37
IP without any Dots 1 59
Using MMsystem To change audio input 1 19
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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