Hi TheISOmorph,
Sorry for missreading your question. I can offer you a half solultion (code only replaces application icons, not taskbar...) So you were on the right way with PInvoke, .NET just doesn't give you the tools to replace the application icons - good old windows API helps. Here we go: (simple .NET 4 Console Application)
using System;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace RemoveAllApplicationIcons
{
class Program
{
[DllImport("user32.dll")]
static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDesktopWindowsDelegate lpfn, IntPtr lParam);
private delegate bool EnumDesktopWindowsDelegate(IntPtr hWnd, int lParam);
[DllImport("user32.dll")]
private static extern int GetWindowText(IntPtr hWnd, StringBuilder title, int size);
[DllImport("user32.dll")]
private static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll")]
static extern IntPtr LoadImage(IntPtr hInst, string lpsz, uint uType, int cxDesired, int cyDesired, uint fuLoad);
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
static IntPtr m_pIcon = IntPtr.Zero;
static string[] m_astrFilter = new string[] { "Start", "Program Manager" };
static void Main(string[] args)
{
string strIconFilePath = @"H:\IconEmpty.ico";
const int IMAGE_ICON = 1;
const int LR_LOADFROMFILE = 0x10;
m_pIcon = LoadImage(IntPtr.Zero, strIconFilePath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
EnumDesktopWindows(IntPtr.Zero, new EnumDesktopWindowsDelegate(EnumDesktopWindowsCallback), IntPtr.Zero);
Console.ReadKey();
}
private static bool EnumDesktopWindowsCallback(IntPtr hWnd, int lParam)
{
StringBuilder title = new StringBuilder(256);
GetWindowText(hWnd, title, 256);
string strTitle = title.ToString();
bool bVisible = IsWindowVisible(hWnd);
if (bVisible &&
!String.IsNullOrEmpty(strTitle) &&
!m_astrFilter.Contains(strTitle))
{
SendMessage(hWnd, 0x80, IntPtr.Zero, m_pIcon);
}
return true;
}
}
}
I hope you can extend it and also manage to remove the taskbar icons - let me know!
best regards