Detect Windows Display Scale Factor 윈도우 배율 확인
C, C++ 2025. 12. 22. 02:26 |반응형
윈도우 디스플레이 배율을 확인 해 보자.
#include <windows.h>
#include <iostream>
void getDisplayScaleDpi(HWND hwnd) {
/*if (hwnd == NULL)
hwnd = GetDesktopWindow();
UINT dpi = GetDpiForWindow(hwnd);*/
// Get the DPI for the system.
UINT dpi = GetDpiForSystem();
// Calculate scale factor: 96 DPI = 100% scale
double scaleFactor = (double)dpi / 96.0;
double scalePercent = scaleFactor * 100.0;
std::cout << "DPI: " << dpi << std::endl;
std::cout << "Scale Factor: " << scaleFactor << std::endl;
std::cout << "Scale Percent: " << scalePercent << "%" << std::endl;
}
int main() {
// Ensure the application is DPI aware.
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
//SetProcessDPIAware(); // same as above
getDisplayScaleDpi(NULL);
return 0;
}

반응형
'C, C++' 카테고리의 다른 글
| 명령창(cmd)을 열지 않고 명령 실행하고 결과 받아오기 popen(pipe open), pclose(pipe close) (0) | 2025.04.14 |
|---|---|
| Qt platform plugin error fix (0) | 2021.09.26 |
| Qt6 설치 및 간단한 사용법 (0) | 2021.09.25 |
| MariaDB(MySQL) C API (0) | 2021.08.29 |
| SQLite - C/C++ (0) | 2021.08.27 |
