Created
March 9, 2024 06:09
-
-
Save neuralpain/45e3ca94c7e32f2d1b14fdf510aca62d to your computer and use it in GitHub Desktop.
Add DPI awareness to Powershell-run .Net Windows Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using assembly System.Windows.Forms | |
using namespace System.Windows.Forms | |
using namespace System.Drawing | |
#Enable visual styles | |
[Application]::EnableVisualStyles() | |
#Enable DPI awareness | |
$code = @" | |
[System.Runtime.InteropServices.DllImport("user32.dll")] | |
public static extern bool SetProcessDPIAware(); | |
"@ | |
$Win32Helpers = Add-Type -MemberDefinition $code -Name "Win32Helpers" -PassThru | |
$null = $Win32Helpers::SetProcessDPIAware() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment