Created
August 4, 2015 22:57
-
-
Save anonymous/b9d7b391b66a25a2cb0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#define WITH_DEBUG_CONSOLE | |
#ifndef UNICODE | |
# define UNICODE | |
#endif | |
#define WIN32_LEAN_AND_MEAN | |
#include <Windows.h> | |
#ifdef WITH_DEBUG_CONSOLE | |
# define _CRT_SECURE_NO_WARNINGS | |
# include <stdio.h> | |
#else | |
# define printf(...) do {} while (0) | |
#endif | |
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ PWSTR pCmdLine, _In_ int nCmdShow) | |
{ | |
#ifdef WITH_DEBUG_CONSOLE | |
if (AllocConsole()) { | |
// WARNING: this might not work with cout | |
// NOTE: the doc of the so called secure alternative freopen_s makes no sense | |
freopen("CONOUT$", "wt", stdout); | |
} | |
#endif | |
HKEY hkey_desktop; | |
LONG res; | |
res = RegOpenKeyExW(HKEY_CURRENT_USER, | |
L"Control Panel\\Desktop", | |
0, | |
KEY_SET_VALUE, | |
&hkey_desktop); | |
if (res == ERROR_SUCCESS) { | |
DWORD DpiScalingVer_val = 0x00001018; | |
res = RegSetValueExW(hkey_desktop, | |
L"DpiScalingVer", | |
0, | |
REG_DWORD, | |
(BYTE*)&DpiScalingVer_val, | |
sizeof(DWORD)); | |
if (res) | |
printf("setting DpiScalingVer failed: %lx\n", res); | |
DWORD Win8DpiScaling_val = 1; | |
res = RegSetValueExW(hkey_desktop, | |
L"Win8DpiScaling", | |
0, | |
REG_DWORD, | |
(BYTE*)&Win8DpiScaling_val, | |
sizeof(DWORD)); | |
if (res) | |
printf("setting Win8DpiScaling failed: %lx\n", res); | |
DWORD LogPixels_val = 0x00000078; | |
res = RegSetValueExW(hkey_desktop, | |
L"LogPixels", | |
0, | |
REG_DWORD, | |
(BYTE*)&LogPixels_val, | |
sizeof(DWORD)); | |
if (res) | |
printf("setting LogPixels failed: %lx\n", res); | |
res = RegCloseKey(hkey_desktop); | |
if (res) | |
printf("RegCloseKey() failed: %lx\n", res); | |
printf("this is only a test, do not attempt to leave the dance floor!\n"); | |
} else { | |
printf("RegOpenKeyEx() failed: %lx\n", res); | |
} | |
//Sleep(5000); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment