15,471
社区成员
发帖
与我相关
我的任务
分享
void Run()
{
HWND hWndQQ = NULL;
HWINSTA hstaSave;
LPCWSTR lpStation = L"WinSta0";
LPCWSTR lpDesk = L"default";
HWINSTA hstaUser;
HDESK hdeskSave;
HDESK hdeskUser;
hstaSave = GetProcessWindowStation();
hstaUser = OpenWindowStation(lpStation, 0, WINSTA_ALL_ACCESS);
SetProcessWindowStation(hstaUser);
hdeskSave = GetThreadDesktop(GetCurrentThreadId());
hdeskUser = OpenDesktop(lpDesk, 0, FALSE, DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL | DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD | DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_WRITEOBJECTS);
if (hdeskUser == NULL)
{
OutputDebugStringA("@xiaohuihui:Open desktop Failed!");
}
if (SetThreadDesktop(hdeskUser) == NULL)
{
OutputDebugStringA("@xiaohuihui:SetThreadDesktop Failed!");
}
////////////////////////这里添加与窗口交互的代码///////////////////////////
hWndQQ = FindWindow(NULL, L"DiscernPicture");
if (hWndQQ != NULL)
{
OutputDebugStringA("@xiaohuihui:Find Window Success!");
}
else
{
OutputDebugStringA("@xiaohuihui:Find Window Falied!");
}
SetThreadDesktop(hdeskSave);
SetProcessWindowStation(hstaSave);
CloseDesktop(hdeskUser);
CloseWindowStation(hstaUser);
}