我想得到桌面的句柄,有一个API GetDesktopWindow(),但好像并不正确!function TForm1.GetDesktopHand: THandle;
begin
{Result:=FindWindow('progman',nil);
Result:=GetWindow(Result,GW_Child);
Result:=GetWindow(Result,GW_Child);} Result := GetDesktopWindow;
Result := FindWindowEx(Result, 0, 'Progman', nil);
Result := FindWindowEx(Result, 0, 'SHELLDLL_DefView', nil);
Result := FindWindowEx(Result, 0, 'SysListView32', nil);
end;请问'Progman' and 'SHELLDLL_DefView' and 'SysListView32' 是什么意思??
我是想用SendMessage(Hand, LVM_GETITEMPOSITION, 0, Longint(@ppt));来得到桌面ICO的位置!!请问如何得到正确的桌面句柄(Hand)???
begin
{Result:=FindWindow('progman',nil);
Result:=GetWindow(Result,GW_Child);
Result:=GetWindow(Result,GW_Child);} Result := GetDesktopWindow;
Result := FindWindowEx(Result, 0, 'Progman', nil);
Result := FindWindowEx(Result, 0, 'SHELLDLL_DefView', nil);
Result := FindWindowEx(Result, 0, 'SysListView32', nil);
end;请问'Progman' and 'SHELLDLL_DefView' and 'SysListView32' 是什么意思??
我是想用SendMessage(Hand, LVM_GETITEMPOSITION, 0, Longint(@ppt));来得到桌面ICO的位置!!请问如何得到正确的桌面句柄(Hand)???
解决方案 »
- 怎么在image上画一个黑色方块,把image白色变成黑色
- RemObjects 如何查询oracle中带long类型的表???(分不够再加)
- 如何自动刷新数据
- 简单问题,高分相送,有关于IE的!
- 如何把BMP转换成JPG??? TBitmap.Create --> TJPEGImage.Create
- opendatasource打开access错误c0000005 EXCEPTION_ACCESS_VIOLATION
- adoconnection连接Oracle问题
- 怎么把listbox导到word
- 计算文件大小的问题?????
- 用Tquery查询二个表放入dbgrid中,对其修改,如果查询语句里有in就不能修改,为何,如何修改???????
- 关于ADO组件的问题
- 网上邻居的图标被误删了,怎么恢复?
65546 -> GetDesktopWindow
393260 -> FindWindow('Progman', nil);
327722、393262分别是其下句柄,倒和Spy得到的结果一致;还有个GetDC(0),不知道有什么用,好象是屏幕可绘区域的句柄,帮你up
///////////////// for NT based //////////////////////* 取桌面 ListView 的句柄 */
HWND hDeskTop;
hDeskTop = FindWindow("progman", NULL);
hDeskTop = FindWindowEx(hDeskTop, 0, "shelldll_defview", NULL);
hDeskTop = FindWindowEx(hDeskTop, 0, "syslistview32", NULL);
/* 取 explorer.exe 句柄. 注意 OpenProcess 的参数 */
DWORD dwProcessId;
GetWindowThreadProcessId(hDeskTop, &dwProcessId);
HANDLE hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION, FALSE, dw
ProcessId);
/* 在 explorer.exe 空间内分配内存 */
PVOID pv = VirtualAllocEx(hProcess, NULL, sizeof(POINT), MEM_COMMIT, PAGE_READW
RITE);
/* 给桌面 ListView 窗口发一 LVM_GETITEMPOSITION 取 "我的电脑" 坐标 */
ListView_GetItemPosition(hDeskTop, 1, pv);
/* 把由 LVM_GETITEMPOSITION 获得的坐标数据复制到 pt 结构 */
POINT pt;
ReadProcessMemory(hProcess, pv, &pt, sizeof(POINT), NULL);
/* 释放内存, 句柄 */
VirtualFreeEx(hProcess, pv, 0, MEM_RELEASE);
CloseHandle(hProcess);这是VC的代码!!我不明白为什么用ListView_GetItemPosition(hDeskTop, 1, pv);这个函数为什么要做这么多工作,为什么呢??不理解?请大家家研究研究!!!!