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.
Printable View
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.
what do you say about WinExec()???
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
Did u try it CreateProcess function?
If u do let me see the code
Regards,
Ovidiu
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...