寻找桌面图标
一般都是双击桌面的图标启动程序的比如:现在我想让程序自动寻找桌面的QQ图标的坐标,如何寻找 ??
#include <iostream> #include <Windows.h> using namespace std; int main() { HWND hDeskTopWnd = GetDesktopWindow(); // 获取桌面窗口句柄 HWND hFolderWnd = FindWindowEx(hDeskTopWnd, NULL, "Progman", "Program Manager"); // 获取"Progman"窗口句柄 // 发送消息打开"Program Manager"窗口的子窗口 SendMessage(hFolderWnd, 0x052C, NULL, NULL); SendMessage(hFolderWnd, 0x0110, NULL, NULL); SendMessage(hFolderWnd, 0x052C, NULL, NULL); // 获取"Program Manager"窗口下的所有子窗口 HWND hWorkerWnd = NULL; while ((hWorkerWnd = FindWindowEx(hDeskTopWnd, hWorkerWnd, "WorkerW", NULL)) != NULL) { HWND hShellWnd = FindWindowEx(hWorkerWnd, NULL, "SHELLDLL_DefView", NULL); // 获取SHELLDLL_DefView窗口句柄 if (hShellWnd != NULL) { HWND hShellViewWnd= FindWindowEx(hShellWnd, NULL, "SysListView32", "FolderView"); // 获取SysListView32窗口句柄 if (hShellViewWnd != NULL) { // 获取SysListView32窗口的坐标 RECT rect; GetWindowRect(hShellViewWnd, &rect); cout << "QQ icon's coordinates: (" << rect.left << ", " << rect.top << ")" << endl; break; } } } return 0; }