Restored from previous forum. Originally posted by Julien Morel.
Hello
I will want to make a small application to stop my PC at one hour precise.
To stop the PC I use the following code:
OpenLibrary(0,"USER32.DLL")
CallFunction(0,"ExitWindowsEx",EWX_POWEROFF,0)
The problem it is that the PC does not stop but Windows closes just the session in progress.
How to make to stop the PC easily?
It would be necessary that the code goes with win9X and NT XP.
Thank you for your assistance.
Also if somebody knows how to know the number of the mother card,
it would be well.
Sorry for my English, but I french
Thank for help me
How Exit Windows, This code is good ?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by TheBeck.
No need to OpenLibrary() for API calls. Do this:
ExitWindowsEx_() #EWX_POWEROFF
For this function don't use 0 for last argument as 0 makes windows write debug code to disk witch takes extra time instead use something like this:
-> #SHTDN_REASON_MAJOR_APPLICATION|#SHTDN_REASON_MINOR_OTHER
Your code should look like this:
I am not able to test this code at this time so I hope it works...
No need to OpenLibrary() for API calls. Do this:
ExitWindowsEx_() #EWX_POWEROFF
For this function don't use 0 for last argument as 0 makes windows write debug code to disk witch takes extra time instead use something like this:
-> #SHTDN_REASON_MAJOR_APPLICATION|#SHTDN_REASON_MINOR_OTHER
Your code should look like this:
Code: Select all
If ExitWindowsEx_(#EWX_POWEROFF, #SHTDN_REASON_MAJOR_APPLICATION|#SHTDN_REASON_MINOR_OTHER) = #false
MessageRequester("Error", Str$(GetLastError_()), #PB_MessageRequester_Ok)
end
EndIf
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Julien Morel.
It is that?
//English
This code Closes the session, but I want that the PC stop
I am under Windows XP home
//French
Est cela comme code ?
Ce code Ferme la session, mais je veux que le PC s’arrête
Je suis sous Windows XP Home
#EWX_POWEROFF=0
#SHTDN_REASON_MAJOR_APPLICATION=0
#SHTDN_REASON_MINOR_OTHER=8
ExitWindowsEx_(#EWX_POWEROFF,#SHTDN_REASON_MAJOR_APPLICATION|#SHTDN_REASON MINOR_OTHER)
It is that?
//English
This code Closes the session, but I want that the PC stop
I am under Windows XP home
//French
Est cela comme code ?
Ce code Ferme la session, mais je veux que le PC s’arrête
Je suis sous Windows XP Home
#EWX_POWEROFF=0
#SHTDN_REASON_MAJOR_APPLICATION=0
#SHTDN_REASON_MINOR_OTHER=8
ExitWindowsEx_(#EWX_POWEROFF,#SHTDN_REASON_MAJOR_APPLICATION|#SHTDN_REASON MINOR_OTHER)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.
You have to change Token Privileges to be able to do this under NT-W2K-XP
This is already a couple of times posted here.
viewtopic.php?t=4278">http://forums.pur ... ebasic.htm
You have to change Token Privileges to be able to do this under NT-W2K-XP
This is already a couple of times posted here.
viewtopic.php?t=4278">http://forums.pur ... ebasic.htm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm