![]() |
|
#1
|
|||
|
|||
|
Hi !
I have one Question about activate hibernate from an application. But i can't find anything about hibernate or any other sleep function, please help me, I hate that I can't find any way out of this problem. If Someone knows, i like to know, how to set the computer to Hibernate and sleep. And do this without asking like I use [EWX_FORCE] if it's possible ? Thanks if someone can help me. [Code I use following] function togglecom(RebootParam: Longword): Boolean; var TTokenHd: THandle; TTokenPvg: TTokenPrivileges; cbtpPrevious: DWORD; rTTokenPvg: TTokenPrivileges; pcbtpPreviousRequired: DWORD; tpResult: Boolean; const SE_SHUTDOWN_NAME = 'SeShutdownPrivilege'; begin if Win32Platform = VER_PLATFORM_WIN32_NT then begin tpResult := OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, TTokenHd); if tpResult then begin tpResult := LookupPrivilegeValue(nil,SE_SHUTDOWN_NAME,TTokenPv g.Privileges[0].Luid); TTokenPvg.PrivilegeCount := 1; TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; cbtpPrevious := SizeOf(rTTokenPvg); pcbtpPreviousRequired := 0; if tpResult then Windows.AdjustTokenPrivileges(TTokenHd,False,TToke nPvg,cbtpPrevious,rTTokenPvg,pcbtpPreviousRequired ); end; end; Result := ExitWindowsEx(RebootParam, 0); end; procedure TForm1.Button1Click(Sender: TObject); begin togglecom(EWX_POWEROFF or EWX_FORCE); end; procedure TForm1.Button2Click(Sender: TObject); begin togglecom(EWX_REBOOT or EWX_FORCE); end; procedure TForm1.Button3Click(Sender: TObject); begin togglecom(EWX_LOGOFF or EWX_FORCE); end; |
|
#2
|
|||
|
|||
|
__________________
Regards, Abdulaziz Jasser |
![]() |
| Thread Tools | |
| Display Modes | |
|
|