'전체 글'에 해당되는 글 590건

  1. 2025.12.22 Detect Windows Display Scale Factor 윈도우 배율 확인
반응형

윈도우 디스플레이 배율을 확인 해 보자.

 

#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;
}

 

 

 

반응형
Posted by J-sean
: