Click here to Skip to main content
16,005,162 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to find a created object dynamically Pin
andylke24-Jan-06 21:36
andylke24-Jan-06 21:36 
QuestionUsing checkbox and button in DataList Pin
JayaDurai24-Jan-06 18:25
JayaDurai24-Jan-06 18:25 
QuestionAlter Table query in DBF through C#.NET ,Problem Pin
Anil Dhiman24-Jan-06 17:34
Anil Dhiman24-Jan-06 17:34 
QuestionSearch Engine Pin
Tugbay Sahin24-Jan-06 15:40
Tugbay Sahin24-Jan-06 15:40 
AnswerRe: Search Engine Pin
Heath Stewart24-Jan-06 15:51
protectorHeath Stewart24-Jan-06 15:51 
AnswerRe: Search Engine Pin
tarasn24-Jan-06 20:44
tarasn24-Jan-06 20:44 
QuestionNetwork drives Pin
Libor Tinka24-Jan-06 12:01
Libor Tinka24-Jan-06 12:01 
AnswerRe: Network drives Pin
Heath Stewart24-Jan-06 16:19
protectorHeath Stewart24-Jan-06 16:19 
Enumerating shell namespaces (which is actually what they're called; some namespaces just happen to be drives while others are mapped drives, etc.) includes a lot of complicated calls (relatively speaking). There's no simple solution to what you want to do. To do this correctly WMI isn't the best solution. Instead you need to use the Shell interfaces which return you namespaces and allow you to query for their icons along with many other things. Doing this doesn't work with paths at all, but item ID lists (IDLs) of objects. Folders and files have unique IDs. The control panel has a unique ID, etc. Everything visible in the shell namespace has a unique ID. See Navigating the Namespace[^] for an overview with links and a sample in native code.

Another problem is that since all these interfaces are native you'll need to create RCWs (runtime-callable wrappers) for several dozen interfaces, define lots of constants (you'll need the C/C++ headers in the Platform SDK[^] - also installed with Visual C++ - for values), and define lots and lots of structures - some of which aren't so easy because of unions which don't have an equivalent representation in .NET. Because of this you might consider writing such a control in Managed C++ - which allows you access to native constructs but compiled to managed code (the resulting assembly is actually a mix of native and managed code, which means the assembly isn't verifiable and won't run in some security contexts like from an Internet or intranet site).

The article http://www.codeproject.com/csharp/csdoesshell1.asp[^] on this site will give you a start. You can find other articles about shell namespace extensions in the search results at http://www.codeproject.com/info/search.asp?cats=2&cats=3&cats=4&cats=5&cats=6&searchkw=IShellFolder[^].

You can find some commercial solutions at http://www.windowsforms.net/ControlGallery/default.aspx?Category=29&tabindex=10[^]. It takes a lot of work to write these correctly and the prices for some of these controls is a very good deal (no royalties, either). If you're developing this on a budget you might find using one of these cheaper controls may be cheaper than the cost of resources to write it yourself. Just a suggestion to consider. This is a daunting task, though not impossible. The articles above should give you some idea about enumerating the shell and handling IDLs. With that you can query for other interfaces to get the icons you're desiring.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft

[My Articles] [My Blog]
QuestionSetWindowsHookEx fails on WIN98 Pin
ranzask24-Jan-06 10:31
ranzask24-Jan-06 10:31 
AnswerRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
Heath Stewart24-Jan-06 11:41
protectorHeath Stewart24-Jan-06 11:41 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
ranzask24-Jan-06 11:48
ranzask24-Jan-06 11:48 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
Heath Stewart24-Jan-06 11:52
protectorHeath Stewart24-Jan-06 11:52 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
ranzask24-Jan-06 12:11
ranzask24-Jan-06 12:11 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
Heath Stewart24-Jan-06 12:15
protectorHeath Stewart24-Jan-06 12:15 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
ranzask24-Jan-06 12:38
ranzask24-Jan-06 12:38 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
Heath Stewart24-Jan-06 13:08
protectorHeath Stewart24-Jan-06 13:08 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
ranzask24-Jan-06 13:27
ranzask24-Jan-06 13:27 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
Dave Kreskowiak24-Jan-06 14:45
mveDave Kreskowiak24-Jan-06 14:45 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
ranzask24-Jan-06 14:52
ranzask24-Jan-06 14:52 
GeneralRe: SetWindowsHookEx fails on VS Express and work on VS2003 Pin
Heath Stewart24-Jan-06 15:45
protectorHeath Stewart24-Jan-06 15:45 
QuestionDefaultValueAttribute Pin
tylerl24-Jan-06 10:07
tylerl24-Jan-06 10:07 
AnswerRe: DefaultValueAttribute Pin
Heath Stewart24-Jan-06 11:30
protectorHeath Stewart24-Jan-06 11:30 
QuestionSelf-deleting hashtable entries Pin
User 665824-Jan-06 10:02
User 665824-Jan-06 10:02 
AnswerRe: Self-deleting hashtable entries Pin
tylerl24-Jan-06 10:11
tylerl24-Jan-06 10:11 
GeneralRe: Self-deleting hashtable entries Pin
User 665824-Jan-06 12:58
User 665824-Jan-06 12:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.