Sri wrote:
> Thanks for your input.
>
> I'm attaching the sample code for createprocess at the bottom of this mail.
> the error code that I'm getting from createprocess call is 2, that means
> ERROR_FILE_NOT_FOUND.
> I have tried many possible combination like path to the executable and
> arguments in the command line field, but the same error each time.
CreateProcess() is a low-level call riddled with nuances and
undocumented behavior.
> I also tried the system(), as told by you, but here it considers the the
> path "C:\\Program Files\\...." as some command or program and gives the
> following error-"C:\Program' is not recognized as an internal or external
> command,
> operable program or batch file."
That happens if the executable is not encased in quotes.
system("cmd /C \"C:\\Program Files\\Wireshark\\tshark.exe\" -r
C:\\input\\tcpdump.cap -R \"tcp.dstport==7275 && ulp.msSUPLPOS\" -V >
C:\\output\\dump.txt");
That should have worked. The entire executable name is encased in quotes.
> Regards,
>
> Sri
>
> /*************************************************sample code for
> createprocess*******************************/
> int main(void)
> {
>
>
> STARTUPINFO si;
> PROCESS_INFORMATION pi;
> ZeroMemory( &si, sizeof(si) );
> si.cb = sizeof(si);
> ZeroMemory( &pi, sizeof(pi) );
>
> char cmdline[1000];
> char currdir[100];
> sprintf(cmdline,"tshark.exe -r C:\\input\\tcpdump.cap -R ulp.msSUPLPOS
> -V > C:\\input\\dump.txt");
Won't work. You have to set up the pipe/redirect yourself. See
previously mentioned MSDN Library article. It is messy, which is why it
is worth getting system() to work instead.
> sprintf(currdir,"C:\\Program Files\\Wireshark\\");
> // Start the child process.
> if( !CreateProcess( NULL, // No module name (use command line)
...
> (LPWSTR)(cmdline), // Command line
> (LPCWSTR)(currdir), // Use parent's starting directory
...
Er...Unicode string _casts_? That is probably why you are getting the
file not found error. You are probably calling CreateProcessW() and
using ANSI strings - the two don't mix. Your root problem is you are
compiling with Unicode enabled. Right click on your project name, go
into Properties, and look for the Unicode option. Switch to ANSI. Get
rid of the casts and try again. Although, it won't work until you set
up proper redirection.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/