简体   繁体   English

CreateProcess()lpCurrentDirectory无效

[英]CreateProcess() lpCurrentDirectory has no effect

I want to start a process (exe file) and if I append the full path to my command line (lpCommandLine param) everything is fine but if I set lpCurrentDirectory to [STARTDIR] the system says: 我想启动一个进程(exe文件),如果我将完整路径附加到我的命令行(lpCommandLine param),一切都很好但是如果我将lpCurrentDirectory设置为[STARTDIR]系统说:

ERROR_FILE_NOT_FOUND

start the process: 开始这个过程:

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

-> In this folder are some other dlls and the exe I want to start - >在这个文件夹中有一些其他的dll和我想要启动的exe

Why this doesn't work? 为什么这不起作用?

Thx! 谢谢!

No, that won't work. 不,那不行。 The new process won't be started with that directory as the "current" directory during the start. 在启动期间,新进程不会以该目录作为“当前”目录启动。 Instead, the current directory is set once the process has started. 而是在进程启动后设置当前目录。

If you want your process to start in a particular directory, then you need to use SetCurrentDirectory or one of the more or less portable variants thereof ( _chdir for example). 如果您希望进程在特定目录中启动,则需要使用SetCurrentDirectory或其中一个或多或少的可移植变体(例如_chdir )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM