Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Change Screen Resolution in Windows: Discover How to Set Current Resolution

Changing the screen resolution on a Windows computer can enhance your viewing experience, especially when dealing with different types of content or applications. However, the specific function "SetCurrentResolution" is not directly applicable in the Windows environment. Instead, Windows provides several ways to change the screen resolution via the graphical interface, command line, or PowerShell.


Changing Screen Resolution via Display Settings


1. Right-click on the Desktop: Right-click on an empty area of your desktop and select "Display settings."
2. Navigate to Resolution Settings: Scroll down to the "Display resolution" section.
3. Select Resolution: Choose your desired resolution from the dropdown menu. Windows will suggest the recommended resolution for your display.
4. Apply Changes: Click "Apply" to change the resolution. You will be prompted to confirm the change; if the screen looks good, click "Keep changes."


Changing Screen Resolution via Command Line


While Windows does not have a built-in command line tool to directly change the display resolution, third-party tools like "NirCmd" can be used. Here's how you can use NirCmd to change the resolution:


1. Download NirCmd: Visit the NirSoft website and download NirCmd.
2. Extract NirCmd: Extract the downloaded files to a folder on your computer.
3. Open Command Prompt: Press Win + R, type cmd, and press Enter to open the Command Prompt.
4. Navigate to NirCmd Directory: Use the cd command to navigate to the directory where NirCmd is extracted. For example:


   cd C:\path\to\nircmd

5. Set Resolution Using NirCmd: Use the following command to set the resolution:


   nircmd.exe setdisplay 1920 1080 32

Replace 1920 1080 32 with your desired width, height, and color depth.


Changing Screen Resolution via PowerShell


PowerShell does not natively support changing screen resolution, but you can use a script with the Windows API to achieve this. Here's a sample script:


Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class ScreenResolution {
[DllImport("user32\.dll")]
public static extern int ChangeDisplaySettings(ref DEVMODE devMode, int flags);
[DllImport("user32\.dll")]
public static extern bool EnumDisplaySettings(string deviceName, int modeNum, ref DEVMODE devMode);
public const int ENUM_CURRENT_SETTINGS = -1;
public const int CDS_UPDATEREGISTRY = 0x01;
public const int DISP_CHANGE_SUCCESSFUL = 0;
[StructLayout(LayoutKind.Sequential)]
public struct DEVMODE {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string dmDeviceName;
public short dmSpecVersion;
public short dmDriverVersion;
public short dmSize;
public short dmDriverExtra;
public int dmFields;
public int dmPositionX;
public int dmPositionY;
public int dmDisplayOrientation;
public int dmDisplayFixedOutput;
public short dmColor;
public short dmDuplex;
public short dmYResolution;
public short dmTTOption;
public short dmCollate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string dmFormName;
public short dmLogPixels;
public int dmBitsPerPel;
public int dmPelsWidth;
public int dmPelsHeight;
public int dmDisplayFlags;
public int dmDisplayFrequency;
public int dmICMMethod;
public int dmICMIntent;
public int dmMediaType;
public int dmDitherType;
public int dmReserved1;
public int dmReserved2;
public int dmPanningWidth;
public int dmPanningHeight;
}
public static void SetResolution(int width, int height) {
DEVMODE dm = new DEVMODE();
if (0 != EnumDisplaySettings(null, ENUM_CURRENT_SETTINGS, ref dm)) {
dm.dmPelsWidth = width;
dm.dmPelsHeight = height;
int iRet = ChangeDisplaySettings(ref dm, CDS_UPDATEREGISTRY);
if (iRet != DISP_CHANGE_SUCCESSFUL) {
throw new Exception("Unable to change resolution");
}
}
}
}
"@
[ScreenResolution]::SetResolution(1920, 1080)

Replace 1920, 1080 with your desired resolution.


To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.