sunkiss
发表于 2010-5-13 10:13:16
FileInstall('dsptw.exe', @TempDir & '\') ;将dsptw.exe文件打包进编译
FileInstall('PECMD.EXE', @TempDir & '\') ;将PECMD.EXE文件打包进编译
RunWait(@ComSpec & ' /c ' & @TempDir & '\dsptw.exe /A /PDR > diskinfo.txt', @TempDir, 0) ;于dos下隐藏运行dsptw生成信息文本
$str = FileRead(@TempDir & '\diskinfo.txt') ;读取文本
$sR = StringRegExp($str, '(:)\t(\d:\d+)\h*\tA\t', 3) ;正则匹配活动分区,[从C到Z]、\t匹配一个制表符、\d、匹配一个数字字符、:???
If Not @error Then MsgBox(0, 0, '活动分区 ' & $sR & ' No. ' & $sR)
local $CP = $sR
local $HAO = $sR
RunWait(@ComSpec & ' /c ' & @TempDir & '\PECMD.EXE ENVI $CP="'&$CP&'"',"", @SW_HIDE)
RunWait(@ComSpec & ' /c ' & @TempDir & '\PECMD.EXE ENVI $HAO="'&$HAO&'"',"", @SW_HIDE)
If Not @error Then MsgBox(0, 0, '活动分区 ' & $CP & ' No. ' & $HAO)
sunkiss
发表于 2010-5-13 10:14:56
回复sunkiss
成功了就OK了~
\d:就是一个数字后面跟个":"而已;\h代表水平空格;\tA代表Tab空 ...
afan 发表于 2010-5-13 09:08 http://www.autoitx.com/images/common/back.gif
哦,呵呵,好,一会我再啃啃帮助这块骨头,哈哈
republican
发表于 2010-5-13 10:22:12
本帖最后由 republican 于 2010-5-13 10:28 编辑
回复 7# afan
请问不用Ghost模式(/A /PDR),正则如何写?
sunkiss
发表于 2010-5-13 10:31:30
变量外面不要用"","$sR" 不对,应该为 $sR
afan 发表于 2010-5-13 10:11 http://www.autoitx.com/images/common/back.gif
哈哈,行了,还是版版厉害!为什么不能用“”呢?《FAQ 大全》初学者必看.txt这里面的就加着""变量里用这个不行吗?
sunkiss
发表于 2010-5-13 10:34:02
回复afan
请问不用Ghost模式(/A /PDR),正则如何写?
republican 发表于 2010-5-13 10:22 http://www.autoitx.com/images/common/back.gif
不加这两个参数生成的文件是这样的啊!Syntax:
DSPTW
Disk: 0-First Hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, ...
d:n e.g. 0:1, 0:2, 0:3 ...
Start: Disk Absolute Sector Number
Sectors: Total Sectors to be Processed
/S:Save Disk Sector Info to File
/R:Restore Disk Sector Info from File
/C:Compare Disk Sector Info with File
FileName: Disk Sector Info File
/Y: Assume Yes on all Queries & not Display Copyright
DSPTW
/L:List Disk Sector Info on Screen
/P:Pause echo Screen
/A:Show ASC Value
DSPTW
/E: Erase Disk Sector Info
DSPTW |
/D: Duplicate Disk Sector Info from Disk to DstDisk.
/O: Compare Disk Sector Info with DstDisk
DstDisk: 0-First Hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, D: ...
Offset: Disk Absolute Sector Number
DSPTW
SectorNo: Disk Absolute Sector Number.
Offset: The Offset in Specified Sector (0..511).
/M: Modify Disk Sector Info.
/HEX: Hex Style.
value: Hex Digital String (No more than 32 characters).
DSPTW
Disk: 0-First Hard disk, 1-Second Hard Disk, ...
/S: Save Disk Partition Info to File.
/R: Restore Disk Partiton Info from File.
/C: Compare Disk Partiton Info with File.
FileName: Disk Partition Info File.
DSPTW
Save Partition Boot Record to File.
DSPTW
/L: List Disk Partition Info on Screen.
/A: Get Accurate TotalSectors of Disk.
/Ext: Display Big Extend Partition.
DSPTW
Active Disk Partition n.
DSPTW
/FIND: Find Disk Partition.
type: Can be FAT16/FAT32/FAT/NTFS/LINUX/DELL/HIDE/NORMAL/ALL.
/GhostStyle: Display in Ghost Style, and Disk Start From 1.
DSPTW
/MBR: ReBuild Disk Main Boot Record.
/NOBACK: Don't Backup old MBR.
/File: Restore MBR from filename
DSPTW
Hide/Unhide Disk Partition n.
DSPTW
/DPS: Save Disk Partition Info to Last Cluster.
/DPR: Restore Disk Partiton Info from Last Cluster.
/DPC: Compare Disk Partiton Info with Last Cluster.
DSPTW
/ChangeType: Change Partition Type.
type: 01-FF.
partno: Partition Number.
DSPTW |
/PDR: Display Relationship of Partition & Drive(Ghost Style).
Drive: C:, D:, E ...
/A: Process All Drive.
/REVERSE: Display with a Reverse Order(Only when Switch "/A" is used).
Type "DSPTW /?" for Help.
afan
发表于 2010-5-13 10:35:20
回复afan
请问不用Ghost模式(/A /PDR),正则如何写?
republican 发表于 2010-5-13 10:22 http://www.autoitx.com/images/common/back.gif
不明白,要正则什么?
sunkiss
发表于 2010-5-13 10:37:11
看来这个正则真的好难啊!
sunkiss
发表于 2010-5-13 13:52:00
可累死我了,休息一下!AU3的函数真多啊,是巨多!
republican
发表于 2010-5-13 15:46:38
回复 21# afan
ghost模式下并不识别Linux结构的分区,所以如果想获取所有磁盘信息的话,该如何?
afan
发表于 2010-5-13 16:27:04
回复 24# republican
可以试试
dsptw 0 /l
dsptw 1 /l
dsptw 2 /l
...
或
dsptw 0 /find:all
dsptw 1 /find:all
dsptw 2 /find:all
...
sunkiss
发表于 2010-5-13 17:53:00
回复 25# afan
在我的电脑上这两个都不对!No.Dr Tag FileSystem Volume Act StartPos Sectors MBytes FreeMB
0:1C: Pri HPFS/NTFS Yes 63 1003740574901032716
0:2F: Log Win95_FAT32 1003741832040192 996 201
0:3D: Log HPFS/NTFS 102414438204812622100006 10550
0:4E: Log HPFS/NTFS 307227123215511912105230 31560
0:5G: Pri Linux_Native 超强电脑 52273903510029379548971
0:6 Pri Linux_Swap 6230328302104515 1027 G:是我量产的usb-CDROM,06是我的U盘剩余空间做的可移动磁盘,我的移动硬盘没有认到
afan
发表于 2010-5-13 17:58:12
非ghost模式第一硬盘都是识别为0,第二硬盘为1...
试试 dsptw 1 /l 或 dsptw 1 /find:all
republican
发表于 2010-5-13 19:42:57
本帖最后由 republican 于 2010-5-13 19:44 编辑
回复 25# afan
其实我的意思是该如何提取数据才能生成上表的结果。
上表生成代码:Local $diskinfo=FileOpen($IniFile) ;dsptw Ghost模式生成的文件
Local $TotalLine=0
While 1;获取行数
FileReadLine($diskinfo,$TotalLine)
If @error=-1 Then ExitLoop
$TotalLine +=1
WEnd
Local $LineRead ;定义变量
For $LineRead =3 To $TotalLine -2;从第三行开始读取
Local $LineForRead=FileReadLine($diskinfo,$LineRead)
Local $InfoForRead=StringSplit($LineForRead," ")
For $i = 1 To $InfoForRead
If $i = 1 Then
_GUICtrlListView_AddItem($DiskList, StringStripWS($InfoForRead[$i],8), $LineRead-3)
_GUICtrlListView_AddSubItem($DiskList, $LineRead-3, DriveGetFileSystem(StringStripWS($InfoForRead[$i],8)), 6)
;_GUICtrlListView_AddSubItem($DiskList, $LineRead-3, 'FAT32', 6)
Else
If $InfoForRead[$i]="A" Then
$InfoForRead[$i]="活动"
$ActivePar=$InfoForRead[$i-2]
EndIf
_GUICtrlListView_AddSubItem($DiskList, $LineRead-3, StringStripWS($InfoForRead[$i],8), $i-1)
EndIf
Next
Next因为Ghost模式可以用制表符隔开,但find:all模式却不可以。
sunkiss
发表于 2010-5-13 20:11:32
又发现问题了!
现在分区表是这样的情况怎么办?Drive No. ActiveVolumeLabe Total (Mb) Free (Mb)
C: 1:1 A 12793 4886
D: 1:2 学习 20494 7342
E: 1:3 娱乐 20494 8209
F: 1:4 下载备份 21059 1957
I: 2:1 A 超强电脑 7420 1332
I: 2:1 A 超强电脑 这个是我量产的U盘再用下边的语句会提示c:和2:1
If Not @error Then MsgBox(0, 0, '活动分区 ' & $sR & ' No. ' & $sR)
怎么让提示现示c:和1:1呢?
sunkiss
发表于 2010-5-13 20:25:16
能不能这样?
正则后$sR显示c:,$sR那个变量才是对应这一行1:1的呢?
C: 1:1 A 12793 4886