일반 C (C++/C#/Objective-C 아님)를 사용하면 Windows에서 화면 해상도를 어떻게 얻을 수 있습니까?Windows C에서 화면 해상도 가져 오기
제 컴파일러는 MingW입니다 (관련이 있는지 확실하지 않음). 온라인에서 찾은 모든 솔루션은 C++ 또는 다른 C 변형입니다.
일반 C (C++/C#/Objective-C 아님)를 사용하면 Windows에서 화면 해상도를 어떻게 얻을 수 있습니까?Windows C에서 화면 해상도 가져 오기
제 컴파일러는 MingW입니다 (관련이 있는지 확실하지 않음). 온라인에서 찾은 모든 솔루션은 C++ 또는 다른 C 변형입니다.
DWORD dwWidth = GetSystemMetrics(SM_CXSCREEN);
DWORD dwHeight = GetSystemMetrics(SM_CYSCREEN);
은 귀하의 질문은 이미 답했습니다 How to get the Monitor Screen Resolution from a hWnd?.
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO info;
info.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(monitor, &info);
int monitor_width = info.rcMonitor.right - info.rcMonitor.left;
int monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
당신은 당신의 코드에서 windows.h
를 포함하여 Windows API를 사용해야합니다. MingW에는 이미이 헤더 파일이있을 수 있습니다.
#include <windows.h>
void GetMonitorResolution(int *horizontal, int *vertical) {
*height = GetSystemMetrics(SM_CYSCREEN);
*width = GetSystemMetrics(SM_CXSCREEN);
}
작업, 따 '아주 많이. – Jimmay