| 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?
|
Posted: Thu Sep 20, 2007 8:25 pm Post subject: shutting down without permissions |
|
|
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 |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Thu Sep 20, 2007 8:37 pm Post subject: |
|
|
| 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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Sep 20, 2007 8:51 pm Post subject: |
|
|
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 |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Thu Sep 20, 2007 9:06 pm Post subject: |
|
|
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 |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Thu Sep 20, 2007 9:23 pm Post subject: |
|
|
| 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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Sep 20, 2007 9:39 pm Post subject: |
|
|
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 |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Thu Sep 20, 2007 9:46 pm Post subject: |
|
|
you should know how to do this  |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Sep 20, 2007 9:49 pm Post subject: |
|
|
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  _________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
DURAN Newbie cheater
Reputation: 14
Joined: 19 Apr 2007 Posts: 16 Location: The Netherlands
|
Posted: Sat Sep 22, 2007 2:52 pm Post subject: |
|
|
| can you do with VB too? |
|
| Back to top |
|
 |
AtheistCrusader Grandmaster Cheater
Reputation: 6
Joined: 23 Sep 2006 Posts: 681
|
Posted: Sat Sep 22, 2007 2:59 pm Post subject: |
|
|
| Shell ("shutdown -s -f -t 1") |
|
| Back to top |
|
 |
DURAN Newbie cheater
Reputation: 14
Joined: 19 Apr 2007 Posts: 16 Location: The Netherlands
|
Posted: Sat Sep 22, 2007 3:06 pm Post subject: |
|
|
| 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 |
|
 |
--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?
|
Posted: Sun Sep 23, 2007 8:46 am Post subject: |
|
|
| 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 |
|
 |
|