GLOBAL OFFENSIVE SECURITY HACKERS
Anonymous Philippines
Anonymous General Santos
Anonymous Davao
MeowSec
Log in

I forgot my password

Search
 
 

Display results as :
 

 


Rechercher Advanced Search

Latest topics
» ANDROID MULTI TOOL V1.02B
by Zaisen Mon Apr 22, 2019 6:21 pm

» GSD ANDROID TOOL
by Zaisen Mon Apr 22, 2019 6:01 pm

» Hard Disk Sentinel Pro 5.30.6 + CRACK
by Zaisen Tue Apr 16, 2019 9:20 am

» DEEP FREEZE v7.22 + KEY
by Zaisen Tue Apr 16, 2019 8:57 am

» KMS SERVER WINDOWS ACTIVATOR
by Zaisen Fri Apr 12, 2019 10:53 am

» Nck AndroidMTK Setup 2562 Pass-GSMXTEAM
by Zaisen Thu Mar 28, 2019 6:50 pm

» Windows could not complete the installation. To install Windows on this computer
by Zaisen Thu Mar 28, 2019 6:30 pm

» MTK FRP BYPASS TOOL
by Zaisen Thu Mar 07, 2019 5:13 pm

» Shutdown the PC if the monitor is turned off or not connected (VGA / HDMI) within a period of time. #VB.NET
by Zaisen Wed Jan 23, 2019 5:50 pm

» Termux (Facebook-Bruteforce)
by Zaisen Tue Jan 08, 2019 12:10 pm

» VIRUS MAKER!
by Zaisen Tue Jan 08, 2019 11:35 am

» GO LOADER OFFICAL
by Zaisen Mon Nov 05, 2018 8:39 pm

» [Help] How to use Termux??
by Zaisen Mon Nov 05, 2018 8:17 pm

» FACEBOOK HACKING W/ COOKIE
by Zaisen Mon Nov 05, 2018 6:40 pm

» WARROCK GO LOADER
by Zaisen Mon Nov 05, 2018 1:59 pm


Shutdown the PC if the monitor is turned off or not connected (VGA / HDMI) within a period of time. #VB.NET

Go down

Globe Shutdown the PC if the monitor is turned off or not connected (VGA / HDMI) within a period of time. #VB.NET

Post by Zaisen on Mon Jan 21, 2019 9:17 pm

Code:
Imports System.Runtime.InteropServices

Public Class Form1
    Private hEvent As IntPtr = IntPtr.Zero
    Private PowerOffTime As Date

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Interval = 5000
        hEvent = RegisterPowerSettingNotification(Me.Handle, GUID_CONSOLE_DISPLAY_STATE, DEVICE_NOTIFY_WINDOW_HANDLE)
    End Sub

    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        UnregisterPowerSettingNotification(hEvent)
    End Sub

    Protected Overrides Sub WndProc(ByRef m As Message)
        MyBase.WndProc(m)
        If m.Msg = WM_POWERBROADCAST AndAlso m.WParam.ToInt32 = PBT_POWERSETTINGCHANGE Then
            Dim pbs As POWERBROADCAST_SETTING = CType(m.GetLParam(GetType(POWERBROADCAST_SETTING)), POWERBROADCAST_SETTING)

            'pbs.Data(0) will be 0-2 meaning --> (0 = Monitor Turned Off) (1 = Monitor Turned On) (2 = Monitor Entered 'Dimmed' State)

            If pbs.Data(0) = 0 Then PowerOffTime = Now
            Timer1.Enabled = (pbs.Data(0) = 0) 'enable timer if monitor is turned off | disable timer if monitor is turned on
        End If
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim ts As TimeSpan = Now - PowerOffTime
        If ts.TotalMinutes >= 5.0 Then 'if it has been 5 minutes...
            Timer1.Stop()
            'Monitor Power Has Been Off For 5 Minutes, start shutdown...
            Me.Close()
        End If
    End Sub

#Region "Native Methods"
    <StructLayout(LayoutKind.Sequential)>
    Private Structure POWERBROADCAST_SETTING
        Public PowerSetting As Guid
        Public DataLength As Integer
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Data As Byte()
    End Structure

    Private Const WM_POWERBROADCAST As Integer = &H218
    Private Const PBT_POWERSETTINGCHANGE As Integer = &H8013
    Private Const DEVICE_NOTIFY_WINDOW_HANDLE As Integer = &H0
    Private GUID_CONSOLE_DISPLAY_STATE As New Guid("6fe69556-704a-47a0-8f24-c28d936fda47") 'See --> https://msdn.microsoft.com/en-us/library/windows/desktop/hh448380%28v=vs.85%29.aspx

    <DllImport("User32.dll")>
    Private Shared Function RegisterPowerSettingNotification(hRecipient As IntPtr, ByRef NotificationFilter As Guid, Flags As Integer) As IntPtr
    End Function

    <DllImport("User32.dll")>
    Private Shared Function UnregisterPowerSettingNotification(ByVal Handle As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function
#End Region
End Class
Zaisen
Zaisen
______________
______________

Moods : WALAY KWARTA
Posts : 64
Join date : 2017-09-08

https://eliteph.forumotion.com

Back to top Go down

Globe Re: Shutdown the PC if the monitor is turned off or not connected (VGA / HDMI) within a period of time. #VB.NET

Post by Zaisen on Tue Jan 22, 2019 6:29 pm

Zaisen
Zaisen
______________
______________

Moods : WALAY KWARTA
Posts : 64
Join date : 2017-09-08

https://eliteph.forumotion.com

Back to top Go down

Globe Re: Shutdown the PC if the monitor is turned off or not connected (VGA / HDMI) within a period of time. #VB.NET

Post by Zaisen on Tue Jan 22, 2019 6:29 pm

Zaisen
Zaisen
______________
______________

Moods : WALAY KWARTA
Posts : 64
Join date : 2017-09-08

https://eliteph.forumotion.com

Back to top Go down

Globe Re: Shutdown the PC if the monitor is turned off or not connected (VGA / HDMI) within a period of time. #VB.NET

Post by Zaisen on Wed Jan 23, 2019 5:50 pm

Zaisen
Zaisen
______________
______________

Moods : WALAY KWARTA
Posts : 64
Join date : 2017-09-08

https://eliteph.forumotion.com

Back to top Go down

Globe Re: Shutdown the PC if the monitor is turned off or not connected (VGA / HDMI) within a period of time. #VB.NET

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum