你怎么读128位NTFS FILE_ID的目录和/或文件? [英] How do you read the 128-bit NTFS FILE_ID for a directory and/or file?

查看:636
本文介绍了你怎么读128位NTFS FILE_ID的目录和/或文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以NTFS使用128位的GUID来标识文件和目录,你可以很轻松地查看此信息:

So NTFS uses a 128-bit Guid to identify files and directories, you can view this information easily enough:


C:\Temp>C:\Windows\System32\fsutil.exe objectid query .
Object ID :        ab3ffba83c67df118130e0cb4e9d4076
BirthVolume ID :   ca38ec6abfe0ca4baa9b54a543fdd84f
BirthObjectId ID : ab3ffba83c67df118130e0cb4e9d4076
Domain ID :        00000000000000000000000000000000

因此,这是明显不够的,但一个人如何编程检索此信息?纵观WINAPI为OpenFileById(...),你应该能够得到这个信息。人们期望这在的的Win32 API写到FileID图书馆,但有方法(的 GetFileInformationByHandleEx )返回的 FILE_ID_BOTH_DIR_INFO 结构。这个结构定义了一个FILEID;但是,它是一个LARGE_INTEGER(64位)不完整的128位标识符。

So this is obvious enough, but how does one retrieve this information programmatically? Looking at the WinApi for OpenFileById(...) you should be able to get this information. One would expect this to be done in the "Win32 FileID API Library", yet the method there (GetFileInformationByHandleEx) returns a FILE_ID_BOTH_DIR_INFO structure. This structure defines a FileId; however, it is a LARGE_INTEGER (64bit) not the full 128 bit identifier.

我猜人们可以使用WMI对于这一点,是我应该在哪里转?

I'm guessing one could use WMI for this, is that where I should turn?

推荐答案

的搜索带我到的DeviceIoControl ,有点蹉跎答案你的问题: FSCTL_GET_OBJECT_ID 返回完全相同的ID作为在输出从 FSUTIL

A bit of searching took me to DeviceIoControl and there lies the answer to your question: FSCTL_GET_OBJECT_ID returns exactly the same IDs as in your output from fsutil.

总之,文档对于 BY_HANDLE_FILE_INFORMATION 说,64位文件ID唯一已标识给定卷上的文件。据维基百科,NTFS仅支持最多2 ^ 32个文件,所以128位ID似乎完全没有必要。

Anyhow, the docs for BY_HANDLE_FILE_INFORMATION say that the 64-bit file ID already uniquely identifies a file on a given volume. According to Wikipedia, NTFS only supports a maximum of 2^32 files, so the 128-bit ID seems quite unnecessary.

这篇关于你怎么读128位NTFS FILE_ID的目录和/或文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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