ChangeScreenResolution – Change the current screen resolution

ChangeScreenResolution – Change the current screen resolution

Option ExplicitConst DM_BITSPERPEL As Long = &H40000Const DM_PELSWIDTH As Long = &H80000Const DM_PELSHEIGHT As Long = &H100000Const CDS_FORCE As Long = &H80000000Const CCDEVICENAME As Long = 32Const CCFORMNAME As Long = 32Private Type DEVMODE    dmDeviceName As String * CCDEVICENAME    dmSpecVersion As Integer    dmDriverVersion As Integer    dmSize As Integer    dmDriverExtra As Integer    dmFields As Long    dmOrientation As Integer    dmPaperSize As Integer    dmPaperLength As Integer    dmPaperWidth As Integer    dmScale As Integer    dmCopies As Integer    dmDefaultSource As Integer    dmPrintQuality As Integer    dmColor As Integer    dmDuplex As Integer    dmYResolution As Integer    dmTTOption As Integer    dmCollate As Integer    dmFormName As String * CCFORMNAME    dmUnusedPadding As Integer    dmBitsPerPel As Long    dmPelsWidth As Long    dmPelsHeight As Long    dmDisplayFlags As Long    dmDisplayFrequency As LongEnd TypePrivate Declare Function EnumDisplaySettings Lib "user32" Alias _    "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, _    ByVal modeIndex As Long, lpDevMode As Any) As BooleanPrivate Declare Function ChangeDisplaySettings Lib "user32" Alias _    "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long' change the screen resolution mode'' returns True if the requested resolution mode is among those' supported by the display adapter (otherwise it doesn't even' try to change the screen resolution)Function ChangeScreenResolution(ByVal Width As Long, ByVal Height As Long, _    ByVal NumColors As Long, Optional Frequency As Long) As Boolean    Dim lpDevMode As DEVMODE    Dim index As Long        ' set the DEVMODE flags and structure size    lpDevMode.dmSize = Len(lpDevMode)    lpDevMode.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL        ' retrieve info on the Nth display mode, exit if no more    Do While EnumDisplaySettings(0, index, lpDevMode) > 0        ' check whether this is the mode we're looking for        If lpDevMode.dmPelsWidth = Width And lpDevMode.dmPelsHeight = Height _            And 2 ^ lpDevMode.dmBitsPerPel = NumColors Then            ' check that the frequency is also the one we're looking for            If Frequency = 0 Or Frequency = lpDevMode.dmDisplayFrequency Then                ' try changing the resolution                If ChangeDisplaySettings(lpDevMode, CDS_FORCE) = 0 Then                    ' zero means success                    ChangeScreenResolution = True                    Exit Do                End If            End If        End If        ' skip to next screen mode        index = index + 1    LoopEnd Function

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes