Rickey, Kyle W wrote:
What do I need to do to put my local computer into standby? I found the
function:
win32api.InitiateSystemShutdown("INT8Y4Y3B1", "Tom Sucks", 300, False,
False)
but it seems to only shutdown/restart.
You need the SetSystemPowerState [1] function from kernel32.
(And your process will need to enable SeShutdown as well).
<code>
import ctypes
import win32api
import win32security
#
# Enable the SeShutdown privilege (which must be present in your
# token in the first place)
#
priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
hToken = win32security.OpenProcessToken (
win32api.GetCurrentProcess (),
priv_flags
)
priv_id = win32security.LookupPrivilegeValue (
None,
win32security.SE_SHUTDOWN_NAME
)
old_privs = win32security.AdjustTokenPrivileges (
hToken,
0,
[(privilege_id, win32security.SE_PRIVILEGE_ENABLED)]
)
#
# Params:
# True=> Standby; False=> Hibernate
# True=> Force closedown; False=> Don't force
#
ctypes.windll.kernel32.SetSystemPowerState (True, True)
</code>
TJG
[1] http://msdn.microsoft.com/en-us/library/aa373206(VS.85).aspx
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32