如何访问GPT格式的磁盘分区/GUID卷的文件系统信息? [英] How do I access the filesystem information for a GPT formatted disk partition/GUID volume?
问题描述
我能够获取标准MBR磁盘上分区的文件系统.但是,我遇到了麻烦,试图在GPT样式的分区方案上获取文件系统.到目前为止,我可以获得体积信息(从一个小的C ++ CLI测试应用程序-用VS2010编译):
I am able to obtain the filesystem for partitions on standard MBR disks. However I am hitting a brick wall trying to obtain the filesystem on a GPT-style partitioning scheme. To-date I can obtain the volume information (from a little C++ CLI test app - compiled with VS2010):
[1] GPT entry:
partition number (2)
partition name: Basic data partition
partition Type GUID: {EBD0A0A2-B9E5-4433-87C0-68B6B72699C7}
partition GUID ID: {AF359AFD-C400-419A-A0DF-6E0E084A548E}
ERROR: Cannot access volume '\\?\Volume{AF359AFD-C400-419A-A0DF-6E0E084A548E}' filesystem information. Have you specified a valid volume GUID? [DeviceIoControl() error: 1]
上面的分区是2Tb硬盘上的标准2Tb NTFS分区(条目1显然是系统保留的GPT表).我可以正确获取卷的句柄(使用CreateFile()函数).但是,当我调用DeviceIoControl(hVolume, FSCTL_QUERY_FILE_SYSTEM_RECOGNITION, ...)
函数时,它将返回一个invalid function error
??
FSCTL_QUERY_FILE_SYSTEM_RECOGNITION
调用对GPT格式化的硬盘有效吗?如果没有,如何获取给定GUID卷代码的文件系统信息?
谢谢
Bob
The above partition is standard 2Tb NTFS partition on a 2Tb harddisk (entry 1 is obviously the system reserved GPT table). I can obtain a handle to the Volume correctly (using the CreateFile() function). However when I call the DeviceIoControl(hVolume, FSCTL_QUERY_FILE_SYSTEM_RECOGNITION, ...)
function it returns an invalid function error
??
Does the FSCTL_QUERY_FILE_SYSTEM_RECOGNITION
call work for GPT formatted harddisks? If not how do I obtain the filesystem information for a given GUID volume code?
Thanks
Bob
推荐答案
确定
我自己解决了这个问题.希望该解决方案将对其他人有所帮助.
答案是使用函数:GetVolumeInformation().
您必须传递L"\\?\ Volume {AF359AFD-C400-419A-A0DF-6E0E084A548E} \"(示例GUID卷描述符)作为第一个参数.注意拖尾(\)...啊,很棒的Microsoft-再次与它们的API保持一致!
GetVolumeInformation()的返回参数:
lpFileSystemNameBuffer [out]
将在您的GPT/MBR分区上包含真实的文件系统!
鲍勃
OK
I solved this problem myself. Hopefully the solution will help other folks. The
answer is to use the function: GetVolumeInformation().
You must pass L"\\?\Volume{AF359AFD-C400-419A-A0DF-6E0E084A548E}\" (an example GUID volume descriptor) as the first argument. NOTE THE TRAILING SLASH (\)... Ah wonderful Microsoft - being consistent with their APIs again!
The return parameters from the GetVolumeInformation():
lpFileSystemNameBuffer [out]
will contain the real world filesystem on your GPT/MBR partition!
Bob
这篇关于如何访问GPT格式的磁盘分区/GUID卷的文件系统信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!