Hi Kwacks,
Based on my understanding, you want to minimize all windows on the desktop and show desktop. Please have a try using the following sample code through
Type.InvokeMember Method. Correct me if I misunderstand you.
private Type typeShell = null;
private object objShell = Type.Missing;
// Invoke MinimizeAll to minimize all windows on the desktop
private void button1_Click(object sender, EventArgs e)
{
// Get the type from Shell.Application
typeShell = Type.GetTypeFromProgID("Shell.Application");
// Create object objShell from the type typeShell
objShell = Activator.CreateInstance(typeShell);
// Invoke MinimizeAll to show the desktop
typeShell.InvokeMember("MinimizeAll", System.Reflection.BindingFlags.InvokeMethod, null, objShell, null);
}
// Invoke UndoMinimizeAll to restore all the Desktop windows
private void button2_Click(object sender, EventArgs e)
{
typeShell = Type.GetTypeFromProgID("Shell.Application");
objShell = Activator.CreateInstance(typeShell);
typeShell.InvokeMember("UndoMinimizeAll", System.Reflection.BindingFlags.InvokeMethod, null, objShell, null);
}
Best regards,
Guo
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.