CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Posts
    6

    Command.com & MFC

    How do I make a system call in Visual C++ (v6.0) to issue a "dos" command without the command window popping up ? I need to issue the dos command a # of times and don't want to create a process each time the call is made.

    Thanks in advance.


  2. #2
    Join Date
    Jul 1999
    Location
    Israel
    Posts
    1,793

    Re: Command.com & MFC

    what do you say about WinExec()???



  3. #3
    Join Date
    Aug 1999
    Posts
    6

    Re: Command.com & MFC

    Thanks for the response... I've tried to use WinExec() but it seems that every time the call is made (once every 30 secs), virtual memory gets chewed up.

    What I'm doing is issuing a dos command as a threaded process behind the UI and sending output
    to a file which is then parsed. The "dos" command is issued once every 30 secs. The flow is do dos command, parse file, wait 30 secs and repeat flow until user stops program by way of the UI.

    If you have any other ideas I'd be glad to know.
    Thanks.

    wlj


  4. #4
    Join Date
    Jul 1999
    Location
    Romania - Iasi
    Posts
    558

    Re: Command.com & MFC

    Did u try it CreateProcess function?
    If u do let me see the code

    Regards,
    Ovidiu


  5. #5
    Join Date
    Aug 1999
    Posts
    6

    Re: Command.com & MFC

    What I'm doing is issuing a dos command as a threaded process behind the UI and sending output
    to a file which is then parsed. The "dos" command is issued once every 30 secs. The flow is do dos command, parse file, wait 30 secs and repeat flow until user stops program by way of the UI.

    If you have any other ideas I'd be glad to know.

    BTW... Here is the code using the CreateProcess...
    It seems to chew up the CPU.

    while(node) {

    STARTUPINFO si;

    ::ZeroMemory (&si, sizeof(STARTUPINFO));
    si.cb = sizeof (STARTUPINFO);
    si.dwFlags = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_HIDE;
    PROCESS_INFORMATION pi;

    sprintf(hp_command,"%s%s%s","C:\\OpenView\\bin\\ovobjprint -s "
    , node->dname, " > C:\\tmp\\dev_status.txt 2> nul");
    BOOL processCreated = ::CreateProcess( NULL, _T (hp_command), NULL, NULL, TRUE,
    NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi );

    ifstream inDevStatusFile("C:\\tmp\\dev_status.txt",ios::nocreate);

    if(processCreated) {
    ::CloseHandle(pi.hThread);
    sprintf(hp_command,"%s%s%s","C:\\OpenView\\bin\\ovobjprint -s "
    , node->dname, " > C:\\tmp\\dev_status.txt 2> nul");

    ::WaitForSingleObject (pi.hProcess, 5000);
    ::CloseHandle(pi.hProcess);
    }
    .
    .
    .
    process next node...



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured