LoginSignup
1
1

More than 5 years have passed since last update.

Windows10 で screen resolution を強制変更

Posted at

はじめに

Windows10 (Windows10 IoT Enterprise)だと、マルチディスプレイで画面を複製モード( = ミラーモード / Clone Mode)にすると、全部が低い解像度のディスプレイと同じ解像度になってしまいとっても迷惑。

なので、強制的に解像度を再設定するコマンドを書いた。デフォルトは1920×1080。

/*
    ForceSetScrResolution
    Usage: command [resolution-id]
    Note: dafault-resolution=1920x1080
*/

#include <windows.h>

long SetResolution(int width, int height, int monitor)
{
    // get device
    DISPLAY_DEVICE disp = { 0 };
    disp.cb = sizeof(disp);
    EnumDisplayDevices(NULL, monitor, &disp, NULL);

    // set resolution
    DEVMODE mode = { 0 };
    mode.dmSize = sizeof(mode);
    mode.dmPelsWidth = width;
    mode.dmPelsHeight = height;
    mode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;

    return(ChangeDisplaySettingsEx(disp.DeviceName, &mode, NULL, 0, NULL));
}

int main(int argc, char *argv[], char *envp[])
{
    int w = 1920; int h = 1080;

    if (argc == 2) {
        switch (atoi(argv[1]) /* resolution-id */)
        {
        case 768:
            w = 1024; h = 768;
            break;
        case 720:
            w = 1280; h = 720;
            break;
        default:
            break;
        }
    }
    return(SetResolution(w, h, 0));
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1