Click here to Skip to main content
15,893,381 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAVI & BMP Pin
28-Sep-01 12:26
suss28-Sep-01 12:26 
GeneralMSVCRT... Pin
28-Sep-01 11:51
suss28-Sep-01 11:51 
GeneralRe: MSVCRT... Pin
Walter Sullivan28-Sep-01 14:05
Walter Sullivan28-Sep-01 14:05 
GeneralRe: MSVCRT... Pin
28-Sep-01 14:37
suss28-Sep-01 14:37 
Generalkeybd_event Pin
Mustafa Demirhan28-Sep-01 10:12
Mustafa Demirhan28-Sep-01 10:12 
GeneralRe: keybd_event Pin
Paolo Messina29-Sep-01 0:24
professionalPaolo Messina29-Sep-01 0:24 
GeneralWake the computer from standby Pin
Mustafa Demirhan28-Sep-01 10:09
Mustafa Demirhan28-Sep-01 10:09 
GeneralExitWindowsEx Problem!! Pin
Mustafa Demirhan28-Sep-01 10:04
Mustafa Demirhan28-Sep-01 10:04 
Hi,

In one of my programs, I am trying to shutdown windows. The following code works well under W2k but it does not work under WinME/9x. It starts the shutdown process, it closes all windows and then hides the taskbar but then it stops.

Please help. Is there any problems with the code?

PS. The reboot operation works well.

<br />
int CTaskStep::ExecuteShutDown ( CTaskObject *pTask , bool bReboot)<br />
{<br />
	HANDLE hProcess = GetCurrentProcess(); // Is pseudohandle, no close needed <br />
	HANDLE hToken = NULL;<br />
	OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken);<br />
	if ( hToken ) <br />
	{<br />
		TOKEN_PRIVILEGES priv_struct;<br />
		LUID_AND_ATTRIBUTES priv;<br />
		LUID priv_luid;<br />
		BOOL bRet;<br />
		bRet = LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &priv_luid);<br />
		priv.Attributes = SE_PRIVILEGE_ENABLED;<br />
		priv.Luid = priv_luid;<br />
		priv_struct.PrivilegeCount = 1;<br />
		priv_struct.Privileges->Attributes = SE_PRIVILEGE_ENABLED;<br />
		priv_struct.Privileges->Luid = priv_luid;<br />
		bRet = AdjustTokenPrivileges(hToken, FALSE, &priv_struct,NULL,NULL, NULL);<br />
		CloseHandle( hToken );<br />
	}<br />
	if ( bReboot )<br />
	{<br />
		if(!ExitWindowsEx (EWX_REBOOT | EWX_FORCE,0) )<br />
			return MSG_FAILED;<br />
	}<br />
	else<br />
	{<br />
		if(!ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCE, 0))<br />
			return MSG_FAILED;<br />
	}<br />
	return EX_CONTINUE;<br />
}<br />


Kind regards
Mustafa Demirhan
GeneralCWebBrowser2 - problems with windows 98 and IE 5.5 Pin
28-Sep-01 8:36
suss28-Sep-01 8:36 
GeneralRe: CWebBrowser2 - problems with windows 98 and IE 5.5 Pin
Masaaki Onishi28-Sep-01 9:29
Masaaki Onishi28-Sep-01 9:29 
GeneralGetting a pointer to frame window Pin
Erik Hammar28-Sep-01 7:23
Erik Hammar28-Sep-01 7:23 
GeneralRe: Getting a pointer to frame window Pin
Michael Dunn28-Sep-01 7:54
sitebuilderMichael Dunn28-Sep-01 7:54 
GeneralRe: Getting a pointer to frame window Pin
Erik Hammar29-Sep-01 1:05
Erik Hammar29-Sep-01 1:05 
GeneralDLL and ATLTRACE question Pin
28-Sep-01 6:59
suss28-Sep-01 6:59 
GeneralRe: DLL and ATLTRACE question Pin
Not Active28-Sep-01 7:15
mentorNot Active28-Sep-01 7:15 
GeneralFunction with variable number of argument Pin
28-Sep-01 6:42
suss28-Sep-01 6:42 
GeneralRe: Function with variable number of argument Pin
Chris Losinger28-Sep-01 6:49
professionalChris Losinger28-Sep-01 6:49 
GeneralRe: Function with variable number of argument Pin
28-Sep-01 7:50
suss28-Sep-01 7:50 
QuestionHow to get the desktop background image ? Pin
28-Sep-01 6:38
suss28-Sep-01 6:38 
QuestionHow can add buttons in a win32 applicatios? Pin
Bart-Man28-Sep-01 6:07
Bart-Man28-Sep-01 6:07 
AnswerRe: How can add buttons in a win32 applicatios? Pin
Erik Hammar28-Sep-01 7:38
Erik Hammar28-Sep-01 7:38 
GeneralBasic question Pin
MolleX28-Sep-01 4:37
MolleX28-Sep-01 4:37 
GeneralRe: Basic question Pin
Mukkie1-Oct-01 6:02
Mukkie1-Oct-01 6:02 
QuestionHow to detect return key in a CListControl? Pin
Ricardo Beja28-Sep-01 4:33
Ricardo Beja28-Sep-01 4:33 
AnswerRe: How to detect return key in a CListControl? Pin
Paolo Messina29-Sep-01 2:58
professionalPaolo Messina29-Sep-01 2:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.