问题描述
假设我有两个手把:
HANDLE h1;
HANDLE h2;
并且都已接收到某些Windows API函数产生的值-特别是,我对CreateFile()
调用产生的句柄感兴趣.如何确定h1
和h2
引用相同的基础对象(对于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句柄代表同一对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!