#include #include int main (void) { HDC hdc = GetDC (0); if (hdc) { int ht = GetDeviceCaps (hdc, VERTRES); int wd = GetDeviceCaps (hdc, HORZRES); std::cerr << wd << "x" << ht << " pixels" << std::endl; double ht_mm = GetDeviceCaps (hdc, VERTSIZE); double wd_mm = GetDeviceCaps (hdc, HORZSIZE); std::cerr << wd_mm << "x" << ht_mm << " mm" << std::endl; double resy = wd * 25.4 / wd_mm; double resx = ht * 25.4 / ht_mm; double resy_log = GetDeviceCaps (hdc, LOGPIXELSY); double resx_log = GetDeviceCaps (hdc, LOGPIXELSX); std::cerr << resx << " resx" << std::endl; std::cerr << resy << " resy" << std::endl; std::cerr << resx_log << " resx_log" << std::endl; std::cerr << resy_log << " resy_log" << std::endl; std::cerr << (resx + resy) / 2 << " avg dpi" << std::endl; int depth = GetDeviceCaps (hdc, BITSPIXEL); std::cerr << depth << " bit depth" << std::endl; ReleaseDC(0, hdc); } else std::cerr << "failed to get device context" << std::endl; return 0; }