Click here to Skip to main content
15,887,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm not terribly familiar with working with the shell, and I just want to be sure I did this right. All I was after was to use the Shell.MinimizeAll() command. The program creates images for use as background tiles, and I'm adding a "set as wallpaper" feature. As such, I wanted to hide any open windows so the user can see the desktop.

What I did:
1. Added a reference to Shell32.dll
2. Added Imports Shell32 to the .vb file
3. In the sub that minimizes all windows, I added:
VB
Dim sh As New Shell
sh.MinimizeAll()


Works great, but I'm suspicious. Nothing is ever this easy. Is what I've done considered an acceptable practice?
Posted
Updated 27-Aug-11 9:34am
v3
Comments
DaveAuld 27-Aug-11 7:22am    
Why can't things be easy? Depends on what you are trying to achieve to determine if it is acceptable or not, maybe share with us your goal........
Alan Burkhart 27-Aug-11 11:41am    
Just needed to hide all windows. The app creates background tiles and I'm adding a "set as wallpaper" feature.

It does exactly what you what it to.

Shell.MinimizeAll() documentation[^]

You're suspicious? hmm, when I find a solution to a problem to be much easier than I expected, I put on the the party hat and start dancing around the office :D
 
Share this answer
 
v2
Comments
Alan Burkhart 27-Aug-11 16:02pm    
Saw the documentation, but was unsure about my adding the reference like I did. Thanks!
Simon Bang Terkildsen 27-Aug-11 16:11pm    
I've used it myself, I had to attach a screenshot to our error reports, but didn't want that screenshot to contain data from other applications as our customers might not want that.
So I used it to hide all windows and then show my own applications window(s).
And I've not seen any other windows than my own applications windows(s) in the screenshots.
Step 1 :- First Add shell32.dll to your Project Reference.

* open your project . Then click on Project Menu Item.
* Then click on Add Reference
* Then GoTo Browse Tab In Dialog Box
* In File name copy this line "c:\windows\system32\shell32.dll"
* Click Ok.

Step 2
Now Goto Code Window you can write code written below :-

VB
Imports Shell32        **** 'Import the shell32.dll to your code
Public Class Form1
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim shell As New Shell32.Shell        *****'An object is created of type shell32
        shell.MinimizeAll()                   *******''''It will minimize all windows 
    End Sub
End Class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900