Tag: 分区查找预览模式: 普通 | 列表
希望能得到这样的结果  

磁盘  1  的分区  1  :  C  
磁盘  1  的分区  2  :  D  
磁盘  1  的分区  3  :  E  
磁盘  1  的分区  4  :  F  
磁盘  2  的分区  1  :  G  
磁盘  2  的分区  2  :  I  
磁盘  2  的分区  3  :  J  
磁盘  2  的分区  4  :  K  

---------------------------------------------------------------  
就是这样了,GetVolumeInfo('C').DiskNumber结果就是所在的物理磁盘ID  

需要JEDI的Win32支持库才能编译!  

function  GetVolumeInfo(DriverLetter:  Char):  TDiskExtent;  
var  
   hVolume:  THandle;  
   DiskExtents:  PVolumeDiskExtents;  
   dwOutBytes:  Cardinal;  
begin  
   with  Result  do  
       begin  
           DiskNumber  :=  0;  
           StartingOffset.QuadPart  :=  0;  
           ExtentLength.QuadPart  :=  0;  
       end;  
   hVolume  :=  CreateFile(PChar('\\.\'+DriverLetter+':'),  GENERIC_READ  or  GENERIC_WRITE,  
                                                 FILE_SHARE_READ  or  FILE_SHARE_WRITE,  nil,  OPEN_EXISTING,  0,  0);  
   if  hVolume  <  1  then  Exit;  
   DiskExtents  :=  AllocMem(Max_Path);  
   if  DeviceIoControl(hVolume,  
                               IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,  
                               nil,  0,  
                               DiskExtents,  Max_Path,  
                               dwOutBytes,  nil)  then  
         begin  
             if  DiskExtents^.NumberOfDiskExtents  >  0  then  
                   Result  :=  DiskExtents^.Extents[0];  
         end;  
   FreeMem(DiskExtents);  
   CloseHandle(hVolume);  
end;  
  
http://lysoft.g4soft.net

查看更多...

Tags: 分区查找

分类:Tech | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2968