桌面图标窗口句柄的获取
刚找了段文章:
GetDestopWindow取到的是桌面窗口的句柄,但不是我们所看到的那个包含图标的
窗口。包含图标的窗口实际上是DesktopWindow的一个字窗口。确切地讲,
Desktop Window包含一个无标题的、类名为“SHELLDLL_DefView”的子窗口,
这个字窗口又包含一个无标题的、类名为“SysListView32”的子窗口——这才是
那个真正包含桌面图标的窗口。
C#里是不是这样写?
[DllImport( "user32 ")]
static extern IntPtr GetDesktopWindow();
[DllImport( "user32 ")]
static extern IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter,string lpszClass,string lpszWindow);
IntPtr HWND=FindWindowEx(GetDesktopWindow(),(IntPtr)null, "SHELLDLL_DefView ", null);
IntPtr HWND2=FindWindowEx(HWND,(IntPtr)null, "SysListView32 ", null)
HWND2是不是就是桌面图标窗口的句柄?
------解决方案--------------------你少了一层 "Program ",下边这样一来就不为空了:
IntPtr HWND3 = FindWindowEx(GetDesktopWindow(), (IntPtr)null, "Progman ", null);
System.Diagnostics.Trace.WriteLine( "HWND3 = " + HWND3.ToString());
IntPtr HWND = FindWindowEx(HWND3, (IntPtr)null, "SHELLDLL_DefView ", null);
System.Diagnostics.Trace.WriteLine( "HWND = " + HWND.ToString());
IntPtr HWND2 = FindWindowEx(HWND, (IntPtr)null, "SysListView32 ", null);
System.Diagnostics.Trace.WriteLine( "HWND2 = " + HWND2.ToString());
------解决方案--------------------怎么spy++里的句柄没一个和EnumWindows列出来的一样的,郁闷
-----------------------
spy++里的句柄 是十六进制
EnumWindows里的句柄 是十进制