473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C#-Enumerate all logical and virtual drives-folders from desktop

Hello,
I've been trying to find a way to enumerate all drives- logical and virtual starting at the desktop for an explorer clone. I know how to get the logical drives and icons, but have not found a way to get all the drives and folders.
I think IShellFolder with enumobjects is used but I can't find an example.
Thank you for your help.
Jul 20 '07 #1
2 3990
pbmods
5,821 Expert 4TB
Heya, Bruce. Welcome to TSDN!

We don't really have a D-flat forum here, but I'll go ahead and move your post to the .NET forum, where one of our resident Experts should be able to help you out.
Jul 20 '07 #2
Hello,
I've been trying to find a way to enumerate all drives- logical and virtual starting at the desktop for an explorer clone. I know how to get the logical drives and icons, but have not found a way to get all the drives and folders.
I think IShellFolder with enumobjects is used but I can't find an example.
Thank you for your help.
Expand|Select|Wrap|Line Numbers
  1.         private void PidlEnumerate()
  2.         {
  3.             IntPtr pidlDrives;
  4.             IntPtr pidlItems = IntPtr.Zero;
  5.             IShellFolder pShellFolder;
  6.             IntPtr ppenum = IntPtr.Zero;
  7.             uint celtFetched = 0;
  8.             int retValue;
  9.             ShellApi.STRRET sDisplayName;
  10.             string pszDisplayName = null;
  11.             uint uAttr = 0;
  12.             IMalloc pMalloc;
  13.             const bool S_OK = true;
  14.  
  15.             pMalloc = ShellLib.ShellFunctions.GetMalloc();
  16.  
  17.             pShellFolder = ShellFunctions.GetDesktopFolder();
  18.  
  19.             retValue = ShellApi.SHGetFolderLocation(IntPtr.Zero, (int)    ShellApi.CSIDL.CSIDL_DRIVES, IntPtr.Zero, 0, out pidlDrives);
  20.  
  21.             pShellFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, pszDisplayName, ref celtFetched, out pidlDrives, ref uAttr);
  22.  
  23.             //retValue = pShellFolder.BindToObject(pidlDrives, IntPtr.Zero, ShellGUIDs.IID_IShellFolder, out ppenum);
  24.             retValue = ShellApi.SHBindToParent(pidlDrives, ShellLib.ShellGUIDs.IID_IShellFolder,
  25.                             out ppenum, ref pidlItems);
  26.  
  27.             retValue = pShellFolder.EnumObjects(this.Handle, (int)ShellApi.SHCONTF.SHCONTF_FOLDERS | (int)ShellApi.SHCONTF.SHCONTF_NONFOLDERS, out ppenum);
  28.  
  29.             while (retValue = ppenum.Next(1, pidlItems, celtFetched) == S_OK && (celtFetched) == 1)
  30.             {
  31.                 pShellFolder.GetDisplayNameOf(pidlDrives, (uint)ShellLib.ShellApi.SHGNO.SHGDN_NORMAL
  32.                                     | (uint)ShellLib.ShellApi.SHGNO.SHGDN_FORPARSING, out sDisplayName);
  33.  
  34.                 string sDisplay;
  35.                 ShellApi.StrRetToBSTR(ref sDisplayName, pidlDrives, out sDisplay);
  36.  
  37.                 pMalloc.Free(pidlDrives);
  38.                 System.Runtime.InteropServices.Marshal.ReleaseComObject(pMalloc);
  39.  
  40.                 MessageBox.Show(sDisplay);
  41.             }
  42.         }
  43.  
Jul 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: rogerclive | last post by:
Perhaps, there is no bigger sleazy company in the entire Maple Republic ( Canada ) than Matrox Graphics Inc. I paid $100+ through my nose circa 1999 for Matrox Millenium II and Mystique. It...
14
by: Bruno van Dooren | last post by:
Hi all, i am having a problems with inheritance. consider the following: class A { public: A(int i){;} };
5
by: TerryWilson | last post by:
I am developing a web based service tool using asp.net that we will distribute with our product. This service tool will be used for remotely configuring the product, problem determination, etc. ...
5
by: DraguVaso | last post by:
Hi, I want my appliation to Run a Shortcut on my Desktop. This should be done regardless the fact if the Shortcut is in the All Users\Desktop or MyProfile\Desktop and regardless the version of...
15
by: Jim Hubbard | last post by:
Is it possible to emulate a monitor (create a virtual monitor) using vb.net? Any code snippets or pointers to helpful articles would be very much appreciated.
2
by: Maciej Bliziński | last post by:
Hello Pythonists, I'd like to write for myself a tiny program that counts time spent on each virtual desktop (in GNOME). In order to do that, I need my program to detect the current virtual...
2
by: John Brock | last post by:
At work we are using a virtual desktop manager called AltDesk (http://www.astonshell.com/), and it is causing a weird and extremely annoying problem with the VB.NET application I am developing. ...
7
by: desktop | last post by:
This page: http://www.eptacom.net/pubblicazioni/pub_eng/mdisp.html start with the line: "Virtual functions allow polymorphism on a single argument". What does that exactly mean? I guess it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.