以下のプログラムから次のエラーが発生します:CreateProcess failed(3)
int __cdecl main(int argc, char **argv)
{
USES_CONVERSION;
string name_of_bitmap;
cout << "Name of file: ";
cin >> name_of_bitmap;
string arguments = "F:\\windowsqnx\\maps\\show_simulation\\Debug\\show_simulation.exe " + name_of_bitmap;
const char * nob;
nob = arguments.c_str();
std::wstring stemp = s2ws("F:\\windowsqnx\\maps\\show_simulation\\Debug\\show_simulation.exe");
LPCWSTR path = stemp.c_str();
// runing simulation display process
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if ( !CreateProcess(path,
A2W( nob ) ,
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
Sleep(2000);
return 1;
}
}
私はプロセスに不慣れで、何が間違っているのか理解できません。私はこれを読んで次のことstring arguments = "\"F:\\windowsqnx\\maps\\show_simulation\\Debug\\show_simulation.exe\" " + name_of_bitmap;
を行いstd::wstring stemp = s2ws("\"F:\\windowsqnx\\maps\\show_simulation\\Debug\\show_simulation.exe\" ");
、最初のパラメータをNULLにすると、エラー123が発生しますCreateProcess(NULL,
。失敗2が発生します。助けてください。
編集
std::wstring s2ws(const std::string& s)
{
int len;
int slength = (int)s.length() + 1;
len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
wchar_t* buf = new wchar_t[len];
MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
std::wstring r(buf);
delete[] buf;
return r;
}