#include"stdio.h"
#include"stdlib.h"
#include"windows.h"
int main()
{
SetConsoleTitle("11");
POINT *ptrpos;
RECT* rect;
HWND hwnd=FindWindow(NULL,"11");
ptrpos=(POINT*)malloc(sizeof(POINT));
rect=(RECT*)malloc(sizeof(RECT*));
while(1)
{
Sleep(500);
printf("%d\n",GetWindowRect(hwnd,rect));
GetCursorPos(ptrpos);
printf("Rrect->left=%lld rect->top=%lld %d %d\n",rect->left,rect->top,ptrpos->x,ptrpos->y);
}
}
在运行以上代码时,rect->left总不在预期中,经查资料发现,GetWindowRect函数调用失败返回0,该程序确实返回了0,就大佬帮忙下,为什么会失败?