Click here to Skip to main content
15,913,283 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Connection to MS Access Database Pin
David Crow2-Nov-04 8:04
David Crow2-Nov-04 8:04 
GeneralRe: Connection to MS Access Database Pin
WinAPILearner2-Nov-04 10:09
WinAPILearner2-Nov-04 10:09 
GeneralRe: Connection to MS Access Database Pin
David Crow2-Nov-04 10:24
David Crow2-Nov-04 10:24 
GeneralRe: Connection to MS Access Database Pin
WinAPILearner2-Nov-04 20:12
WinAPILearner2-Nov-04 20:12 
GeneralRe: Connection to MS Access Database Pin
David Crow3-Nov-04 2:31
David Crow3-Nov-04 2:31 
GeneralRe: Connection to MS Access Database Pin
WinAPILearner3-Nov-04 7:42
WinAPILearner3-Nov-04 7:42 
GeneralRe: Connection to MS Access Database Pin
David Crow3-Nov-04 9:41
David Crow3-Nov-04 9:41 
GeneralConsole Threading Problem Pin
Joe_Sextus31-Oct-04 7:36
Joe_Sextus31-Oct-04 7:36 
I am writing a program that runs another program and prints the second program's output in first's console, but the second program's output is printed before output in the first program.

Here's my code
<br />
#include <windows.h><br />
#include <tchar.h><br />
#include <iostream.h><br />
<br />
void main(void)<br />
{<br />
  PROCESS_INFORMATION pi;<br />
  STARTUPINFO si;<br />
<br />
  ZeroMemory(&si,sizeof(STARTUPINFO));<br />
  si.cb = sizeof(STARTUPINFO);<br />
<br />
  cout << _T("Starting ver...\n");<br />
  <br />
  if(CreateProcess(NULL, _T("cmd /c ver"), NULL, NULL,<br />
                   TRUE, 0, NULL, NULL, &si, &pi))<br />
  {    <br />
    DWORD ExitCode = 0;<br />
    DWORD ErrorCode = 0;<br />
    <br />
    do<br />
    {<br />
      Sleep(100);<br />
      if(GetExitCodeProcess(pi.hProcess, &ExitCode) == 0)<br />
      {<br />
        cout << _T("GetExitCodeProcess Error: ");<br />
        cout << GetLastError() << endl;<br />
      }<br />
    }while(ExitCode == STILL_ACTIVE);<br />
    <br />
    CloseHandle(pi.hThread);<br />
  }  <br />
  cout << _T("Finsihed with ver\n");<br />
} //void main(void)<br />


and here is the program output
Microsoft Windows XP [Version 5.1.2600]
Starting ver...
Finsihed with ver


The program should output "Starting ver..." before it runs version. The output doen't change if I use printf instead of cout either.

Does anybody know of a solution? It has me stumped.

Thanks in advance.
-Joe
GeneralRe: Console Threading Problem Pin
Ryan Binns31-Oct-04 17:57
Ryan Binns31-Oct-04 17:57 
GeneralRe: Console Threading Problem Pin
Joe_Sextus31-Oct-04 18:31
Joe_Sextus31-Oct-04 18:31 
GeneralRe: Operating System for Developers Pin
Christian Graus31-Oct-04 9:07
protectorChristian Graus31-Oct-04 9:07 
QuestionHow to hook system API under windows 9x? Pin
jedyking31-Oct-04 6:36
jedyking31-Oct-04 6:36 
AnswerRe: How to hook system API under windows 9x? Pin
User 665831-Oct-04 8:25
User 665831-Oct-04 8:25 
GeneralRe: How to hook system API under windows 9x? Pin
jedyking1-Nov-04 5:28
jedyking1-Nov-04 5:28 
AnswerRe: How to hook system API under windows 9x? Pin
ThatsAlok31-Oct-04 17:29
ThatsAlok31-Oct-04 17:29 
GeneralRe: How to hook system API under windows 9x? Pin
jedyking1-Nov-04 5:27
jedyking1-Nov-04 5:27 
GeneralTAPI givin link error Pin
asif m@hmood31-Oct-04 5:46
asif m@hmood31-Oct-04 5:46 
GeneralRe: TAPI givin link error Pin
Michael P Butler31-Oct-04 6:18
Michael P Butler31-Oct-04 6:18 
Questionhow to enable... Pin
Natural_Demon31-Oct-04 4:19
Natural_Demon31-Oct-04 4:19 
Generalpassin a variable from another class Pin
Natural_Demon31-Oct-04 4:13
Natural_Demon31-Oct-04 4:13 
GeneralRe: passin a variable from another class Pin
Christian Graus31-Oct-04 9:05
protectorChristian Graus31-Oct-04 9:05 
GeneralRe: passin a variable from another class Pin
Natural_Demon31-Oct-04 10:10
Natural_Demon31-Oct-04 10:10 
GeneralRe: passin a variable from another class Pin
Christian Graus31-Oct-04 10:14
protectorChristian Graus31-Oct-04 10:14 
GeneralRe: passin a variable from another class Pin
Natural_Demon31-Oct-04 10:16
Natural_Demon31-Oct-04 10:16 
GeneralRe: passin a variable from another class Pin
Christian Graus31-Oct-04 10:20
protectorChristian Graus31-Oct-04 10:20 

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.