EnumDisplayDevices
4 отговора
160 прегледа
EnumDisplayDevices
Как с Win API да изброя дисплейните адаптери? Ако решението вклю4ва и код ще съм много благодарен.
Re: EnumDisplayDevices
Копирано от MSDN:
--------------------------------
EnumDisplayDevices
The EnumDisplayDevices function lets you obtain information about the display devices in a system.
BOOL EnumDisplayDevices(
PVOID Unused, // not used; must be NULL
DWORD iDevNum, // specifies display device
PDISPLAY_DEVICE lpDisplayDevice, // pointer to structure to
// receive display device information
DWORD dwFlags // flags to condition function behavior
);
Parameters
Unused
This parameter is currently not used. Set it to NULL.
iDevNum
Index value that specifies the display device of interest.
The operating system identifies each display device with an index value. The index values are consecutive integers, starting at 0. If a system has three display devices, for example, they are specified by the index values 0, 1, and 2.
lpDisplayDevice
Pointer to a DISPLAY_DEVICE structure that receives information about the display device specified by iDevNum.
Before calling EnumDisplayDevices, you must initialize the cb member of DISPLAY_DEVICE to the size, in bytes, of DISPLAY_DEVICE.
dwFlags
A set of flags that condition the behavior of the function.
There are no flags currently defined.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. The function fails if iDevNum is greater than the largest device index.
Remarks
In order to query all display devices in the system, call this function in a loop, starting with iDevNum set to 0, and incrementing iDevNum until the function fails.
Code Examples
To paint in response to a WM_PAINT message, using the capabilities of each monitor, you can use code like the following in a window procedure:
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
EnumDisplayMonitors(hdc, NULL, MyPaintEnumProc, 0);
EndPaint(hwnd, &ps);
To paint the upper half of a window using the capabilities of each monitor, you can use code like the following:
GetClientRect(hwnd, &rc);
rc.bottom = (rc.bottom - rc.top) / 2;
hdc = GetDC(hwnd);
EnumDisplayMonitors(hdc, &rc, MyPaintEnumProc, 0);
ReleaseDC(hwnd, hdc);
To paint the entire screen optimally for each display monitor, you can use code like the following:
hdc = GetDC(NULL);
EnumDisplayMonitors(hdc, NULL, MyPaintScreenEnumProc, 0);
ReleaseDC(NULL, hdc);
To get information about all the display monitors, you can use code like the following:
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc,0)
QuickInfo
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
---------------------------------
DISPLAY_DEVICE
The DISPLAY_DEVICE structure receives information about the display device specified by the iDevNum parameter of the EnumDisplayDevices function.
typedef struct _DISPLAY_DEVICE {
DWORD cb;
WCHAR DeviceName[32];
WCHAR DeviceString[128];
DWORD StateFlags;
} DISPLAY_DEVICE, *PDISPLAY_DEVICE, *LPDISPLAY_DEVICE;
Members
cb
Size, in bytes, of the DISPLAY_DEVICE structure. This must be initialized prior to calling EnumDisplayDevices.
DeviceName
An array of characters identifying the device name.
DeviceString
An array of characters containing the device context string.
StateFlags
Device state flags. Reserved for future use.
QuickInfo
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in wingdi.h.
Unicode: Defined as Unicode and ANSI structures.
--------------------------------
EnumDisplayDevices
The EnumDisplayDevices function lets you obtain information about the display devices in a system.
BOOL EnumDisplayDevices(
PVOID Unused, // not used; must be NULL
DWORD iDevNum, // specifies display device
PDISPLAY_DEVICE lpDisplayDevice, // pointer to structure to
// receive display device information
DWORD dwFlags // flags to condition function behavior
);
Parameters
Unused
This parameter is currently not used. Set it to NULL.
iDevNum
Index value that specifies the display device of interest.
The operating system identifies each display device with an index value. The index values are consecutive integers, starting at 0. If a system has three display devices, for example, they are specified by the index values 0, 1, and 2.
lpDisplayDevice
Pointer to a DISPLAY_DEVICE structure that receives information about the display device specified by iDevNum.
Before calling EnumDisplayDevices, you must initialize the cb member of DISPLAY_DEVICE to the size, in bytes, of DISPLAY_DEVICE.
dwFlags
A set of flags that condition the behavior of the function.
There are no flags currently defined.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. The function fails if iDevNum is greater than the largest device index.
Remarks
In order to query all display devices in the system, call this function in a loop, starting with iDevNum set to 0, and incrementing iDevNum until the function fails.
Code Examples
To paint in response to a WM_PAINT message, using the capabilities of each monitor, you can use code like the following in a window procedure:
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
EnumDisplayMonitors(hdc, NULL, MyPaintEnumProc, 0);
EndPaint(hwnd, &ps);
To paint the upper half of a window using the capabilities of each monitor, you can use code like the following:
GetClientRect(hwnd, &rc);
rc.bottom = (rc.bottom - rc.top) / 2;
hdc = GetDC(hwnd);
EnumDisplayMonitors(hdc, &rc, MyPaintEnumProc, 0);
ReleaseDC(hwnd, hdc);
To paint the entire screen optimally for each display monitor, you can use code like the following:
hdc = GetDC(NULL);
EnumDisplayMonitors(hdc, NULL, MyPaintScreenEnumProc, 0);
ReleaseDC(NULL, hdc);
To get information about all the display monitors, you can use code like the following:
EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc,0)
QuickInfo
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
---------------------------------
DISPLAY_DEVICE
The DISPLAY_DEVICE structure receives information about the display device specified by the iDevNum parameter of the EnumDisplayDevices function.
typedef struct _DISPLAY_DEVICE {
DWORD cb;
WCHAR DeviceName[32];
WCHAR DeviceString[128];
DWORD StateFlags;
} DISPLAY_DEVICE, *PDISPLAY_DEVICE, *LPDISPLAY_DEVICE;
Members
cb
Size, in bytes, of the DISPLAY_DEVICE structure. This must be initialized prior to calling EnumDisplayDevices.
DeviceName
An array of characters identifying the device name.
DeviceString
An array of characters containing the device context string.
StateFlags
Device state flags. Reserved for future use.
QuickInfo
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in wingdi.h.
Unicode: Defined as Unicode and ANSI structures.
Редактирано от Пaлячo на
Re: EnumDisplayDevices
#include <windows.h>
typedef BOOL ( WINAPI *displprc)( LPCTSTR, DWORD, PDISPLAY_DEVICE, DWORD );
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
DISPLAY_DEVICE DSP;
DWORD i = 0;
displprc dis;
UNREFERENCED_PARAMETER( hInstance );
UNREFERENCED_PARAMETER( hPrevInstance );
UNREFERENCED_PARAMETER( lpCmdLine );
UNREFERENCED_PARAMETER( nCmdShow );
#ifdef UNICODE
dis = (displprc)GetProcAddress( GetModuleHandle( TEXT( "User32.dll" ) ), "EnumDisplayDevicesW" );
#else
dis = (displprc)GetProcAddress( GetModuleHandle( TEXT( "User32.dll" ) ), "EnumDisplayDevicesA" );
#endif
memset( &DSP, 0, sizeof( DSP ) );
DSP.cb = sizeof( DSP );
while( (*dis)( NULL, i, &DSP, 0UL ) )
{
MessageBox( NULL, (LPCTSTR)DSP.DeviceString, NULL, MB_OK );
i++;
}
return 0;
}
Re: EnumDisplayDevices
Благодаря за кода, но същото може да се направи и без толкова фокуси.
Работата е там , че при изброяванети излиза и NetMeeting а може да наизлязат и други такива които със сигурност неса никакви видео-карти. Ако дадеш решение което работи коректно ще съм благодарен.
Работата е там , че при изброяванети излиза и NetMeeting а може да наизлязат и други такива които със сигурност неса никакви видео-карти. Ако дадеш решение което работи коректно ще съм благодарен.
Re: EnumDisplayDevices
wbemdump /Q root\cimv2 WQL "SELECT * FROM Win32_DisplayConfiguration"