Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


shutting down without permissions

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Sep 20, 2007 8:25 pm    Post subject: shutting down without permissions Reply with quote

Have you ever tried shutting down in command prompt and if you have programs running it asks if you want to end these programs, is there anyway to make those windows not open and just shutdown? C++ btw
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Thu Sep 20, 2007 8:37 pm    Post subject: Reply with quote

The reason those windows pop up is because programs respond to the WM_QUERYENDSESSION message which is supposed to give program authors the ability to clean up resources, save important files, etc. That's a good thing. I don't know if you're using an API (because all of the available ones give you that option) or if you're using shutdown.exe and think it is some sort of internal shell command, not a program in itself. There are parameters you can pass to force a shutdown for that, too. Explain why you want an immediate shutdown.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Sep 20, 2007 8:51 pm    Post subject: Reply with quote

Hmmm, oh just to make it easy on my computer instead of going to start>shutdown>shutdown. Plus I can use enso and just learn as open shutdown then do open shutdown and boom im done. Can I have some code though?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Thu Sep 20, 2007 9:06 pm    Post subject: Reply with quote

hmm i think uzeil released soemthing that appal made that was a 16 bit PE file that shut down instantaneiously. and omg i cant spell today...
_________________
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Thu Sep 20, 2007 9:23 pm    Post subject: Reply with quote

Code:

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

BOOL GetPrivilege(LPCTSTR Privilege)
{
    TOKEN_PRIVILEGES tp; LUID luid;
    HANDLE hToken = 0; BOOL ok = FALSE;
   
    if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
        if (LookupPrivilegeValue(NULL, Privilege, &luid)) {
            tp.PrivilegeCount           = 1;
            tp.Privileges[0].Luid       = luid;
            tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
            ok = AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
        }
    }
   
    if (hToken) CloseHandle(hToken);   
    return ok;
}


int _tmain(int argc, _TCHAR* argv[])
{
    if (!GetPrivilege(SE_SHUTDOWN_NAME)) {
        _tprintf(TEXT("Unable to gain shutdown privilege. Last Error = %d\n"), GetLastError());
    } else {
        if (!ExitWindowsEx(EWX_POWEROFF, EWX_FORCE))
            _tprintf(TEXT("Unable to shutdown. Last Error = %d\n"), GetLastError()); 
    }     
           
    return EXIT_SUCCESS;
}
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Sep 20, 2007 9:39 pm    Post subject: Reply with quote

Uh...lets say I wanted to make this into a function? Just put the code in the function?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Thu Sep 20, 2007 9:46 pm    Post subject: Reply with quote

you should know how to do this Confused
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Sep 20, 2007 9:49 pm    Post subject: Reply with quote

haha yes, but i rly didnt look at code, and it looks like functions + idk if i cna put a function code in a function, w8 yes i can Razz
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
DURAN
Newbie cheater
Reputation: 14

Joined: 19 Apr 2007
Posts: 16
Location: The Netherlands

PostPosted: Sat Sep 22, 2007 2:52 pm    Post subject: Reply with quote

can you do with VB too?
Back to top
View user's profile Send private message
AtheistCrusader
Grandmaster Cheater
Reputation: 6

Joined: 23 Sep 2006
Posts: 681

PostPosted: Sat Sep 22, 2007 2:59 pm    Post subject: Reply with quote

Shell ("shutdown -s -f -t 1")
Back to top
View user's profile Send private message
DURAN
Newbie cheater
Reputation: 14

Joined: 19 Apr 2007
Posts: 16
Location: The Netherlands

PostPosted: Sat Sep 22, 2007 3:06 pm    Post subject: Reply with quote

masterkert3 wrote:
Shell ("shutdown -s -f -t 1")

i wanna put that on VB like this if i push the button the computer need to shutdown
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Sun Sep 23, 2007 8:46 am    Post subject: Reply with quote

oib111 wrote:
Uh...lets say I wanted to make this into a function? Just put the code in the function?

Clicky Clicky?

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites