Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
General :: Windows :: Programming :: Windows with Delphi :: Windows API
Windows programming with Delphi
Articles:
This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Only the 40 most recently viewed articles are shown. You can see the full list here.
Featured Article
Programmatically logoff a user, shutdown or reboot
If your program needs to programmatically logoff a user, shutdown or reboot the computer, then you may use the following function with the appropriate parameter:
WinExit(EWX_LOGOFF); // one of these 3 only :-)
WinExit(EWX_REBOOT);
WinExit(EWX_SHUTDOWN);
See the source for the flags EWX_POWEROFF and EWX_FORCE.
The function SetPrivilege() is a necessary helper function.
The other document referenced at the top in the See-Also section is a slight modification of this code snippet, but it works basically the same way.  | |  | | 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
TP.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
else
TP.Privileges[0].Attributes := 0;
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
begin
result := False
end;
SetPrivilege ('SeShutdownPrivilege', False)
end
else
begin
result := False
end
end;
| |  | |  | You don't like the formatting? Check out SourceCoder then!
|
| Most recent comments
2008-10-13 07:36:46:
by anonymous
in Other Scams
on Another dating / chat scam - USA/ Nigeria connection:
has anyone been getting any mail from trustedlilly@yahoo.com from Ghana ? Please let me know. I want to get back at her good. I have not sent her any money and never would. I am just sick of these sna ... read more
|
2008-10-13 06:30:08:
by anonymous
in Male Dating Scammers
on Dating scammer Alan Armstrong:
Oh he was using Newsline0444 on Match.com this time around. I have reported him to Interpol and the irish police. I'll forward his details to Scotland Yard today as well as one of his IP addresses c ... read more
|
2008-10-13 05:57:02:
by Gabor
in Dating Scams
on Dating scammer Goodwill Ajaratu:
Hi,
I am more than happy in your reply to my mail.
How is your day? Mine was hot over here in Daker senegal.
My name is Josebeth Andrew (23) single and never married,I am from liber ... read more
|
2008-10-13 03:15:39:
by [hidden]
in Dating Scams
on Dating scammer Rhoda Naa from Accra, Ghana:
Can you find out the IP-Address from her and post it here??Thanks
|
2008-10-13 01:13:31:
by anonymous
in Dating Scams
on Dating scammer anastasiya:
PLEASE CONTACT ME MEHRDAD.ALIHA@GMAIL.COM
|
2008-10-13 00:55:30:
by [hidden]
in Dating Scams
on Dating scammer svetlana belonosova:
Hi guys, was just looking at my computer and found an old email from Svetlana,sent to me last christmas...
(i will send it to admin,hope they can attach it here..)
I dont look for Russian gir ... read more
|
|
2008-10-12 23:51:43:
by [hidden]
in Dating Scams
on Dating scammer Sevil Alekberova:
Here is the latest emial I got from Sevil. Anthony how many times does she have to put our names in her emails.
Hello my dearest Abel!
I want to say to you that as usual and usual, I'm ha ... read more
|
2008-10-12 22:40:21:
by anonymous
in Dating Scams
on Dating scammer Tiffany Taylor:
She changed her name
Look at this
Fred (10/12/2008 10:02:42 AM): Hi Linda.....are you there?
Fred (10/12/2008 10:06:27 AM): What name do you do by on AM?
linda.steven (10/12/2008 ... read more
|
2008-10-12 22:31:13:
by anonymous
in Male Dating Scammers
on Dating scammer Dennis McCuen:
Rape Hotline 713-528-RAPE Teen sexual assault survivor group for females 13-17 years old. The group provides education and peer support.
|
2008-10-12 22:02:32:
by [hidden]
in Other Scams
on The UK NATIONAL LOTTERY scam:
bueno tambien he recibido uno si,ilar quede en claro que es falso
|
|