Click here to Skip to main content
15,901,958 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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;
}
GeneralEnumerating ODBC drivers... Pin
dandy721-Jun-05 8:25
dandy721-Jun-05 8:25 
GeneralRe: Enumerating ODBC drivers... Pin
trelliot1-Jun-05 22:13
trelliot1-Jun-05 22:13 
GeneralRe: Enumerating ODBC drivers... Pin
dandy722-Jun-05 3:18
dandy722-Jun-05 3:18 
QuestionTooltip without hwnd? Pin
Anonymous1-Jun-05 8:21
Anonymous1-Jun-05 8:21 
AnswerRe: Tooltip without hwnd? Pin
Christian Graus1-Jun-05 13:13
protectorChristian Graus1-Jun-05 13:13 
Generalpostmessage windclass Pin
pc_dev1-Jun-05 7:03
pc_dev1-Jun-05 7:03 
GeneralRe: postmessage windclass Pin
S. Senthil Kumar1-Jun-05 8:28
S. Senthil Kumar1-Jun-05 8:28 
GeneralRe: postmessage windclass Pin
racenjason1-Jun-05 12:01
professionalracenjason1-Jun-05 12:01 
GeneralRe: postmessage windclass Pin
ThatsAlok1-Jun-05 18:25
ThatsAlok1-Jun-05 18:25 
GeneralChange File's Accessed Time Pin
RedDragon2k1-Jun-05 7:02
RedDragon2k1-Jun-05 7:02 
GeneralRe: Change File's Accessed Time Pin
Toni781-Jun-05 8:24
Toni781-Jun-05 8:24 
GeneralHDC and CStatic control question Pin
Steve Messer1-Jun-05 6:54
Steve Messer1-Jun-05 6:54 
GeneralRe: HDC and CStatic control question Pin
David Crow1-Jun-05 7:02
David Crow1-Jun-05 7:02 
GeneralRe: HDC and CStatic control question Pin
Steve Messer1-Jun-05 7:10
Steve Messer1-Jun-05 7:10 
GeneralRe: HDC and CStatic control question Pin
David Crow1-Jun-05 7:30
David Crow1-Jun-05 7:30 
GeneralRe: HDC and CStatic control question Pin
Steve Messer1-Jun-05 7:38
Steve Messer1-Jun-05 7:38 
GeneralRe: HDC and CStatic control question Pin
Ryan Binns1-Jun-05 18:25
Ryan Binns1-Jun-05 18:25 

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.