C# - Show&Hide desktop icons

  • 0 Replies
  • 156 Views

0 Members and 1 Guest are viewing this topic.

Offline Omega

    *
  • The Boss (Admin)
  • Black Hat Sec Member
  • Telegram: @BLACKHATSEC_FORUM
  • Posts: 190
  • Popularity: +1/-0
  • God of Malware
    • View Profile
    • Awards
« on: March 14, 2022, 09:22:27 AM »
C# - Show&Hide desktop icons

Code
//Win32 API's needed
[DllImport("user32", EntryPoint = "FindWindowExA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern long FindWindowEx(long hWnd1, long hWnd2, string lpsz1, string lpsz2);

[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern long SetWindowPos(long hWnd, long hWndInsertAfter, long X, long Y, long cx, long cy, long wFlags);

/// <summary>
/// method for handling the showing/hiding of the desktop icons
/// </summary>
/// <param name="show">condition: show or hide</param>
/// <returns>true/false</returns>
public bool ShowHideDesktopIcons(bool show)
{
    try
    {
        //get a handle to the desktop ("Progman")
        long winHandle = FindWindowEx(0L, 0L, "Progman", null);

        //determine if we're showing or hiding
        switch (show)
        {
            case true:
                ShowWindow(winHandle, 0);
                break;
            case false:
                ShowWindow(winHandle, 5);
                break;
        }
        return true;
    }
    catch (Win32Exception ex)
    {
        MessageBox.Show(ex.ToString());
        return false;
    }
   
}
  • Discord: BLACK HAT SEC#5222
  • [+]
  • [-]

  •