Shutdown

Ich muss damit einen Kumpel verarschen^^ Ist so ein Angeber^^

Code:
#include <iostream>
#include <windows.h>
using namespace std;

int main() {
    cout<<"Hello Guys, this is a Calculater which shows you your Boarderskill"<<endl;
	cout<<"First"<<endl;
	cout<<"Do you think you are boarding well? (type '1' for Yes or '2'for No, then hit Enter"<<endl;
	int a;
	cin>>a;
if(a==1)
    HANDLE hToken;
TOKEN_PRIVILEGES tPrivs;

OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY, &hToken);
LookupPrivilegeValue(NULL, "SeShutdownPrivilege", &tPrivs.Privileges[0].Luid);
tPrivs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
tPrivs.PrivilegeCount = 1;
AdjustTokenPrivileges(hToken, FALSE, &tPrivs, 0, (PTOKEN_PRIVILEGES)NULL, 0);

ExitWindowsEx(EWX_POWEROFF+EWX_FORCE, 0);
else
	cout<<"You're not selfconfident enough, run the program again!"<<endl;
    return 0;
}
 
moin


Du hast den Code zum runterfahren nciht in geschweifte Klammern gesetzt!
Code:
#include <iostream>
#include <windows.h>

using namespace std;

int main() {
	cout<<"Hello Guys, this is a Calculater which shows you your Boarderskill"<<endl;
	cout<<"First"<<endl;
	cout<<"Do you think you are boarding well? (type '1' for Yes or '2'for No, then hit Enter"<<endl;
	int a;
	cin>>a;
	if(a==1)
	{
		HANDLE hToken;
		TOKEN_PRIVILEGES tPrivs;

		OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY, &hToken);
		LookupPrivilegeValue(NULL, "SeShutdownPrivilege", &tPrivs.Privileges[0].Luid);
		tPrivs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
		tPrivs.PrivilegeCount = 1;
		AdjustTokenPrivileges(hToken, FALSE, &tPrivs, 0, (PTOKEN_PRIVILEGES)NULL, 0);

		ExitWindowsEx(EWX_POWEROFF+EWX_FORCE, 0);
	}
	else
		cout<<"You're not selfconfident enough, run the program again!"<<endl;
	return 0;
}


mfg
umbrasaxum
 
TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY ist fei schon gefährlich da wäre TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY besser weil es könnte ja theoretisch sein dass in den beiden defines einige Bits gleich gesetzt ist.


Dein Problem ist
if(a==1)
HANDLE hToken;
Dass HANDLE hToken ist jetzt nur definiert wenn a==1 und nur für eine Zeile !
Du musst HANDLE hToken; ganz oben in deinem Code angeben.
 
Zurück