Forum Discussion

Ag3nt49's avatar
Ag3nt49
Occasional Contributor
8 years ago

DPI Settings

Hello,   I am looking to write a VBScript that retrieves the current system's DPI settings. I've tried looking online, but so far have not yet found anything that solidly works. Any help for a dire...
  • tristaanogre's avatar
    tristaanogre
    8 years ago
    I was just about to post that the value that you're looking for is in the registry.  Now, there are a few things out there on StackOverflow and such that talk about needing to make sure you are referencing the proper device since different monitors on the same machine could be set differently... but the script that sanjay0288 looks pretty good.

    One thing that I would suggest changing is that, starting with more recent versions of TC, you no longer need to create an object for the WScript.Shell.  TC has it's own wrapper for it.  So, you can pretty much just change your function to be:
    Function readFromReg(strRegistryKey, defaultVal)
        Dim value
        On Error Resume Next
        value = WshShell.RegRead(strRegistryKey)
        If Err.Number <> 0 Then
            readFromReg = defaultVal
        Else
            readFromReg = value
        End If
    End Function