Cambiare la risoluzione di Windows in C++ richiamando una DLL
Jump to navigation
Jump to search
Si richiama la funzione ChangeDisplaySettings contenuta in user32.dll:
Vedi http://rvmserver:8000/changeres
#include <windows.h>
#include <wingdi.h>
#include <stdio.h>
int main () {
/*Typedef the hello function*/
//typedef int (*pfunc)();
/*Windows handle*/
//HINSTANCE hdll;
/*A pointer to a function*/
//pfunc hello;
/*LoadLibrary*/
//hdll = LoadLibrary("user32.dll");
//rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3
/*GetProcAddress*/
//hello = (pfunc)GetProcAddress(hdll, "ChangeDisplaySettings");
/*Call the function*/
//printf ("IS User admin ? %i", hello());
//http://msdn.microsoft.com/en-us/library/dd183411(VS.85).aspx
//rundll32.exe User32.dll,ChangeDisplaySettings 800 600
//RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
DEVMODE dm;
// initialize the DEVMODE structure
ZeroMemory(&dm, sizeof(dm));
dm.dmSize = sizeof(dm);
if (0 != EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm)) {
// swap height and width
DWORD dwTemp = dm.dmPelsHeight;
dm.dmPelsHeight= dm.dmPelsWidth;
dm.dmPelsWidth = dwTemp;
dm.dmPelsWidth = 1024;
dm.dmPelsHeight= 768;
}
long lRet = ChangeDisplaySettings(&dm, 0);
if (DISP_CHANGE_SUCCESSFUL != lRet) {
printf ("Change failed.\n");
}
return 0;
}