We are trying to turn the monitor off via code and turn it back on via code. We found code that works however it uses user32.dll and does not seem to work in 64 bit mode like the rest of our software (yes i did try the obvious user64.dll) Any suggestions?
'''
Public WM_SYSCOMMAND As Integer = &H112
Public SC_MONITORPOWER As Integer = &HF170
Private mainWindowHandle As IntPtr
Public Sub New(mainWindowHandle As IntPtr)
InitializeComponent()
Me.mainWindowHandle = mainWindowHandle
End Sub
<DllImport("user32.dll")>
Private Shared Function SendMessage(hWnd As Integer, hMsg As Integer, wParam As Integer, lParam As Integer) As Integer
End Function
Private Sub PowerOffButton_Click(sender As Object, e As RoutedEventArgs)
SendMessage(mainWindowHandle, WM_SYSCOMMAND, SC_MONITORPOWER, 2)
End Sub
'''