Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo) { FARPROC EnumDisplayDevices; HINSTANCE hInstUser32; DISPLAY_DEVICE DispDev; char szSaveDeviceName[33]; // 32 + 1 for the null-terminator BOOL bRet = TRUE; HRESULT hr; hInstUser32 = LoadLibrary("c:\\windows\User32.DLL"); if (!hInstUser32) return FALSE; // Get the address of the EnumDisplayDevices function EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA"); if (!EnumDisplayDevices) { FreeLibrary(hInstUser32); return FALSE; } ZeroMemory(&DispDev, sizeof(DispDev)); DispDev.cb = sizeof(DispDev); // After the first call to EnumDisplayDevices, // DispDev.DeviceString is the adapter name if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0)) { hr = StringCchCopy(szSaveDeviceName, 33, DispDev.DeviceName); if (FAILED(hr)) { // TODO: write error handler } // After second call, DispDev.DeviceString is the // monitor name for that device EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0); // In the following, lpszMonitorInfo must be 128 + 1 for // the null-terminator. hr = StringCchCopy(lpszMonitorInfo, 129, DispDev.DeviceString); if (FAILED(hr)) { // TODO: write error handler } } else { bRet = FALSE; } FreeLibrary(hInstUser32); return bRet; } |
Werbeanzeige