Since I've tried the suggestions and it seems no one's code works on my PCs (both at home and at work) - although both of them do support Standby and Hibernate mode...
Just a thought - VB Script seems to be able to do most things. Why don't you ask on there, forum 329, and then if they come up with a solution, use the scripting runtime to include it in your VB.NET program.
you can also look into the shutdown command in XP. you can use a shell statement to call it, I'm not sure if it support hibernate though.
Most of what I saw on the net for hib/suspend delt with finding the correct dll. If the hibernate/suspend system is being controled by a different set of drivers then the core windows (kernel32) then it won't work. See if there are settings for suspend more in your graphics settings, if so, disable them and set it up in the system settings.
I posted to thread329-1088571 and will post back here with any "winning answers"...
In the meantime, if anyone knows how to do this in pure VB.NET, please post here. BTW, could anyone get their computers to go into standby mode with the code posted above?
Oops - I don't know a whole lot about this, as just became glaringly obvious (in case it wasn't before). I thought that was Rick's own implementation of it...
Because the function is in a Win32 dll that Microsoft has not yet incorporated into the .NET Framework we need to tell our program where to find it and what its called:
Declare Function SetSystemPowerState Lib "kernel32" (ByVal fSuspend As Integer, ByVal fForce As Integer) As Integer
Then we can use the function so for example - assume you have a button on your form called btnStandby
In its Click event you would put: SetSystemPowerState(1,0)
I beleive the problem is that kernel32 is not controling your system's suspend mode. There was a thread about this on another forum and the person figure out that he had to use his video card's drivers. The code was exactly the same, but he had a different dll listed then kernel32.
but am not sure how. Could someone please offer some very specific guidance, please? As in, all the code necessary for a VB.NET button click to put a PC into Standby?
You ARE using that API. The CORRECT CODE has been posted. The problem is with the configuration of your computer. Using that API from the Kernal32 library will only work if Kernal32 is controling your machines sleep state. It is possible that your video card driver is actually controlling the sleep state, if it is, you either need to call the set power state from that DLL or turn off your video cards sleep state control and turn on the windows sleep state control.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.