You 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);
        }
    }
}

I don't have a Unix system, but try this and tell me whether it works:

#include <stdlib.h>

int main( )
{
    system( "shutdown" ) ;
    return 0 ;
}

For references see here and here.

lol....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 function. include <windows.h> to use it.

Check my post again please.

It still looks blank in my browser window. Maybe someone needs to edit your post...

Heh..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.

Heh..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 category to the Rules thread -- do not make hidden posts. I don't know how he did it, but than you ~S.O.S~ for fixing it up. :)

I guess he used the [COLOUR=WHITE] tag.. I'm not sure why Daniweb even has this, since AFAIK, its not possible to change the background of posts (Probably a good thing...)

I imagine a few other colours on that chart would be pretty nasty to read aswell... Maybe that rule should be "No unreadable colours" :)

I guess he used the [COLOUR=WHITE] tag.. I'm not sure why Daniweb even has this, since AFAIK, its not possible to change the background of posts (Probably a good thing...)

Yeah, I think he used the color white for posting, but don't know why play this prank...:(

Appears we need to have Ms. Dani add a new category to the Rules thread -- do not make hidden posts. I don't know how he did it, but thank you ~S.O.S~ for fixing it up.

Yes it is a good idea to let Miss Dani know of it.

I guess he used the [COLOUR=WHITE] tag.. I'm not sure why Daniweb even has this, since AFAIK, its not possible to change the background of posts (Probably a good thing...)

I imagine a few other colours on that chart would be pretty nasty to read aswell... Maybe that rule should be "No unreadable colours" :)

Haha, this used to happen a lot at Cprogramming. We often hid little messages in our post while it contained useful information, so it didn't look suspecting. The background wasn't white, so we looked in the CSS to retrieve the HTML color, and then used this to make parts of the post invisible. Finally the mods got mad at us, and we had to stop. :D

The only time white is visible is when it's within another kind of tag:

this is some white

I don't have a Unix system, but try this and tell me whether it works:

Your code usually won't work. Most Unix-based systems require you to use shutdown now or shutdown -t [I]seconds till shutdown[/I] . And even with the correct syntax, shutdown is only made possible if the program is run with root privilages.

Your code usually won't work. Most Unix-based systems require you to use shutdown now or shutdown -t [I]seconds till shutdown[/I] . And even with the correct syntax, shutdown is only made possible if the program is run with root privilages.

I guess, you forgot to click on the links which I included with that post, which explains in detail the syntax of "shutdown" along with its usage. ;)

This article has been dead for over six months. Start a new discussion instead.