• 使用Windows API获取和改变当前显示设置


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

    void main()
    {
        DEVMODE devmode,oldmode;
        EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&devmode);
        ZeroMemory(&oldmode,sizeof(DEVMODE));
        CopyMemory(&oldmode,&devmode,sizeof(DEVMODE));
        printf("BitsPerPel:%d\n",devmode.dmBitsPerPel);
        printf("DisplayFrequency:%d\n",devmode.dmDisplayFrequency);
        printf("PelsWidth:%d\n",devmode.dmPelsWidth);
        printf("PelsHeight:%d\n",devmode.dmPelsHeight);
        printf("Press any key to change display...\n");
        getch();
        printf("BitsPerPel:%d\n",devmode.dmBitsPerPel=16);
        printf("DisplayFrequency:%d\n",devmode.dmDisplayFrequency=60);
        printf("PelsWidth:%d\n",devmode.dmPelsWidth=800);
        printf("PelsHeight:%d\n",devmode.dmPelsHeight=600);
        ChangeDisplaySettings(&devmode,0);
        printf("Press any key to restore...\n");   
        getch();
        printf("BitsPerPel:%d\n",oldmode.dmBitsPerPel);
        printf("DisplayFrequency:%d\n",oldmode.dmDisplayFrequency);
        printf("PelsWidth:%d\n",oldmode.dmPelsWidth);
        printf("PelsHeight:%d\n",oldmode.dmPelsHeight);
        printf("Press any key to change display...\n");
        ChangeDisplaySettings(&oldmode,0);
        getch();
    }

  • 相关阅读:
    2021.4.11(每周总结)
    2021.4.9
    2021.4.8
    2021.4.7
    k8s集群安装(一)安装方案介绍
    k8s映射外部服务Endpoints
    Linux服务器配置上网代理squid
    SonarQube学习笔记
    yum安装指定版本mysql
    linux目录没有颜色的处理
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/286755.html
Copyright © 2020-2023  润新知