//cDriveLetter で指定されたドライブレターと TargetCluster で指定されたクラスター番号から論理アドレスに変換 (NTFS 用)//BytesPerSector と BytesPerCluster は WinAPI なら GetDiskFreeSpace()で、cmd なら fsutil fsinfo ntfsinfo で取得可能var cDriveLetter = "C";var TargetCluster = 0x100000;function GetBytesPerSectorFromDriveLetter(cDriveLetter){ var objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}"); var listWin32LogicalDiskToPartition = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition"); var listWin32DiskDriveToDiskPartition = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDriveToDiskPartition"); var listWin32DiskDrive = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive"); for(var i = 0; i < listWin32LogicalDiskToPartition.Count; i++){ if(/Win32_LogicalDisk\.DeviceID=\"([A-Za-z]):\"/i.exec(listWin32LogicalDiskToPartition.ItemIndex(i).Dependent) != null){ if(RegExp.$1.toUpperCase() == cDriveLetter.toUpperCase()){ for(var i2 = 0; i2 < listWin32DiskDriveToDiskPartition.Count; i2++){ if(listWin32LogicalDiskToPartition.ItemIndex(i).Antecedent.toUpperCase() == listWin32DiskDriveToDiskPartition.ItemIndex(i2).Dependent.toUpperCase()){ if(/Win32_DiskDrive\.DeviceID=\"(.+)\"/i.exec(listWin32DiskDriveToDiskPartition.ItemIndex(i2).Antecedent) != null){ var sDeviceID = RegExp.$1.replace(/\\\\/g, "\\"); for(var i3 = 0; i3 < listWin32DiskDrive.Count; i3++){ if(listWin32DiskDrive.ItemIndex(i3).DeviceID.toUpperCase() == sDeviceID.toUpperCase()){ return parseInt(listWin32DiskDrive.ItemIndex(i3).BytesPerSector); } } } } } } } } return 0;}function GetBytesPerClusterFromDriveLetter(cDriveLetter){ var objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}"); var listWin32Volume = objWMIService.ExecQuery("SELECT * FROM Win32_Volume WHERE DriveLetter LIKE '" + cDriveLetter + ":'"); if(listWin32Volume.Count > 0){ return parseInt(listWin32Volume.ItemIndex(0).BlockSize); }else{ return 0; }}function GetPartitionStartAddressFromDriveLetter(cDriveLetter){ var objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}"); var listWin32LogicalDiskToPartition = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition"); for(var i = 0; i < listWin32LogicalDiskToPartition.Count; i++){ if(/Win32_LogicalDisk\.DeviceID=\"([A-Za-z]):\"/i.exec(listWin32LogicalDiskToPartition.ItemIndex(i).Dependent) != null){ if(RegExp.$1.toUpperCase() == cDriveLetter.toUpperCase()){ return parseInt(listWin32LogicalDiskToPartition.ItemIndex(i).StartingAddress); } } } return 0;}var BytesPerSector = GetBytesPerSectorFromDriveLetter(cDriveLetter);var BytesPerCluster = GetBytesPerClusterFromDriveLetter(cDriveLetter);var PartitionStartingAddress = GetPartitionStartAddressFromDriveLetter(cDriveLetter);var LogicalAddress = PartitionStartingAddress + (TargetCluster * BytesPerCluster);var LogicalBlockAddress = LogicalAddress / BytesPerSector;var s1 = "//Ctrl + C でクリップボードにコピー" + "\n"; s1 += "cDriveLetter:\t\t" + cDriveLetter + "\n"; s1 += "BytesPerSector:\t\t" + BytesPerSector + "\n"; s1 += "BytesPerCluster:\t\t" + BytesPerCluster + "\n"; s1 += "PartitionStartingAddress:\t" + PartitionStartingAddress + "\n"; s1 += "TargetCluster:\t\t" + TargetCluster + "\n"; s1 += "LogicalAddress:\t\t" + LogicalAddress + "\n"; s1 += "LogicalBlockAddress:\t" + LogicalBlockAddress + "\n";WScript.Echo(s1);
元データの書式(インラインプラグイン)を継承する
CrucialWestern DigitalSK hynixSamsungTranscendADATAKingstonSilicon PowerOCZPatriot
IntelSanDiskPlextorMicronToshiba
関連ソフトベンチマークソフト
雑多
SandBoxヘルプfaqサンプル
〔編集:MenuBar〕