显示屏幕的分辨率

 1 #define _CRT_SECURE_NO_WARNINGS
 2 #include <Windows.h>
 3 #include <tchar.h>
 4 #include <stdio.h>
 5 
 6 int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat, ...)
 7 {
 8     TCHAR szBuffer[1024];
 9     va_list pArgList;
10     //这是一个指针,指向szFormat后面的位置
11     va_start(pArgList, szFormat);
12 
13     _vsntprintf(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), szFormat, pArgList);
14 
15     va_end(pArgList);
16 
17     return MessageBox(NULL, szBuffer, szCaption, 0);
18 
19 }
20 
21 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
22 {
23     int cxScreen, cyScreen;
24 
25     cxScreen = GetSystemMetrics(SM_CXSCREEN);
26     cyScreen = GetSystemMetrics(SM_CYSCREEN);
27 
28     MessageBoxPrintf(TEXT("ScrnSize"), TEXT("The screen is %i pixels wide by %i pixels high."), cxScreen, cyScreen);
29 
30     return 0;
31 }

猜你喜欢

转载自www.cnblogs.com/xiyu714/p/9252287.html