Help needed with external call, WinExec() and timer.
My objective is to print the output of "netstat" and "netstat -e" into a file and read from it the data and display it through my program.
The first problem I encountered is that
WinExec("netstat -e > tmp.txt", FALSE);
cannot work because the function does not seems to be able to understand "> tmp.txt".
The first advice I received is to make a batch file and call it.
WinExec("batch.bat", FALSE); //batch.bat: netstat-e > tmp.txt
The problem with this solution is that a thread Winoldap is created upon this call and does not terminates even when the batch file finishes operation(unlike calling an .exe).
Another problem that I fear I might encounter is that how can I determine the operation to write to the file is finished so that I can read the file?
Function_To_Write_To_File(); //WinExec("batch.bat", FALSE); -Which has a problem
A process is created to write the file(an individual thread, I think) and the commands to read the file may be carried out even before the file is written.
Since I am using timer to refresh the data shown, how can I ensure that there is no multiple call to refresh?
Let's say I set the timer
SetTimer(timer, 1000, NULL);
And on timer, I call a function refresh(); the function refresh() may take more than 1.000 second to finish operation and before it finishes, another call to refresh() is made.
How do I solve this?
I am a beginner, please try to explain in as much details as possible.