如何确定两个Win32 API句柄代表同一对象? [英] How to determine that two Win32 API handles represent the same object?

查看:112
本文介绍了如何确定两个Win32 API句柄代表同一对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个手把:

HANDLE h1;
HANDLE h2;

并且都已接收到某些Windows API函数产生的值-特别是,我对CreateFile()调用产生的句柄感兴趣.如何确定h1h2引用相同的基础对象(对于CreateFile())是相同的文件,目录或设备?是否有一些API可以确定这一点?

And both have received values resulted from some Windows API function - in particular, I'm interesed in handles resulted from calls to CreateFile(). How do I determine that h1 and h2 reference the same underlying object - in the case of CreateFile() - same file, directory or device? Is there some API to determine that?

推荐答案

您可以使用GetFinalPathNameByHandle并比较两个句柄的文件路径. https://msdn.microsoft. com/en-us/library/windows/desktop/aa364962(v = vs.85).aspx

You could use GetFinalPathNameByHandle and compare the file path of both handles. https://msdn.microsoft.com/en-us/library/windows/desktop/aa364962(v=vs.85).aspx

这篇关于如何确定两个Win32 API句柄代表同一对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆