方法一

Private SPI_SETSCREENSAVERACTIVE As Integer = 17
Private SPIF_SENDWININICHANGE As Integer = 2
 
<DllImport("user32", CharSet:=CharSet.Auto)> _
Public Shared Function SystemParametersInfo( _
        ByVal intAction As Integer, _
        ByVal intParam As Integer, _
        ByVal strParam As String, _
        ByVal intWinIniFlag As Integer) As Integer
End Function

開啟螢幕保護程式

SystemParametersInfo(SPI_SETSCREENSAVERACTIVE, 1, Nothing, SPIF_SENDWININICHANGE)

關閉螢幕保護程式

SystemParametersInfo(SPI_SETSCREENSAVERACTIVE, 0, Nothing, SPIF_SENDWININICHANGE)

 

方法二

開啟螢幕保護程式

Call Registry.SetValue("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaveActive", "1")

關閉螢幕保護程式

Call Registry.SetValue("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaveActive", "0")

iammic 發表在 痞客邦 PIXNET 留言(0) 人氣()