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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Different exec result between DOS window or in _spawnlp app

Status
Not open for further replies.

PROPAR

Programmer
Oct 25, 2001
51
FR
I compiled an WinMain CalcCRC.exe which produces a 4 digit check-sum of a file (exe : CalcCRC.exe myfile.txt).

When executed in DOS window(i.e. C:>CalcCRC.exe myfile.txt), my exec computes a different result that the one produced when executed with an _spawnlp("CalcCRC.exec","myfile.txt", NULL) API in a VC6 app.
How is this possible ?
How can the iostream which reads the file can behave in a different way ?
What can I do to insure the same result both way ?
It puzzles me
 
intptr_t _spawnlp(
int mode,
const char *cmdname,
const char *arg0,
const char *arg1,
... const char *argn,
NULL
);

So your _spawnlp call should be:

_spawnlp ( "calccrc.exe", "calccrc.exe", "myfile.txt", NULL );

Your _spawnlp call is calculating a checksum of calccrc.ee itself.

Marcel
 
Yes, I missed a parameter in my above example of the _spawnlp call.
However, my _spawnlp call is well written and doubled the exec name.

I think the trick may be in the std::locale of my iostream opening. Can the locale be different between DOS and the API call, if the file is opened in text mode ?
 
Correction, i forgot the mode parameter


_spawnlp ( _P_WAIT (or _P_NOWAIT), "calccrc.exe", "calccrc.exe", "myfile.txt", NULL )


Marcel
 
Propar, my previous post (about the correction) was posted before i read your reply, so that doesn't make sense if you are sure your _spawnlp call was right.
Don't know about locale, I can't answer that. But I don't think it should make a difference, because what you call DOS is in fact also a 32 bit program when using VC6.
Make sure you open the right file, you can pop up a MessageBox before the iostream is opened.


Marcel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top