[英]CreateProcess() lpCurrentDirectory has no effect
我想啟動一個進程(exe文件),如果我將完整路徑附加到我的命令行(lpCommandLine param),一切都很好但是如果我將lpCurrentDirectory設置為[STARTDIR]系統說:
ERROR_FILE_NOT_FOUND
開始這個過程:
CreateProcessA(NULL, // No module name (use command line)
&command[0], // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
CREATE_NEW_CONSOLE, // No creation flags
NULL, // Use parent's environment block
[NULL] or [STARTDIR], // Use parent's starting directory
startupInfo, // Pointer to STARTUPINFO structure
processInfo) // Pointer to PROCESS_INFORMATION structure
- >在這個文件夾中有一些其他的dll和我想要啟動的exe
為什么這不起作用?
謝謝!
不,那不行。 在啟動期間,新進程不會以該目錄作為“當前”目錄啟動。 而是在進程啟動后設置當前目錄。
如果您希望進程在特定目錄中啟動,則需要使用SetCurrentDirectory
或其中一個或多或少的可移植變體(例如_chdir
)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.