Board index » delphi » Open a virtual folder.

Open a virtual folder.

Hi!
I would like to be able to open a virtual folder (like 'My computer',
'Printers' etc.) from my application.
ShellExecute won't do the job.
Does anyone know how I can do that?
Thanks in advance.
--
Yours

Poul Bak
(Don't get Bit-hysterical, remember 2 bits are just a little bit more than
1).

 

Re:Open a virtual folder.


try:

uses ShellAPI, ShlOBJ,...

procedure TForm1.Button1Click(Sender: TObject);
     var
       pidl: PITEMIDLIST;
       PMalloc: IMalloc;
       sei :  TShellExecuteInfo;
     begin
       try
         SHGetMalloc(PMalloc);
         ZeroMemory(@sei, sizeof(sei));

//csidl_desktop = desktop
//csidl_drives = my computer
//csidl_bitbucket = recycle bin...

          SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,pidl);
           with sei do
           begin
             cbSize := SizeOf(sei);
             fMask := SEE_MASK_IDLIST;
             lpVerb := 'open';
             lpIDList := pidl;
             nShow:=SW_SHOWNORMAL;
           end;
         ShellExecuteEx(@sei);
       finally
         pMalloc._Release;
         pMalloc := nil;
       end;
     end;

hth, ales

Quote
Matthias Thiel wrote:
> :Poul S. Bak <poul.s....@get2net.dk> schrieb in im Newsbeitrag:
> 81n0kc$i7...@news.inet.tele.dk...
> : Hi!
> : I would like to be able to open a virtual folder (like 'My computer',
> : 'Printers' etc.) from my application.
> : ShellExecute won't do the job.
> : Does anyone know how I can do that?
> : Thanks in advance.
> : --
> : Yours
> :
> : Poul Bak
> : (Don't get Bit-hysterical, remember 2 bits are just a little bit more than
> : 1).
> :

> Hi, Poul.
> I don't know if it's the right way but you can use the functions
> SHGetSpecialFolderLocation
> and
> SHGetPathFromIDList
> to get the directories of these special folders and open the folder with
> ShellExecute.
> The constants for the special folders are definded n ShlObj (Delphi 2...)
> and start with
> CSIDL_
> (e.g. CSIDL_PRINTERS for Printers, CSIDL_DRIVES for My Computer)...

> Hth,
> Matthias.

Re:Open a virtual folder.


Hi,

Take a look at the topic "Shell's Namespaces" in
the Win32 API guide. It is a bit complex in the beginning,
but just read carefully and it's not too hard.

Best Regards,
Sander van de Merwe
vandeme...@caiw.nl

Quote
"Poul S. Bak" wrote:
> Hi!
> I would like to be able to open a virtual folder (like 'My computer',
> 'Printers' etc.) from my application.
> ShellExecute won't do the job.
> Does anyone know how I can do that?
> Thanks in advance.
> --
> Yours

> Poul Bak
> (Don't get Bit-hysterical, remember 2 bits are just a little bit more than
> 1).

Other Threads