Hide or disable the desktop icons

Hide or disable the desktop icons

The Desktop is a window like any other window in the system, so you can hide/show and enable/disable it. The only details you need to know is how to retrieve the handle to the Desktop window. It turns out that this window is the first child window of the “Program Manager” window, so all you need is a couple of API functions:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _    lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _    ByVal wCmd As Long) As LongPrivate Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _    ByVal nCmdShow As Long) As LongPrivate Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, _    ByVal fEnable As Long) As LongPrivate Const GW_CHILD = 5Private Const SW_HIDE = 0Private Const SW_SHOW = 5Sub ShowDesktopIcons(ByVal bVisible As Boolean)    Dim hWnd_DesktopIcons As Long    hWnd_DesktopIcons = GetWindow( FindWindow("Progman", "Program Manager"), _        GW_CHILD)    If bVisible Then        ShowWindow hWnd_DesktopIcons, SW_SHOW    Else        ShowWindow hWnd_DesktopIcons, SW_HIDE    End IfEnd SubSub EnableDesktop(ByVal bEnable As Boolean)    Dim hWnd_Desktop As Long    hWnd_Desktop = GetWindow( FindWindow("Progman", "Program Manager"), _        GW_CHILD)    If bEnable Then        EnableWindow hWnd_Desktop, True    Else        EnableWindow hWnd_Desktop, False    End IfEnd Sub

You can make the above code more concise in this way:

Sub ShowDesktopIcons(ByVal bVisible As Boolean)    ShowWindow GetWindow( FindWindow("Progman", "Program Manager"), GW_CHILD), _        IIf(bVisible, SW_SHOW, SW_HIDE)End SubSub EnableDesktop(ByVal bEnable As Boolean)    EnableWindow GetWindow( FindWindow("Progman", "Program Manager"), GW_CHILD), _        bEnableEnd Sub

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved