命令行改变屏幕分辨率 cds ChangeDisplaySettings

执行文件 https://files.cnblogs.com/files/nlsoft/cds.7z

#include <windows.h>
#include <stdio.h>

void SetResolution(int width, int height)
{
    DEVMODE dm;
    memset(&dm, 0, sizeof(dm));
    dm.dmSize = sizeof(dm);

    if (0 != EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
    {
        int savew = dm.dmPelsWidth;
        int saveh = dm.dmPelsHeight;
        dm.dmPelsWidth = width;
        dm.dmPelsHeight = height;

        LONG result = ChangeDisplaySettings(&dm, 0);
        if (result == DISP_CHANGE_SUCCESSFUL)
        {
            printf("Display change successful [%dx%d]: %d", width, height, result);
        }
        else
        {
            dm.dmPelsWidth = savew;
            dm.dmPelsHeight = saveh;
            ChangeDisplaySettings(&dm, 0);
            printf("Display change failed [%dx%d]: %d", width, height, result);
        }
    }
}

void main(int argc, char** argv)
{
    int w,h;
    if(argc==1 || argc==2)
    {
        printf("Usage: cds w h\n");
    }
    if(argc>=3)
    {
        w=atoi(argv[1]);
        h=atoi(argv[2]);
        SetResolution(w, h);
    }
}

 

上一篇:SqlServer 查运行进程


下一篇:查看SqlServer的内存使用情况