RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, SPIF_SENDCHANGE);
int client_width = (rect.right - rect.left);
int client_height = (rect.bottom - rect.top);
方法三:GetSystemMetrics
// 带标题栏和菜单栏
int have_menu_bar_width = GetSystemMetrics(SM_CXSCREEN);
int have_menu_bar_height = GetSystemMetrics(SM_CYSCREEN);
// 不带菜单栏的大小
int no_menu_bar_width = GetSystemMetrics(SM_CXFULLSCREEN);
int no_menu_bar__height = GetSystemMetrics(SM_CYFULLSCREEN);
方法四:GetDeviceCaps
HDC hdc = ::GetDC(NULL);
int client_width = GetDeviceCaps(hdc, DESKTOPHORZRES);
int client_height = GetDeviceCaps(hdc, DESKTOPVERTRES);
::ReleaseDC(NULL, hdc);
方法五:GetWindowRect
HWND hd = ::GetDesktopWindow();
RECT rect;
::GetWindowRect(hd, &rect);
int window_width = (rect.right - rect.left);
int window_height = (rect.bottom - rect.top);