Click here to Skip to main content
15,926,174 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: PostMessage causing hang... Pin
Nilesh K.1-Jun-05 17:31
Nilesh K.1-Jun-05 17:31 
GeneralRe: PostMessage causing hang... Pin
ThatsAlok1-Jun-05 18:38
ThatsAlok1-Jun-05 18:38 
GeneralRe: PostMessage causing hang... Pin
Nilesh K.1-Jun-05 19:15
Nilesh K.1-Jun-05 19:15 
GeneralRe: PostMessage causing hang... Pin
ThatsAlok1-Jun-05 19:19
ThatsAlok1-Jun-05 19:19 
GeneralRe: PostMessage causing hang... Pin
S. Senthil Kumar2-Jun-05 0:02
S. Senthil Kumar2-Jun-05 0:02 
GeneralRe: PostMessage causing hang... Pin
S. Senthil Kumar1-Jun-05 23:57
S. Senthil Kumar1-Jun-05 23:57 
GeneralDynamically updating property sheets or formviews Pin
connere241-Jun-05 15:29
connere241-Jun-05 15:29 
Questionhow to cancel the closing of an application Pin
elephantstar1-Jun-05 13:38
elephantstar1-Jun-05 13:38 
AnswerRe: how to cancel the closing of an application Pin
Christian Graus1-Jun-05 13:47
protectorChristian Graus1-Jun-05 13:47 
AnswerRe: how to cancel the closing of an application Pin
Stlan1-Jun-05 19:55
Stlan1-Jun-05 19:55 
GeneralMS Access and MFC Pin
Tom Wright1-Jun-05 12:03
Tom Wright1-Jun-05 12:03 
GeneralRe: MS Access and MFC Pin
Michael P Butler1-Jun-05 12:38
Michael P Butler1-Jun-05 12:38 
Question::myFunc ? Pin
Anonymous1-Jun-05 10:03
Anonymous1-Jun-05 10:03 
AnswerRe: ::myFunc ? Pin
Roland Pibinger1-Jun-05 10:09
Roland Pibinger1-Jun-05 10:09 
AnswerRe: ::myFunc ? Pin
Nilesh K.1-Jun-05 17:47
Nilesh K.1-Jun-05 17:47 
AnswerRe: ::myFunc ? Pin
toxcct1-Jun-05 21:08
toxcct1-Jun-05 21:08 
GeneralRe: ::myFunc ? Pin
trelliot3-Jun-05 20:45
trelliot3-Jun-05 20:45 
GeneralExecuting a program from within mine Pin
Anonymous1-Jun-05 9:23
Anonymous1-Jun-05 9:23 
GeneralRe: Executing a program from within mine Pin
ddmcr1-Jun-05 9:35
ddmcr1-Jun-05 9:35 
GeneralRe: Executing a program from within mine Pin
Anonymous1-Jun-05 9:47
Anonymous1-Jun-05 9:47 
GeneralRe: Executing a program from within mine Pin
Wes Aday1-Jun-05 9:55
professionalWes Aday1-Jun-05 9:55 
GeneralRe: Executing a program from within mine Pin
ThatsAlok1-Jun-05 18:31
ThatsAlok1-Jun-05 18:31 
GeneralRe: Executing a program from within mine Pin
Miszou1-Jun-05 10:01
Miszou1-Jun-05 10:01 
GeneralRe: Executing a program from within mine Pin
racenjason1-Jun-05 11:47
professionalracenjason1-Jun-05 11:47 
GeneralRe: Executing a program from within mine Pin
trelliot1-Jun-05 22:01
trelliot1-Jun-05 22:01 
// Here's a start:

// Run an external command, optionally waiting around
// for it to finish.
bool RunProgram(LPCTSTR progName, LPCTSTR args,
bool wait /*=false*/, int show /*=SW_SHOWNORMAL*/,
)
{
CString commandLine, userName;
PROCESS_INFORMATION procInfo;
STARTUPINFO startInfo;

memset(&startInfo, 0, sizeof(startInfo));
startInfo.cb = sizeof(startInfo);
startInfo.wShowWindow = (WORD)show;
startInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_FORCEONFEEDBACK;

try
{
// remove leading and trailing spaces
// Trim() is left as an excercise for the reader
commandLine = Trim(progName);
// If there's a space and no double quotes,
// surround the command with double quotes
if (commandLine.Find(' ') >= 0 && commandLine.Find('"') < 0)
commandLine = '"' + commandLine + '"';

commandLine += ' ';
commandLine += args;

LPTSTR lpCommandLine = commandLine.GetBuffer(CommandLine.GetLength() + 32);
if (!CreateProcess(NULL, lpCommandLine, NULL, NULL,
FALSE, 0, NULL, NULL, &startInfo, &procInfo))
return false;

if (wait)
WaitForSingleObject(procInfo.hProcess, INFINITE);

CloseHandle(procInfo.hThread);
CloseHandle(procInfo.hProcess);
}
catch(CMemoryException *)
{
return false;
}

return true;
}

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.