Jump to content
Sign in to follow this  

Changing DPI

Recommended Posts

Larry once made a script that would allow a person to change the screen resolution and depth, but in the process left the DPI change portion to the noobs. Well Larry, I admit I am a noob at dllcall, because I cannot see how to change the DPI using the DEVMODE dllstruct you created, since it does not seem to follow the format on MSDN.

For reference, the original post is here.

My current (very unsuccessful) attempt is here:

Func DisplayChangeDPI($dpi)
    $DM_LOGPIXELS = 0x00020000
    $DEVMODE = DLLStructCreate("byte[32];int[10];byte[32];int[6]")
    $b = DLLCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DLLStructGetPtr($DEVMODE))
    If @error Then
        $b = 0
        $b = $b[0]
    If $b <> 0 Then
        ;??????  DllStructSetData($DEVMODE, 6, $DM_LOGPIXELS)

Func DisplayChangeDPI($dpi)
    long ret;


    DevM.dmFields = DM_LOGPIXELS;
    DevM.dmLogPixels = dpi;

    ret = ChangeDisplaySettings(&DevM, CDS_TEST);

            return 2;
            ChangeDisplaySettings(&DevM, CDS_UPDATEREGISTRY);
            SendMessage(HWND_BROADCAST, WM_DISPLAYCHANGE, (WPARAM)DevM.dmBitsPerPel, (LPARAM)(DevM.dmPelsHeight * 2 ^ 16 + DevM.dmPelsWidth));
            return 1;
            return 0;
Edited by this-is-me

Who else would I be?

Share this post

Link to post
Share on other sites

Nevermind, I found information on an undocumented function that allows a DPI change. Here it is for those who want to know:

DllCall("syssetup.dll", "int", "SetupChangeFontSize", "int_ptr", 0, "wstr", "96")

The target DPI (in this case 96) must be specified in string format. This function will only take effect after a system restart.

Who else would I be?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...