[英]how to launch dx app using createProcess()
using this code snippet: 使用此代码段:
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
char szExe[] = "C:\\Apps\\Desktop\\Release\\simplesample.exe";
//char szExe[] = "C:\\Windows\\System32\\notepad.exe";
if(CreateProcess(0, szExe, 0, 0, 0, 0, 0, 0, &si, &pi))
{
// optionally wait for process to finish
WaitForSingleObject(pi.hThread, 0);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
return 0;
when I use notepad.exe, notepad gets launched. 当我使用notepad.exe时,记事本会启动。
However, when I use the path to simplesample.exe, it launches simplesample and crashes immediately. 但是,当我使用simplesample.exe的路径时,它将启动simplesample并立即崩溃。 I fail to understand why simplesample won't launch properly from createProcess.
我不明白为什么simplesample无法从createProcess中正确启动。
I can launch simplesample.exe from command prompt as is. 我可以直接从命令提示符启动simplesample.exe。
PS: Simplesample
is a dx sample app using winmain PS:
Simplesample
是使用winmain的dx示例应用程序
Ty to pass directory where simplesample.exe
is to lpCurrentDirectory
parameter of CreateProcess()
. Ty传递目录,其中
simplesample.exe
是CreateProcess()
lpCurrentDirectory
参数。 Probably, this program searches for assets, shaders or DLLs in current folder, but receives directory of calling process and thus it cannot find them. 该程序可能在当前文件夹中搜索资产,着色器或DLL,但接收到调用进程的目录,因此找不到它们。
lpCurrentDirectory [in, optional]
lpCurrentDirectory [in,可选]
The full path to the current directory for the process.
进程当前目录的完整路径。 The string can also specify a UNC path.
该字符串还可以指定UNC路径。
If this parameter is NULL, the new process will have the same current drive and directory as the calling process .
如果此参数为NULL,则新进程将具有与调用进程相同的当前驱动器和目录 。 (This feature is provided primarily for shells that need to start an application and specify its initial drive and working directory.)
(此功能主要提供给需要启动应用程序并指定其初始驱动器和工作目录的外壳。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.