|
又研究了一下,之前没有取到列数是因为获得的窗口句柄不对,SysListView32不支持直接获取列数,需要定位到SysHeader32再取列,就可以了。如下代码:
Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString
Extern.Declare micHwnd, "FindWindowEx", "user32.dll", "FindWindowExA", micHwnd, micHwnd, micString, micString
Extern.Declare micHwnd, "SendMessage", "user32.dll", "SendMessageA", micHwnd, micLong, micLong, micLong
Hwnd = extern.FindWindowEx(0,0,vbNullString, "Windows 任务管理器")
Hwnd1 = extern.FindWindowEx(Hwnd,0,"#32770", vbNullString)
Hwnd2 = extern.FindWindowEx(Hwnd1,0,"SysListView32", vbNullString)
Hwnd3 = extern.FindWindowEx(Hwnd2,0, "SysHeader32", vbNullString)
MessageCode = &H1200 'HDM_GETITEMCOUNT
columnCount = extern.SendMessage(Hwnd3,MessageCode,0, 0)
至于列名一样可以取到,不过要复杂点。用vbs比较麻烦,建议写个dll,调用起来方便。 |
|