Solved

CSIDL_DRIVES?

Posted on 1998-09-18
2
1,057 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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now