代码:
#include "windows.h"
#include <QDebug>
int main(int argc, char *argv[])
{
char *sLinkName = QString("远程桌面连接").toLocal8Bit().data();
WCHAR wstr[MAX_PATH]={0};
MultiByteToWideChar(CP_ACP, 0, sLinkName, -1, wstr, sizeof(wstr));
HWND d=FindWindow(NULL, wstr);
if(d==NULL)
{
qDebug()<<"NULL";
}
else
{
qDebug()<<d;
RECT rect;
WINBOOL ok=GetWindowRect(d, &rect);
if(ok)
{
qDebug()<<rect.left<<","<<rect.right<<","<<rect.top<<","<<rect.bottom;
}
}
return 0;
}
运行效果: