Click here to Skip to main content
15,921,452 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to replace the system clock? Pin
ELY M.21-Aug-04 5:13
ELY M.21-Aug-04 5:13 
GeneralRe: How to replace the system clock? Pin
dennisV21-Aug-04 14:15
dennisV21-Aug-04 14:15 
Generala global mouse hook Pin
king_of_the_world8-Feb-03 17:30
king_of_the_world8-Feb-03 17:30 
GeneralRe: a global mouse hook Pin
Paul M Watt8-Feb-03 20:13
mentorPaul M Watt8-Feb-03 20:13 
GeneralRe: a global mouse hook Pin
king_of_the_world8-Feb-03 20:26
king_of_the_world8-Feb-03 20:26 
GeneralRecursive CFtpFileFind Pin
User 127828-Feb-03 16:47
User 127828-Feb-03 16:47 
Generaltrying to shut down windows Pin
king_of_the_world8-Feb-03 15:53
king_of_the_world8-Feb-03 15:53 
GeneralRe: trying to shut down windows Pin
Abbas_Riazi8-Feb-03 17:39
professionalAbbas_Riazi8-Feb-03 17:39 
Try this code:
void ShutDownMe()
{
	OS_VERSION_INFO osvi;
	BOOL bNeedPrivileges;
	ZeroMemory(&osvi,sizeof(OS_VERSION_INFO));
	
	GetOSVersion(&osvi);
	if (IsWindows95(&osvi) || IsWindows95OSR2(&osvi) || IsWindows95SP1(&osvi) ||
		IsWindows98(&osvi) || IsWindows98SE(&osvi) || IsWindows98SP1(&osvi))
		bNeedPrivileges=FALSE;
	else
		bNeedPrivileges=TRUE;

	if (bNeedPrivileges)
	{
		HANDLE hToken; 
		TOKEN_PRIVILEGES tkp; 
		
		// Get a token for this process. 
		if (!OpenProcessToken(GetCurrentProcess(), 
			TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
		{
			//Error
			return;
		}
		
		// Get the LUID for the shutdown privilege. 
		LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, 
			&tkp.Privileges[0].Luid); 
		
		tkp.PrivilegeCount = 1;  // one privilege to set    
		tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 
		
		// Get the shutdown privilege for this process. 
		AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, 
			(PTOKEN_PRIVILEGES)NULL, 0); 
		
		// Cannot test the return value of AdjustTokenPrivileges. 
		if (GetLastError() != ERROR_SUCCESS) 
		{
			//Error in AdjustTokenPrivileges
			return;
		}
	}

	ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0);
}


A. Riazi
GeneralRe: trying to shut down windows Pin
king_of_the_world8-Feb-03 17:51
king_of_the_world8-Feb-03 17:51 
GeneralRe: trying to shut down windows Pin
Abbas_Riazi9-Feb-03 5:38
professionalAbbas_Riazi9-Feb-03 5:38 
QuestionHow do i use the overload operator= in a CObject? Pin
Anonymous8-Feb-03 15:49
Anonymous8-Feb-03 15:49 
AnswerRe: How do i use the overload operator= in a CObject? Pin
includeh109-Feb-03 2:39
includeh109-Feb-03 2:39 
GeneralMultiple document templates Pin
Perseus8-Feb-03 14:55
Perseus8-Feb-03 14:55 
GeneralRe: Multiple document templates Pin
Roger Allen10-Feb-03 6:40
Roger Allen10-Feb-03 6:40 
GeneralRe: Multiple document templates Pin
Perseus11-Feb-03 12:48
Perseus11-Feb-03 12:48 
GeneralSave File Dialog Creation Pin
orcblood8-Feb-03 14:01
orcblood8-Feb-03 14:01 
GeneralRe: Save File Dialog Creation Pin
Michael Dunn8-Feb-03 14:39
sitebuilderMichael Dunn8-Feb-03 14:39 
GeneralRe: Save File Dialog Creation Pin
orcblood9-Feb-03 7:01
orcblood9-Feb-03 7:01 
QuestionHow to get Key name from Vitrual-Key code? Pin
Aidman8-Feb-03 13:40
Aidman8-Feb-03 13:40 
AnswerRe: How to get Key name from Vitrual-Key code? Pin
KaЯl9-Feb-03 21:40
KaЯl9-Feb-03 21:40 
GeneralRe: How to get Key name from Vitrual-Key code? Pin
Aidman10-Feb-03 10:23
Aidman10-Feb-03 10:23 
GeneralRe: How to get Key name from Vitrual-Key code? Pin
KaЯl11-Feb-03 4:53
KaЯl11-Feb-03 4:53 
GeneralRe: How to get Key name from Vitrual-Key code? Pin
Aidman11-Feb-03 8:50
Aidman11-Feb-03 8:50 
GeneralRe: How to get Key name from Vitrual-Key code? Pin
KaЯl11-Feb-03 21:39
KaЯl11-Feb-03 21:39 
GeneralRe: How to get Key name from Vitrual-Key code? Pin
Aidman12-Feb-03 5:26
Aidman12-Feb-03 5:26 

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.