#include #include #include #include void PrintAvailableDisplayModes() { DEVMODE dm; // содержит сведения о инициализации и среде принтера или устройства отображения. int count = 0; while (EnumDisplaySettings(NULL, count++, &dm)) { //позволяет получить доступные варианты разрешений и цветов видеосистемы; printf("Resolution: %dx%d, Color: %d bits\n", dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel); } } void PrintCurrentDisplayMode() { DEVMODE dm; if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm)) { printf("Current Resolution: %dx%d, Current Color Depth: %d bits\n", dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel); } else { printf("Unable to retrieve current display settings.\n"); } } void ChangeScreenResolution(int width, int height, int colorDepth) { DEVMODE dm; ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); dm.dmPelsWidth = width; dm.dmPelsHeight = height; dm.dmBitsPerPel = colorDepth; dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; LONG result = ChangeDisplaySettings(&dm, CDS_UPDATEREGISTRY); if (result == DISP_CHANGE_SUCCESSFUL) { printf("Resolution changed successfully to %dx%d, %d bits color depth.\n", width, height, colorDepth); } else { printf("Failed to change resolution.\n"); } } void ChangeOboi(const char* wallpaperPath) { // указ if (GetFileAttributes(wallpaperPath) == INVALID_FILE_ATTRIBUTES) { printf("File not found: %s\n", wallpaperPath); return; } // Изменение обоев if (SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID)wallpaperPath, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)) { printf("Wallpaper changed successfully to %s\n", wallpaperPath); } else { printf("Failed to change wallpaper to %s\n", wallpaperPath); } } // Функция для получения цвета пикселя под курсором мыши void GetPixelColorUnderCursor() { for (int i=0; i < 10; i++) { POINT pt; // пара координат if (GetCursorPos(&pt)) { HDC hdc = GetDC(NULL); //контекст устройства для экрана COLORREF color = GetPixel(hdc, pt.x, pt.y); //RGB red green blue ReleaseDC(NULL, hdc); printf("Color under cursor: RGB(%d, %d, %d)\n", GetRValue(color), GetGValue(color), GetBValue(color)); } else { printf("Unable to get cursor position.\n"); } Sleep(1000); } } int main() { PrintAvailableDisplayModes(); PrintCurrentDisplayMode(); //ChangeScreenResolution(1920, 1440, 32); ChangeScreenResolution(2160, 1440, 32); ChangeOboi(L"D:\\bts.png"); GetPixelColorUnderCursor(); system("pause"); return 0; }