Arsip: Script shutdown komputer

more 16 years ago
mourphious
yth. Master2 delphi
Numpang tanya, kalo scricpt bwt matiin komputer tu gmn y?
tlong d jwb y! :lol:

more 16 years ago
hak3nd3n
Coba pakai ini
var s:string;
begin
s:='shutdown -s -t 0';
WinExec(pchar(s),SW_NORMAL);

more 16 years ago
ImanD
@mourphiousOffline
bisa juga memanfaatkan fungsi ExitWindowsEx();
sample http://www.swissdelphicenter.ch/torry/showcode.php?id=168

more 16 years ago
eksant
Lengkapnya :
function Shutdown(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,
TTokenPvg.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,
TTokenPvg,
cbtpPrevious,
rTTokenPvg,
pcbtpPreviousRequired);
end;
end;
Result := ExitWindowsEx(RebootParam, 0);
end;

more 15 years ago
duro
function SetPrivilege(
sPrivilegeName : string;
bEnabled : boolean )
: boolean;
var
TPPrev,
TP : TTokenPrivileges;
Token : THandle;
dwRetLen : DWord;
begin
Result := False;
OpenProcessToken(
GetCurrentProcess,
TOKEN_ADJUST_PRIVILEGES
or TOKEN_QUERY,
@Token );
TP.PrivilegeCount := 1;
if( LookupPrivilegeValue(
Nil,
PChar( sPrivilegeName ),
TP.Privileges[ 0 ].LUID ) )then
begin
if( bEnabled )then
begin
TP.Privileges[ 0 ].Attributes :=
SE_PRIVILEGE_ENABLED;
end else
begin
TP.Privileges[ 0 ].Attributes :=
0;
end;
dwRetLen := 0;
Result := AdjustTokenPrivileges(
Token,
False,
TP,
SizeOf( TPPrev ),
TPPrev,
dwRetLen );
end;
CloseHandle( Token );
end;
function WinExit( iFlags : integer ) : boolean;
begin
Result := True;
if( SetPrivilege( 'SeShutdownPrivilege', True ) )then
begin
if( not ExitWindowsEx( iFlags, 0 ) )then
Result := False;
end;
SetPrivilege( 'SeShutdownPrivilege', False )
end else
begin
Result := False;
end;
end;
panggil : ExitWindows( EW_RESTARTWINDOWS, 0 );
Semoga membantumore ...
- Pages:
- 1
reply |
Report Obsolete
AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now:
https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 5 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago
Random Topic
- Crystal Report pada Delphi 7
by shindo in Hal umum tentang Pascal Indonesia more 17 years ago - Create menu Item di Delphi IDE [problem: cannot dropdown..]
by wongdee2t in Enginering more 19 years ago - File EXE
by p2bf in OOT more 17 years ago - Set lebar grid otomatis
by chandra in Tutorial & Community Project more 16 years ago - Makan di D'Cost
by zones in Network, Files, I/O & System more 16 years ago - transfer file lewat bluetooth?
by barcodebima in Enginering more 17 years ago - [ASK] Buat Lookup Table...
by RoenZ in Enginering more 17 years ago - Menggambar control langsung ke bitmap, mungkinkah ?
by kenjiro in Tip n Trik Pemrograman more 16 years ago - Tanya Gan... Membuat Bank SOAL dengan delphi ???
by sandymercury in Hal umum tentang Pascal Indonesia more 13 years ago - Perkalaian antara 2 buah listbox
by mysweetaurel in Hal umum tentang Pascal Indonesia more 16 years ago