I've designed a project containing of some forms. The problem is that it doesn't display correctly on wide monitors. I've searched for it and found out that it works correctly for dpi= 96. I wanna change dpi via registry in vb.net (not manually) Here is the code I use:
Dim dpi As Graphics = Me.CreateGraphics
If (dpi.DpiX <> 96 And dpi.DpiY <> 96) Then
Dim DPISetting As RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("HKEY_CURRENT_USER\Control Panel\Desktop\WindowsMetrics", True)
DPISetting.SetValue("AppliedDPI", 96) '**
End If
But I get a nullRefrence Exception at the line with **. Object reference not set to an instance of an object. I've really worked on it for a long time but couldn't find what the problem is. I'd be so thankful if you have any suggestion or solution for it.