大家好,今天我在Delphi中调用CreateProcess函数时遇到一个问题。在MSDN中CreateProcess的原型如下:BOOL CreateProcess(
LPCTSTR lpApplicationName, // name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);可以看到它有一个BOOL类型的参数“BOOL bInheritHandles”,我在调用时,对这个参数直接传入True或False,结果发现不管传入的是True还是False,效果却都跟传入False一样。请问是不是我对这个BOOL类型的参数的传法搞错了呢?向大家求教正确的方法,谢谢。
其实我是想问:我用VC编了一个DLL,导出一个函数,代码为:void _stdcall Test(BOOL bValue)
{
if(bValue)
MessageBox(NULL, "the parameter is True.", "Test", MB_OK);
else
MessageBox(NULL, "the parameter is False.", "Test", MB_OK);
}然后我在delphi里调用,用以下语句声明这个函数:procedure Test(bValue: LongBool); stdcall; external 'DLL名' name 'Test';接着这样调用:Test(True);结果弹出the parameter is False.请问这是为何啊?太奇怪了。
你的Handle为可继承才有用的