原来有个程序,需要使用DuplicateHandle,在xp下
if(DuplicateHandle(hProcess, toDuplicate, GetCurrentProcess(), &hObject, STANDARD_RIGHTS_REQUIRED, FALSE, 0) != FALSE) ......没有问题,返回值OK,可是在win 10下,每次都是error,GetLastError返回5,百思不得其解,
只有好好研究文档了,看到最新的MSDN是这样写的:
https://msdn.microsoft.com/zh-cn/data/ms724251(v=vs.100)
Optional actions. This parameter can be zero, or any combination of the following values.
Value Meaning DUPLICATE_CLOSE_SOURCECloses the source handle. This occurs regardless of any error status returned.
DUPLICATE_SAME_ACCESSIgnores the dwDesiredAccess parameter. The duplicate handle has the same access as the source handle.
老版的就不去找了,原来没有使用options,使用options
if(DuplicateHandle(hProcess, toDuplicate,
GetCurrentProcess(), &hObject, 0/*STANDARD_RIGHTS_REQUIRED*/, FALSE, DUPLICATE_SAME_ACCESS) != FALSE)
{
Build->Run,OK!