|
-
October 1st, 2010, 05:07 PM
#7
Re: Know when laptop lid is closed
Hi,
That code is great and it works but can you make like a function to tell the monitor power state.
I saw this code on the internet
Public Function IsMonitorOff() As Boolean
On Error GoTo Hell
Dim wmiObjSet As SWbemObjectSet
Dim colSettings As SWbemObject
wmiObjSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_DesktopMonitor")
For Each colSettings In wmiObjSet
MsgBox(colSettings.Availability)
Select Case colSettings.Availability
Case 7
IsMonitorOff = True
Case 3
IsMonitorOff = False
End Select
Next
Exit_For:
wmiObjSet = Nothing
On Error GoTo 0
Exit Function
Hell:
GoTo Exit_For
End Function
But the SWbemObjectSet and SWbemObject aren't decared and i can't find any on the internet.
JamesStewy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|