I am trying to compile legacy code from Windows XP in a new environment in Windows 7. It compiles but does not execute at runtime.
CreateProcess () returns 0 and GetLastError () returns 2, which means ERROR_FILE_NOT_FOUND
Here is my call to CreateProcess
STARTUPINFO StartInfo; memset(&StartInfo, 0, sizeof(StartInfo)); wcsncpy(astrCommandLine, L"TFTP", MAX_OSCOMMANDLINE_SZ-1); BOOL bFuncRetn = CreateProcess(NULL, astrCommandLine, // command line NULL, // process security attributes NULL, // primary thread security attributes NULL, // handles are inherited 0, // creation flags NULL, // use parent environment NULL, // use parent current directory &StartInfo, // STARTUPINFO pointer &m_ProcInfo ); // receives PROCESS_INFORMATION
Now for the weird thing: when I run calc instead of tftp, a popup is called up. I can do everything on the command line from anywhere on the command line, so it tells me that% PATH% to c: \ windows \ system32 is known and working correctly.
I tried to force CreateProcessA with ansi strings, but I got the same result. I also tried in the debug and release configuration and from the command line.
Any idea?
EDIT: both files calc.exe and tftp.exe are located in the c: \ windows \ system32 directory, which is located in the system path.
running "c: \ windows \ system32 \ tftp" does not work.
source share