VB and VBA Users Source Code: Suspend a Computer
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Suspend a Computer
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, November 20, 2000
Hits:
601
Category:
Windows API
Article:
To suspend a PC use the following routine: Option Explicit Private Declare Function SetSystemPowerState Lib "kernel32" (ByVal fSuspend As Long, ByVal fForce As Long) As Long 'Purpose : To make a machine go into suspended mode. 'Inputs : bPrompt If True will prompt the user before going into suspended mode 'Outputs : Returns True if succeeded 'Author : Andrew Baker 'Date : 20/11/2000 15:19 'Notes : 'Revisions : 'Assumptions : 'Requirements: Windows NT/2000: Requires Windows 2000. ' Windows 95/98: Requires Windows 95 or later. Function MachineSuspend(Optional bPrompt As Boolean) As Boolean If bPrompt Then 'Prompts the user before it goes into sleep mode 'if you have dial up open networking you will be prompted MachineSuspend = SetSystemPowerState(1, 0) Else 'Forces your computer into sleep mode 'Note, this will terminate dial up connections MachineSuspend = SetSystemPowerState(1, 1) End If End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder