VB.NET覚書

VB.NETの覚書
[個人メモ] [仕事メモ] [アイデア] [Ruby]
[TIPS] [対応表] [コメント書き方] [.NET Tips] [VB中学校] [VB.NET の入門サイト] [VB.NET コーディング標準 ] [VBレスキュー] [NonSoft]

2014-07-11

画面の電源を消すだけのソフト

http://www.vector.co.jp/soft/win95/hardware/se313781.html

exeの実行で省電力モードになる

VB.NETで、モニターの電源を切る。入れる。

http://scripting.cocolog-nifty.com/blog/2009/05/vbnet-5faa.html


vbc /t:winexe MonitorPowerOff.vb

Public Class Class1
Private Declare Function SendMessageA Lib "user32" (hWnd As Integer,  Msg As Integer, wParam As Integer, lParam As Integer) As Integer
Public Shared Sub Main()
SendMessageA(-1, 274, 61808, 2)
End Sub
End Class

vbc /t:winexe MonitorPowerOn.vb

Public Class Class1
Private Declare Function SendMessageA Lib "user32" (hWnd As Integer,  Msg As Integer, wParam As Integer, lParam As Integer) As Integer
Public Shared Sub Main()
SendMessageA(-1, 274, 61808, -1)
End Sub
End Class

VB6モニターON OFF



Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Sub Command1_Click()

    Dim t As Single
    
    t = Timer
    

    
    Label1.Caption = "START"
    
      Call SendMessage(-1, 274, 61808, 2)
    Do While Timer - t < 5
        DoEvents
    Loop
    
    Call SendMessage(-1, 274, 61808, -1)
    


End Sub

VB.NET モニタON/OFF


Public Class Form1
    Private Declare Function SendMessageA Lib "user32" (hWnd As Integer, Msg As Integer, wParam As Integer, lParam As Integer) As Integer

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click


        'モニターOFF
        Call SendMessageA(-1, 274, 61808, 2)

        System.Threading.Thread.Sleep(3000)
        'モニターON
        Call SendMessageA(-1, 274, 61808, -1)
    End Sub
End Class
トラックバック - http://sub.g.hatena.ne.jp/garyo/20140711