How to use Shell32 within a C# application?
Just add a reference to Shell32.dll
from the Windows\System32
folder and use it:
Shell32.Shell shell = new Shell32.Shell();
shell.MinimizeAll();
maybe this can help:
- Right click project
- Click
Add reference
- Click
.COM
tab inAdd reference
dialogue - Select
Microsoft Shell Controls and Automation
- Click OK
your shell32
is ready to use...
I know this thread is old, but I post this for anyone having the same problem as I did. The solution above does not compile under windows 8
Shell32.Shell shell = new Shell32.Shell(); <= this doesn't work with windows 8
Use the work around below if you want your apps to run under windows 8.
using Shell32;
private Shell32.Folder GetShell32Folder(string folderPath)
{
Type shellAppType = Type.GetTypeFromProgID("Shell.Application");
Object shell = Activator.CreateInstance(shellAppType);
return (Shell32.Folder)shellAppType.InvokeMember("NameSpace",
System.Reflection.BindingFlags.InvokeMethod, null, shell, new object[] { folderPath });
}