本文整理匯總了C++中EnumDisplayDevices函數的典型用法代碼示例。如果您正苦於以下問題:C++ EnumDisplayDevices函數的具體用法?C++ EnumDisplayDevices怎麽用?C++ EnumDisplayDevices使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EnumDisplayDevices函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: get_screen_info
int get_screen_info(int id, _TCHAR* name, int* width, int* height, int* bpp)
{
DISPLAY_DEVICE dd;
memset(&dd, 0, sizeof(DISPLAY_DEVICE));
dd.cb = sizeof(DISPLAY_DEVICE);
if (EnumDisplayDevices(NULL, id, &dd, 0) != 0)
{
HDC dc;
if (name != NULL)
_stprintf(name, _T("%s (%s)"), dd.DeviceName, dd.DeviceString);
dc = CreateDC(dd.DeviceName, NULL, NULL, NULL);
*width = GetDeviceCaps(dc, HORZRES);
*height = GetDeviceCaps(dc, VERTRES);
*bpp = GetDeviceCaps(dc, BITSPIXEL);
//ReleaseDC(NULL, dc);
DeleteDC(dc);
}
else
{
return 0;
}
return 1;
}
示例2: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
int deviceIndex=0;
int result;
DWORD bpp=16;
do
{
PDISPLAY_DEVICE displayDevice = new DISPLAY_DEVICE();
displayDevice->cb = sizeof(DISPLAY_DEVICE);
result = EnumDisplayDevices(NULL,
deviceIndex++, displayDevice, 0);
if (displayDevice->StateFlags & DISPLAY_DEVICE_ACTIVE)
{
PDISPLAY_DEVICE monitor = new DISPLAY_DEVICE();
monitor->cb = sizeof(DISPLAY_DEVICE);
EnumDisplayDevices(displayDevice->DeviceName,
0, monitor, 0);
PDEVMODE dm = new DEVMODE();
if ( EnumDisplaySettings(displayDevice->DeviceName,
ENUM_CURRENT_SETTINGS, dm) )
{
dm->dmBitsPerPel=(DWORD)bpp;
ChangeDisplaySettingsEx(displayDevice->DeviceName, dm, \
NULL, (CDS_GLOBAL | CDS_UPDATEREGISTRY | CDS_RESET), NULL);
}
}
} while (result);
return 0;
}
示例3: GetDisplayCoordinates
/*
========================
GetDisplayCoordinates
========================
*/
static bool GetDisplayCoordinates( const int deviceNum, int & x, int & y, int & width, int & height, int & displayHz ) {
idStr deviceName = GetDeviceName( deviceNum );
if ( deviceName.Length() == 0 ) {
return false;
}
DISPLAY_DEVICE device = {};
device.cb = sizeof( device );
if ( !EnumDisplayDevices(
0, // lpDevice
deviceNum,
&device,
0 /* dwFlags */ ) ) {
return false;
}
DISPLAY_DEVICE monitor;
monitor.cb = sizeof( monitor );
if ( !EnumDisplayDevices(
deviceName.c_str(),
0,
&monitor,
0 /* dwFlags */ ) ) {
return false;
}
DEVMODE devmode;
devmode.dmSize = sizeof( devmode );
if ( !EnumDisplaySettings( deviceName.c_str(),ENUM_CURRENT_SETTINGS, &devmode ) ) {
return false;
}
common->Printf( "display device: %i\n", deviceNum );
common->Printf( " DeviceName : %s\n", device.DeviceName );
common->Printf( " DeviceString: %s\n", device.DeviceString );
common->Printf( " StateFlags : 0x%x\n", device.StateFlags );
common->Printf( " DeviceID : %s\n", device.DeviceID );
common->Printf( " DeviceKey : %s\n", device.DeviceKey );
common->Printf( " DeviceName : %s\n", monitor.DeviceName );
common->Printf( " DeviceString: %s\n", monitor.DeviceString );
common->Printf( " StateFlags : 0x%x\n", monitor.StateFlags );
common->Printf( " DeviceID : %s\n", monitor.DeviceID );
common->Printf( " DeviceKey : %s\n", monitor.DeviceKey );
common->Printf( " dmPosition.x : %i\n", devmode.dmPosition.x );
common->Printf( " dmPosition.y : %i\n", devmode.dmPosition.y );
common->Printf( " dmBitsPerPel : %i\n", devmode.dmBitsPerPel );
common->Printf( " dmPelsWidth : %i\n", devmode.dmPelsWidth );
common->Printf( " dmPelsHeight : %i\n", devmode.dmPelsHeight );
common->Printf( " dmDisplayFlags : 0x%x\n", devmode.dmDisplayFlags );
common->Printf( " dmDisplayFrequency: %i\n", devmode.dmDisplayFrequency );
x = devmode.dmPosition.x;
y = devmode.dmPosition.y;
width = devmode.dmPelsWidth;
height = devmode.dmPelsHeight;
displayHz = devmode.dmDisplayFrequency;
return true;
}
示例4: MonitorFromWindow
BOOL CMonitorManager::GetMonitorResolution(HWND hWnd, long *lResoluteW, long *lResoluteH)
{
HMONITOR hm = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
BOOL bFindMonitor = FALSE;
for(int i = 0; i < m_MonitorList.size(); i++)
{
if (hm == m_MonitorList[i].hMonitor)
{
bFindMonitor = TRUE;
break;
}
}
if (!bFindMonitor) return FALSE;
DISPLAY_DEVICE dd;
ZeroMemory(&dd, sizeof(DISPLAY_DEVICE));
dd.cb = sizeof(DISPLAY_DEVICE);
bFindMonitor = EnumDisplayDevices(NULL, i, &dd, 0);
if (!bFindMonitor) return FALSE;
DEVMODE dm;
ZeroMemory(&dm, sizeof(DEVMODE));
dm.dmSize = sizeof(dm);
bFindMonitor = EnumDisplaySettings((char*)dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm);
if (!bFindMonitor) return FALSE;
*lResoluteW = dm.dmPelsWidth;
*lResoluteH = dm.dmPelsHeight;
return TRUE;
}
示例5: GetWindowsMonitorSize
bool GetWindowsMonitorSize( int *width, int *height)
{
int WidthMm = 0;
int HeightMm = 0;
DISPLAY_DEVICE dd;
dd.cb = sizeof(dd);
DWORD dev = 0; // device index
int id = 1; // monitor number, as used by Display Properties > Settings
wxString DeviceID;
bool bFoundDevice = false;
while (EnumDisplayDevices(0, dev, &dd, 0) && !bFoundDevice)
{
DISPLAY_DEVICE ddMon;
ZeroMemory(&ddMon, sizeof(ddMon));
ddMon.cb = sizeof(ddMon);
DWORD devMon = 0;
while (EnumDisplayDevices(dd.DeviceName, devMon, &ddMon, 0) && !bFoundDevice)
{
if (ddMon.StateFlags & DISPLAY_DEVICE_ACTIVE &&
!(ddMon.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
{
DeviceID = wxString(ddMon.DeviceID, wxConvUTF8);
DeviceID = DeviceID.Mid (8);
DeviceID = DeviceID.Mid (0, DeviceID.Find ( '\\' ));
bFoundDevice = GetSizeForDevID(DeviceID, &WidthMm, &HeightMm);
}
devMon++;
ZeroMemory(&ddMon, sizeof(ddMon));
ddMon.cb = sizeof(ddMon);
}
ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd);
dev++;
}
if(width)
*width = WidthMm;
if(height)
*height = HeightMm;
return bFoundDevice;
}
示例6: VeStrcpy
//--------------------------------------------------------------------------
VE_BOOL VeWindows::AddDisplay(LPSTR DeviceName)
{
VeDevice::VideoDisplay kDisplay;
DisplayData* pkDisplayData;
VeDevice::DisplayMode kMode;
DISPLAY_DEVICE kDevice;
if(!GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &kMode))
{
return VE_FALSE;
}
pkDisplayData = VE_NEW DisplayData;
if(!pkDisplayData)
{
return VE_FALSE;
}
VeStrcpy(pkDisplayData->m_acDeviceName, DeviceName);
kDevice.cb = sizeof(kDevice);
if (EnumDisplayDevices(DeviceName, 0, &kDevice, 0))
{
kDisplay.m_kName = kDevice.DeviceString;
}
kDisplay.m_kDesktopMode = kMode;
kDisplay.m_kCurrentMode = kMode;
kDisplay.m_spDriverData = pkDisplayData;
m_kDisplays.PushBack(kDisplay);
return VE_TRUE;
}
示例7: Rotate
static BOOL Rotate( int iDevNum, SHORT dmOrientation )
{
DISPLAY_DEVICE d;
DEVMODE dm;
int w;
LONG r;
ZeroMemory( &d, sizeof( d ) );
d.cb = sizeof( d );
if( !EnumDisplayDevices( NULL, iDevNum, &d, 0 ) ) {
DebugMsg( _T("EnumDisplayDevices failed:%d\r\n" ), GetLastError() );
return FALSE;
}
if( !EnumDisplaySettings( d.DeviceName, ENUM_CURRENT_SETTINGS, &dm ) ){
DebugMsg( _T("EnumDisplaySettings(\"%s\") failed:%d\r\n" ), d.DeviceName, GetLastError() );
return FALSE;
}
if( dm.dmDisplayOrientation == dmOrientation ) return TRUE;
w = dm.dmPelsHeight;
dm.dmPelsHeight = dm.dmPelsWidth;
dm.dmPelsWidth = w;
dm.dmDisplayOrientation = dmOrientation;
r = ChangeDisplaySettingsEx( d.DeviceName, &dm, NULL, CDS_UPDATEREGISTRY, NULL );
if( r != DISP_CHANGE_SUCCESSFUL ){
DebugMsg( _T("ChangeDisplaySettingsEx failed:%d\r\n"), r );
return FALSE;
}
return TRUE;
}
示例8: sizeof
bool output_device_enumerator_win32::enumerate_device(gl::output_device_descriptor& desc, const std::string& name)
{
_issues.push_back(std::string("output_device_enumerator_win32::enumerate_device(): {"));
DISPLAY_DEVICE disp_device;
disp_device.cb = sizeof(DISPLAY_DEVICE);
unsigned dev_index = 0;
bool found_dev = false;
while (!found_dev && EnumDisplayDevices(NULL, dev_index, &disp_device, 0)) {
if (name == std::string(disp_device.DeviceName)) {
found_dev = true;
}
else {
dev_index++;
}
}
if (found_dev) {
return (this->enumerate_device(desc, dev_index));
}
else {
_issues.push_back(std::string("\tError: unable to find device: ") + name);
return (false);
}
}
示例9: win_shadow_enum_monitors
int win_shadow_enum_monitors(MONITOR_DEF* monitors, int maxMonitors)
{
HDC hdc;
int index;
int desktopWidth;
int desktopHeight;
DWORD iDevNum = 0;
int numMonitors = 0;
MONITOR_DEF* monitor;
DISPLAY_DEVICE displayDevice;
ZeroMemory(&displayDevice, sizeof(DISPLAY_DEVICE));
displayDevice.cb = sizeof(DISPLAY_DEVICE);
if (EnumDisplayDevices(NULL, iDevNum, &displayDevice, 0))
{
hdc = CreateDC(displayDevice.DeviceName, NULL, NULL, NULL);
desktopWidth = GetDeviceCaps(hdc, HORZRES);
desktopHeight = GetDeviceCaps(hdc, VERTRES);
index = 0;
numMonitors = 1;
monitor = &monitors[index];
monitor->left = 0;
monitor->top = 0;
monitor->right = desktopWidth;
monitor->bottom = desktopHeight;
monitor->flags = 1;
DeleteDC(hdc);
}
return numMonitors;
}
示例10: sizeof
HRESULT CSystemInfo::GetDisplayInfo(CString& strDisplay)
{
DISPLAY_DEVICE displayInfo;
DWORD dwIndex = 0;
displayInfo.cb = sizeof(DISPLAY_DEVICE);
displayInfo.StateFlags = 0;
while (EnumDisplayDevices(NULL, dwIndex, &displayInfo, NULL))
{
dwIndex++;
if (0 == _tcslen(displayInfo.DeviceID))
{
continue;
}
if (strDisplay.GetLength() > 0)
{
strDisplay.Append("&");
}
strDisplay.Append(displayInfo.DeviceString);
}
return S_OK;
}
示例11: memset
BOOL CMirageManager::LookupDisplayDevices(DISPLAY_DEVICE& deviceInfo, DWORD& deviceNumber, bool bShouldLog)
{
memset(&deviceInfo, 0, sizeof(deviceInfo));
deviceInfo.cb = sizeof(deviceInfo);
deviceNumber = 0;
BOOL result = FALSE;
std::wstring dataStream(_T(""));
while (result = EnumDisplayDevices(NULL, deviceNumber, &deviceInfo, 0))
{
if (bShouldLog)
{
dataStream.append(_T("Detected Device :: "));
dataStream.append(deviceInfo.DeviceName);
dataStream.append(_T(" - "));
dataStream.append(deviceInfo.DeviceString);
CMirageManager::WriteDiagnostics(dataStream);
dataStream.clear();
}
if (wcscmp(deviceInfo.DeviceString, DRIVER_NAME) == 0)
{
result = TRUE;
break;
}
++deviceNumber;
}
return result;
}
示例12: _glfwPlatformSetGammaRamp
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{
HDC dc;
WORD values[768];
DISPLAY_DEVICE display;
if (ramp->size != 256)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Gamma ramp size must be 256");
return;
}
memcpy(values + 0, ramp->red, 256 * sizeof(unsigned short));
memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short));
memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short));
ZeroMemory(&display, sizeof(DISPLAY_DEVICE));
display.cb = sizeof(DISPLAY_DEVICE);
EnumDisplayDevices(monitor->win32.name, 0, &display, 0);
dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL);
SetDeviceGammaRamp(dc, values);
DeleteDC(dc);
}
示例13: memset
//************************************
// 函數名稱: GetMonitorDisplayDevice
// 返回類型: DISPLAY_DEVICE&
// 參數信息: DWORD _MonitorIndex
// 函數說明:
//************************************
DISPLAY_DEVICE& DuiMonitor::GetMonitorDisplayDevice( DWORD _MonitorIndex /*= 1*/ )
{
static DISPLAY_DEVICE mDisplayDevice;
memset(&mDisplayDevice,0, sizeof(mDisplayDevice));
if(_MonitorIndex <= 0 || _MonitorIndex > GetMonitorCount())
return mDisplayDevice;
DEVMODE mDevMode;
memset(&mDevMode,0, sizeof(mDevMode));
DWORD mCheckCount = 0,mMonitorCount = 0;
while(mMonitorCount != _MonitorIndex)
{
mDisplayDevice.cb = sizeof(DISPLAY_DEVICE);
if(EnumDisplayDevices(NULL, mCheckCount, &mDisplayDevice,0) == FALSE)
break;
if(EnumDisplaySettings(mDisplayDevice.DeviceName,ENUM_CURRENT_SETTINGS,&mDevMode))
mMonitorCount++;
mCheckCount++;
}
return mDisplayDevice;
}
示例14: DetectVirtualMonitor
BOOL DetectVirtualMonitor(BOOL log)
{
INT devNum = 0;
DISPLAY_DEVICE displayDevice;
BOOL result;
BOOL bFound = FALSE;
FillMemory(&displayDevice, sizeof(DISPLAY_DEVICE), 0);
displayDevice.cb = sizeof(DISPLAY_DEVICE);
// First enumerate for Primary display device:
while ((result = EnumDisplayDevices(NULL, devNum, &displayDevice, 0))) {
if (log) {
logInfo("%s, %s %s \n",
&displayDevice.DeviceString[0],
&displayDevice.DeviceName[0],
&displayDevice.DeviceID[0]/*,
&displayDevice.DeviceKey[0]*/);
}
if (strcmp(&displayDevice.DeviceID[0], DRIVER_NAME) == 0) {
bFound = TRUE;
if (!log)
break;
}
devNum++;
}
return bFound;
}
示例15: WIN_AddDisplay
static SDL_bool
WIN_AddDisplay(_THIS, LPTSTR DeviceName)
{
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
DISPLAY_DEVICE device;
#ifdef DEBUG_MODES
printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
#endif
if (!WIN_GetDisplayMode(_this, DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
return SDL_FALSE;
}
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
if (!displaydata) {
return SDL_FALSE;
}
SDL_memcpy(displaydata->DeviceName, DeviceName,
sizeof(displaydata->DeviceName));
SDL_zero(display);
device.cb = sizeof(device);
if (EnumDisplayDevices(DeviceName, 0, &device, 0)) {
display.name = WIN_StringToUTF8(device.DeviceString);
}
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
SDL_free(display.name);
return SDL_TRUE;
}