|
-
Sep 9th, 2002, 05:22 AM
#1
Thread Starter
Member
Difficult Question
Hello friends!
1) I am switching off my System without proper Shutdown. I want to write a program to shutdown the System properly.
To be Specific!
I want to execute a program when Iam switching off my Computer
2) The second question is I want to Turn Off my monitor from VB
I used the following coding. But its not working. Can u please help me .
SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal 0&
Thanks & Regards
E.ElayaRaja
-
Sep 9th, 2002, 06:04 AM
#2
I don't know about the first question, but for the second, try this
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _
ByVal lParam As Any) As Long
Private Const WM_SYSCOMMAND = &H112
Private Const SC_MONITORPOWER = &HF170
Dim l As Long
Private Sub Command1_Click()
'To turn off the monitor:
l = SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, 2&)
End Sub
Private Sub Command2_Click()
'Standby monitor:
l = SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, 1&)
End Sub
Private Sub Command3_Click()
'To turn on the monitor:
l = SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, -1&)
End Sub
-
Sep 9th, 2002, 06:04 AM
#3
1)
Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
uFlags
One or more of the following flags specifying how to shut down or reboot the computer:
EWX_FORCE = 4
Force any applications to quit instead of prompting the user to close them. EWX_LOGOFF = 0
Log off the network. EWX_POWEROFF = 8
Shut down the system and, if possible, turn the computer off. EWX_REBOOT = 2
Perform a full reboot of the system. EWX_SHUTDOWN = 1
Shut down the system.
dwReserved
Reserved for future versions of Windows. Always set to 0
Not sure about 2) sorry.
-
Sep 9th, 2002, 06:25 AM
#4
Fanatic Member
For the first Question,
Try make an app as Service(not necessary as service, but this
sort of app may need it)
In QueryUnload event, check if its Windows shutdown, if yes,
execute the stuff you need.
However, if you mean by pushing the power button to switch it
off and want the OS to raise an event notifying ur app about it
then this is quite impossible(may be, but I've never use an ATX
casing)
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
-
Sep 9th, 2002, 06:29 AM
#5
If you want to go the service route, check out this link:
Creating An NT Service
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
|