Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem in starting an external program with input file

Status
Not open for further replies.

AVITAL

Programmer
Mar 26, 2001
1
IL
Hi,

I used CreateProcess in order to run an *.exe file .This execute need an input
file in order to run ,the input file is not need to be writen in the command line
in order to run the execute file.So I used CreateFile before the CreateProcess
But still I have an error:Can not find the input file!!!!.
What's wrong????


The code is:

hReadFile=CreateFile("d:\\text.txt", GENERIC_READ, FILE_SHARE_READ,
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);


// Execute the command with a call to the CreateProcess API call.
memset(&si,0,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.wShowWindow = SW_SHOW;
si.hStdInput=hReadFile;

CreateProcess(NULL,"d:\\presyn.exe",NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);

//remember to close owned handles
CloseHandle(pi.hThread);

//Remember to close the handle of the file
CloseHandle(hReadFile);
 
Add below line before "CreateProcess" please:

si.dwFlags = STARTF_USESTDHANDLES | TARTF_USESHOWWINDOW;


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top