We are trying to read system DPI before, now I want to return to set up the system of DPI to a want to the value of the
Change the registry way: no, thank you.
CodePudding user response:
Try EnumDisplaySettings ChangeDisplaySettingsThe DEVMODE such description
DmPrintQuality
Specifies the printer resolution. There are four predefined device - independent values:
DMRES_HIGH
DMRES_MEDIUM
DMRES_LOW
DMRES_DRAFT
If a positive value is given, it specifies the number of dots per inch (DPI) and is therefore device dependent.
Actually I haven't tried, you can test under see
CodePudding user response:
No EnumDisplaySettngs, only EnumDisplaySettingA and EnumDisplaySettingsW two functions,CodePudding user response:
SearchThe Module name: DispRes. CPP
Written by: Jeffrey Richter
Notices: 1995 Written by Jeffrey Richter
CodePudding user response:
//Codes are to here for reading! Not *!
Void CVcDispResDlg: : ChangeResolution ()
{
if(! M_bAllowToChange) return;
//
LPCTSTR PSZ;
UINT nMBBtn;
//Keep the current refresh rate
M_DevSelect. DmDisplayFrequency=GetDeviceCaps ((HDC) GetDC (), VREFRESH);
//Attempt to change the display resolution.
The switch (ChangeDisplaySettings (& amp; M_DevSelect CDS_UPDATEREGISTRY))
{
Case DISP_CHANGE_SUCCESSFUL:
PSZ=__TEXT (" Display change successful. ");
break;
Case DISP_CHANGE_RESTART:
PSZ=__TEXT (" You must restart your computer before the ")
__TEXT (" the new Settings will take effect. \ n \ n ")
__TEXT (" Do you want to restart your computer now?" );
NMBBtn=MB_YESNO;
break;
Case DISP_CHANGE_BADFLAGS:
PSZ=__TEXT (" An invalid set of flags was passed in. ");
break;
Case DISP_CHANGE_FAILED:
PSZ=__TEXT (" The display driver couldn 't change The display. ");
break;
Case DISP_CHANGE_BADMODE:
PSZ=__TEXT (" gave Settings ");
break;
Case DISP_CHANGE_NOTUPDATED:
PSZ=__TEXT (" Unable to write Settings to the registry. ");
break;
}
//Show the user the results
If (IDYES==AfxMessageBox (PSZ, nMBBtn | MB_ICONINFORMATION))
{//If the user wants to reboot the computer to do so.
//Windows NT: We must enable our shutdown privilege, assumming We have it.
//Windows 95: OpenProcessToken LookupPrivilegeValue, and
//AdjustTokenPrivileges are not implemented and
//are ignored.
HANDLE hToken;
The TOKEN_PRIVILEGES TKP;
//We want to adjust our process 's privileges.
OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES, & amp; HToken);
//Get the LUID for shutdown privilege
LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME, & amp; TKP. Privileges [0]. Luid);
TKP. PrivilegeCount=1;//one privilege to set
TKP. Privileges [0]. Attributes=SE_PRIVILEGE_ENABLED;
//Turn the SE_SHUTDOWN_NAME privilege on the for our process
AdjustTokenPrivileges (hToken, FALSE, & amp; TKP, 0, NULL, 0);
The CloseHandle (hToken);
//Shut down and reboot the system.
ExitWindowsEx (EWX_REBOOT, 0);
}
}
CodePudding user response:
EnumDisplaySettingsThe EnumDisplaySettings function obtains information about one of a display device 's graphics modes. You can obtain information for all of a display device' s graphics modes by making a series of calls to this function.
BOOL EnumDisplaySettings (
LPCTSTR lpszDeviceName,//specifies the display device
DWORD iModeNum,//specifies the graphics mode
LPDEVMODE LPDEVMODE//points to structure the to receive Settings
);
CodePudding user response:
SetDisplayConfig