Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

@nfukuoka's pickup articles

nfukuoka

@nfukuoka(nfukuoka)

[Software Developer]です。 なお、掲載内容は全て個人の見解であり、所属する団体・組織としての見解ではありません

Comments

No comments

Let's comment your feelings that are more than good

Being held Article posting campaign

1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Login to continue?

Login or Sign up with social account

Login or Sign up with your email address