【发布时间】:2011-06-22 22:58:24
【问题描述】:
我试图让一个 C++ 程序调用一个已经制作好的 C# 程序在后台运行。
STARTUPINFO info = {sizeof(info)};
PROCESS_INFORMATION processinfo;
DWORD error1 = GetLastError();
bool x = ::CreateProcess((LPCWSTR)"C:\Convert_Shrink.exe", GetCommandLine(), NULL, NULL, false, 0,NULL,NULL, &info, &processinfo);
DWORD error = GetLastError();
在 CreateProcess 之前error1 为 0 CreateProcess 后错误为 2
错误 2:
ERROR_FILE_NOT_FOUND 2 (0x2) The system cannot find the file specified.
我已将其更改为 C:\ \ 以防他们检查转义序列,但我仍然收到错误 2,我不知道为什么。
【问题讨论】:
-
这种转换只会阻止编译器告诉你你做错了。它并没有阻止你做错事。在字符串前面放一个 L 使其成为 Unicode 文字。
-
应用程序路径是否也只能这么长?我把程序放在C:\进行测试,但它需要与目录较深的程序在同一目录中。