【发布时间】:2011-09-14 17:34:05
【问题描述】:
我正在尝试通过命令行或任何其他方式将互斥体句柄传递给子进程。
我该怎么做? 如何访问孩子的互斥锁?
这就是我创建子进程的方式:
HANDLE ghMutex;
if( !CreateProcess( _T("C:\\Users\\Kumppler\\Documents\\Visual Studio 2010\\Projects\\teste3\\Debug\\teste3.exe"), // No module name (use command line)
aux2, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
TRUE, // Set handle inheritance to TRUE
STARTF_USESTDHANDLES, // inherit the standard input, standard output, and standard error handles
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si[j], // Pointer to STARTUPINFO structure
&pi[j] ) // Pointer to PROCESS_INFORMATION structure
)
编辑:
我需要为多个子进程使用互斥锁,可以吗?
这就是我现在正在做的事情:
HANDLE ghMutex;
int mutex;
char mutexstring[7];
mutex=(int)ghMutex;
itoa(mutexValue,mutexString,10);
我将通过命令行传递 mutexString,然后在子进程中将其转换回:
mutexValue=atoi(argv[2]);
Mutex=(HANDLE)mutexValue;
我的问题,可以进行 (HANDLE) 投射吗??
【问题讨论】: