PowerShell – Set DPI Aware

email me

 

Code.ps1

 

# MrNetTek
# eddiejackson.net
# 7/15/2022
# free for public use
# free to claim as your own

# Add a new type definition using C# code
Add-Type -TypeDefinition @'
using System.Runtime.InteropServices; // Import the necessary namespace for DLL import
public class ProcessDPI {
    // Declare an external method from user32.dll to set the process DPI awareness
    [DllImport("user32.dll", SetLastError=true)]
    public static extern bool SetProcessDPIAware();      
}
'@

# Call the SetProcessDPIAware method to make the current process DPI aware
$null = [ProcessDPI]::SetProcessDPIAware()