Ok, ich hab mich mal mittels Google auf die Suche gemacht und es gibt
doch tatsächlich entweder ein japanisches bzw. chinesisches Forum.
Mit den Zeichen kenne ich mich natürlich nicht so aus
Aber ich habe hier was gefunden, angepasst und ausprobiert. Nicht schlecht.
Der Link des Originalsources ist am Anfang des Sources angegeben.
Code: Alles auswählen
;Projekt Shutdown Windows
;Author: http://oryaaaaa.com/forum/posting.php?mode=quote&p=180&sid=6a03a05fd151bb24d92616cfb446a95b
;Rewrite: Falko Lünsmann
Procedure ShutdownWIN(Endmode)
; Endmode=0 shutdouwn
If Endmode=1 ; Suspend
If OpenLibrary(0,"powrprof.dll") And GetFunction(0,"SetSuspendState")
CallFunction(0,"SetSuspendState",#False,#True,#False)
CloseLibrary(0)
EndIf
End
EndIf
If Endmode=2 ; Hibernate
If OpenLibrary(0,"powrprof.dll") And GetFunction(0,"SetSuspendState")
CallFunction(0,"SetSuspendState",#True,#True,#False)
CloseLibrary(0)
EndIf
End
EndIf
If Endmode=3 ; End
End
EndIf
If OSVersion()=#PB_OS_Windows_XP ;#VER_PLATFORM_WIN32_NT
#TOKEN_ADJUST_PRIVILEGES = 32
#TOKEN_QUERY = 8
#SE_PRIVILEGE_ENABLED = 2
#EWX_LOGOFF = 0
#EWX_SHUTDOWN = 1
#EWX_REBOOT = 2
#EWX_FORCE = 4
#EWX_POWEROFF = 8
Structure MyLUID
lowpart.l
highpart.l
Attributes.l
EndStructure
Structure MyTOKEN
PrivilegeCount.l
lowpart.l
highpart.l
Attributes.l
EndStructure
Global hdlProcessHandle.l
Global hdlTokenHandle.l
Global tmpLuid.MyLUID
Global tkp.MyTOKEN
Global tkpNewButIgnored.MyTOKEN
Global lBufferNeeded.l
hdlProcessHandle = GetCurrentProcess_()
OpenProcessToken_(hdlProcessHandle, #TOKEN_ADJUST_PRIVILEGES | #TOKEN_QUERY, @hdlTokenHandle)
; Get the LUID For shutdown privilege.
SysName.s=""+Chr(0)
Name.s="SeShutdownPrivilege"+Chr(0)
Erg.l=LookupPrivilegeValue_(SysName, Name, @tmpLuid)
tmpLuid\Attributes = #SE_PRIVILEGE_ENABLED
tkp\PrivilegeCount = 1
tkp\lowpart = tmpLuid\lowpart
tkp\highpart = tmpLuid\highpart
tkp\Attributes = tmpLuid\Attributes
; Enable the shutdown privilege in the access token of this process.
Erg.l = AdjustTokenPrivileges_(hdlTokenHandle,0,@tkp,SizeOf(MyTOKEN),@tkpNewButIgnored,@lBufferNeeded)
Erg.l = ExitWindowsEx_((#EWX_SHUTDOWN | #EWX_POWEROFF | #EWX_FORCE), 0)
If Erg=0
OpenConsole()
Buffer.s = Space(200)
FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), #LANG_NEUTRAL, @Buffer, 200, 0)
PrintN(Buffer)
Input()
CloseConsole()
EndIf
End
ElseIf OSVersion()=#PB_OS_Windows_98 ;#VER_PLATFORM_WIN32_WINDOWS
#EWX_FORCE=4
#EWX_LOGOFF=0
#EWX_REBOOT=2
#EWX_SHUTDOWN=1
ExitWindowsEx_(#EWX_SHUTDOWN|#EWX_FORCE,0)
End
EndIf
EndProcedure
ShutdownWIN(2); Schaltet in den Suspendmode, bei mir funktioniert das prima auf XP :D
PS: Ihr braucht dazu eine PB-Vollversion und keine Demo wegen der API
Und tragt doch bitte das in das Proil oder eure Signatur ein, damit jeder weis, mit welcher PB-Version gearbeitet wird
Grüße Falko