文档详情

检测屏幕分辨率和颜色(Detect screen resolution and color).doc

发布:2017-07-31约5.89千字共10页下载文档
文本预览下载声明
检测屏幕分辨率和颜色(Detect screen resolution and color) Category: VC++ Recommendation: * * * Document popularity: 352 This weeks popularity: 3 Release date: 2007-5-8 Nanjing Naval Command Academy Huang Xiangming Windows API (GetDeviceCaps) - function can provide background information about equipment widely, including screen resolution and color depth. GUI program design allows the graphic elements as abstract objects, regardless of hardware device settings and user selection. This is for the majority of cases, such as window screen and a typical device independent bitmap operation can meet. But in some special cases will be limited, programmers need other methods to obtain the relevant information of the actual situation of equipment. This paper introduces an application for screen resolution and color depth. (GetDeviceCaps) -- a function (GetDeviceCaps) - API function can be used to obtain a lot of information equipment, it will become the gateway application and device driver. The following is the prototype of it in wingdi.h int GetDeviceCaps (HDC: HDC, int, nIndex); - the first parameter is related to detection equipment background, the second parameter represents the detection value. The specific function is described in detail in the Win32SDK file, this paper focuses on the two characteristics of the equipment associated with the display resolution (horizontal and vertical) and can display different color number. These values can be respectively by HORZRES, VERTRES and BITSPIXEL (GetDeviceCaps) to return to the second parameters. BITSPIXEL returns the description of a pixel color need to determine the actual number of color figures, as long as calculated by 2 as the return value of the exponent. The following C code is given, the detection screen resolution and color depth: DC initialization screen HDC screenDC; Int colorBits, xRes, yRes; ScreenDC = CreateDC (DISPLAY, NULL, NULL, NULL); Retrieval equipment ColorBits = GetDeviceCaps (screenDC, BITSPIXEL); XRes = GetDevi
显示全部
相似文档