请教win10中设置系统DPI的API

licunxijyy 2018-11-09 04:30:43
win10设置系统的DPI不用重启即可生效,请问有相关设置API的资料吗?
以往我们都是想方设法读取系统的DPI,现在我想反过来去设置系统的DPI到一个想要的值。
不用改注册表的方式,谢谢。
...全文
381 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eleven 2020-01-13
  • 打赏
  • 举报
回复
SetDisplayConfig
Sabs 2020-01-10
  • 打赏
  • 举报
回复
没有EnumDisplaySettngs,只有EnumDisplaySettingA和EnumDisplaySettingsW两个函数。
schlafenhamster 2020-01-10
  • 打赏
  • 举报
回复
EnumDisplaySettings
The 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 to receive settings
);

schlafenhamster 2020-01-10
  • 打赏
  • 举报
回复

// Codes are shown here for reading ! not tested !
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.
switch (ChangeDisplaySettings(&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("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("Invalid 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, 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;
TOKEN_PRIVILEGES tkp;
// We want to adjust our process's privileges.
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken);
// Get the LUID for shutdown privilege
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &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 for our process
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
CloseHandle(hToken);
// Shut down and reboot the system.
ExitWindowsEx(EWX_REBOOT, 0);
}
}
schlafenhamster 2020-01-10
  • 打赏
  • 举报
回复
搜索
Module name: DispRes.cpp
Written by: Jeffrey Richter
Notices: Written 1995 by Jeffrey Richter
zgl7903 2018-11-09
  • 打赏
  • 举报
回复
试试 EnumDisplaySettings ChangeDisplaySettings
DEVMODE 中 有这样的描述
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.
实际的我也没有试过, 你可以测试下看看





15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧