how to make computer shutdown in C?which header do i have to include?
jan1024188 7 Posting Whiz in Training
Recommended Answers
Jump to PostYou need the windows header.
int main() { HANDLE hToken; TOKEN_PRIVILEGES tkp; if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if(AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0)) { ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF|EWX_FORCE,0); } } }
Jump to PostMS-Windows -- InitiateSystemShutdown()
Jump to Postlol....he was just pressing enter
So can you give me source?
Don't you ever read the posts to your thread? :eek: I already gave you the win32 api function call for MS-Windows os. Just click the link I posted and you will get everything you need to know about that …
Jump to PostHeh..I knew that, just wanted to tell you that it is not a normal way of reading posts and many members will get confused...;)
BTW have fixed the code so that it can be read by each and every person.
Appears we need to have Ms. Dani add a new …
Jump to Postunless of course you #include "im133e7hax0r.h" :)
All 19 Replies

iamthwee
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
jan1024188 7 Posting Whiz in Training

iamthwee
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
jan1024188 7 Posting Whiz in Training
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

iamthwee
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

iamthwee
Ancient Dragon commented: stop that silly madness -2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Bench 212 Posting Pro
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
John A 1,896 Vampirical Lurker Team Colleague
jwenting 1,905 duckman Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.