首页 > 编程知识 正文

duplicatehandle,win10装xp双系统步骤

时间:2023-05-03 17:02:33 阅读:245701 作者:3809

原来有个程序,需要使用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)

dwOptions [in]

Optional actions. This parameter can be zero, or any combination of the following values.

Value Meaning DUPLICATE_CLOSE_SOURCE

 Closes the source handle. This occurs regardless of any error status returned.

DUPLICATE_SAME_ACCESS 

Ignores 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!

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。