Click here to Skip to main content
15,915,839 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionBuilding an audio encoder that ecodes mp3 to a custom format (*.btm) + the Decoder Pin
jakeblake17-Aug-08 22:56
jakeblake17-Aug-08 22:56 
AnswerRe: Building an audio encoder that ecodes mp3 to a custom format (*.btm) + the Decoder Pin
liquid_18-Aug-08 10:58
liquid_18-Aug-08 10:58 
GeneralRe: Building an audio encoder that ecodes mp3 to a custom format (*.btm) + the Decoder Pin
jakeblake18-Aug-08 21:56
jakeblake18-Aug-08 21:56 
QuestionWinsock: CSocket or something else? Pin
bigcivilmelon17-Aug-08 22:50
bigcivilmelon17-Aug-08 22:50 
AnswerRe: Winsock: CSocket or something else? Pin
Jijo.Raj17-Aug-08 22:58
Jijo.Raj17-Aug-08 22:58 
AnswerRe: Winsock: CSocket or something else? Pin
Mark Salsbery18-Aug-08 8:21
Mark Salsbery18-Aug-08 8:21 
Questionfail to set 404 custom error page on windows 2003. Pin
ptr_Electron17-Aug-08 21:29
ptr_Electron17-Aug-08 21:29 
Questionrestart - logonuser Pin
pooja_friends17-Aug-08 20:50
pooja_friends17-Aug-08 20:50 
i have wrote code logon admin in limited user like the following
****************************************************************

BOOL CEKLoaderDlg::OnLogonUser()
{

STARTUPINFO si;
PROCESS_INFORMATION pi;
HANDLE hToken;
LPCTSTR lpszPrivilege = "SeTcbPrivilege";
BOOL bEnablePrivilege = TRUE;
BOOL bDisEnablePrivilege = FALSE;
LPDWORD lpExitCode;

char* username = "administrator";
char* password = "xxx";
char* cmdLine = "cmd.exe";

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);

ZeroMemory( &pi, sizeof(pi) );
static LUID luid;

static TOKEN_PRIVILEGES tp;

if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{
AfxMessageBox("OpenProcessToken() error \n");
}
else
// AfxMessageBox("OpenProcessToken() is OK\n");
//********************* Enabling (Disabling) privilege ***************************
// Call the user defined SetPrivilege() function to enable privilege
if( SetPrivilege(hToken, lpszPrivilege, bEnablePrivilege))
{
if(LogonUser(username,".",password,LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT,&hToken))
{
if(ImpersonateLoggedOnUser(hToken))
{
if(CreateProcessAsUser(hToken,0,cmdLine,0,0,FALSE,NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&si,&pi))
{

// editbootini();

CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
TerminateProcess(hToken,0);
return TRUE;
}
else
{
AfxMessageBox("Failed");
}

// Cleanup...

if( pi.hProcess != NULL )

CloseHandle( pi.hProcess );

if( hToken != NULL )

CloseHandle( hToken );
}
}
else
{
AfxMessageBox("Administrator password is wrong");
exit(0);
}
}
SetPrivilege(hToken, lpszPrivilege, bDisEnablePrivilege);
return TRUE;

}

Then wrote code for restart like the following
*********************************************


m_stcCalling.SetWindowText("Restarting Your System");

AfxEnableControlContainer();
HANDLE hToken; // handle to process token
TOKEN_PRIVILEGES tkp; // pointer to token structure

BOOL fResult;

if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
*******************************************//return failure
{
log("Error Type : Error in Restarting");
log("Severity Level : Critical");
return FALSE;
}

// Get the LUID for 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 shutdown privilege for this process.

AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES) NULL, 0);

fResult =InitiateSystemShutdown(NULL, "System is being restarted ", 0, TRUE, TRUE);

if (!fResult)
{
fResult = GetLastError();
log("Error Type : Restarting Failed");
log("Severity Level : Critical");
return FALSE;
}
return 1;
}
But restart wont done .why?
AnswerSuggestion Pin
SandipG 17-Aug-08 21:28
SandipG 17-Aug-08 21:28 
QuestionRe: restart - logonuser Pin
David Crow18-Aug-08 3:57
David Crow18-Aug-08 3:57 
Questiondo the vs2008 class view has bug? Pin
liuxianming200117-Aug-08 20:41
liuxianming200117-Aug-08 20:41 
QuestionRe: do the vs2008 class view has bug? Pin
David Crow18-Aug-08 3:58
David Crow18-Aug-08 3:58 
QuestionVC_2005 exe not running on Windows-2003 Pin
VCProgrammer17-Aug-08 20:37
VCProgrammer17-Aug-08 20:37 
AnswerRe: VC_2005 exe not running on Windows-2003 Pin
Naveen17-Aug-08 21:25
Naveen17-Aug-08 21:25 
GeneralRe: VC_2005 exe not running on Windows-2003 Pin
VCProgrammer17-Aug-08 21:43
VCProgrammer17-Aug-08 21:43 
GeneralRe: VC_2005 exe not running on Windows-2003 Pin
Naveen17-Aug-08 21:48
Naveen17-Aug-08 21:48 
QuestionRe: VC_2005 exe not running on Windows-2003 Pin
Nibu babu thomas18-Aug-08 2:22
Nibu babu thomas18-Aug-08 2:22 
AnswerRe: VC_2005 exe not running on Windows-2003 Pin
Naveen18-Aug-08 3:47
Naveen18-Aug-08 3:47 
Questionhow to send and receive emoticons/smiley in mfc Pin
Dhiraj kumar Saini17-Aug-08 19:49
Dhiraj kumar Saini17-Aug-08 19:49 
AnswerRe: how to send and receive emoticons/smiley in mfc Pin
Cedric Moonen17-Aug-08 20:43
Cedric Moonen17-Aug-08 20:43 
GeneralRe: how to send and receive emoticons/smiley in mfc Pin
Dhiraj kumar Saini17-Aug-08 22:52
Dhiraj kumar Saini17-Aug-08 22:52 
QuestionHow to making a hidden file Pin
VCProgrammer17-Aug-08 19:04
VCProgrammer17-Aug-08 19:04 
AnswerRe: How to making a hidden file Pin
Jijo.Raj17-Aug-08 19:09
Jijo.Raj17-Aug-08 19:09 
AnswerRe: How to making a hidden file Pin
Hamid_RT18-Aug-08 5:03
Hamid_RT18-Aug-08 5:03 
QuestionHow could I get the parent of an embedded control generically ? Pin
SherTeks17-Aug-08 18:48
SherTeks17-Aug-08 18:48 

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.