找回密码
 加入
搜索
楼主: kn007

[系统综合] 如何得到第一硬盘的最后分区?

  [复制链接]
发表于 2009-10-28 23:13:26 | 显示全部楼层
本帖最后由 netegg 于 2009-10-28 23:16 编辑

15# kn007

不是,是我在官网上找来的
还没翻译呢,太多了,偷个懒,过几天
你要的这个功能好象是带geo的那个drive
发表于 2009-10-28 23:17:27 | 显示全部楼层
隐藏分区我没试过,不过内存虚拟盘可以
发表于 2009-10-28 23:20:35 | 显示全部楼层
函数倒是现在就可以给你,不过可能要改些东西,要不你先试试看
 楼主| 发表于 2009-10-29 15:02:34 | 显示全部楼层
饿,算了,我先去下个新版,有劳你了
发表于 2010-1-4 19:08:17 | 显示全部楼层
本帖最后由 ahkang 于 2010-3-29 10:06 编辑

仿深度小兵早期获取磁盘分区的脚本(自定义变量名是胡编乱造的, 可能有些费解)
其实, 深度小兵也是借助了第三方的工具: DsptW 来实现的, 本人在模拟实现其功能的基础上, 再加入了自动判断当前目录如果是光盘, 则不复制临时目录的 Ghost.ini 文件到脚本目录和读取磁盘隐藏分区功能, 这也借助了 "无忧启动论坛 123 MM 编写的一个小程序 ShowDrive, 由于考虑到害怕病毒感染, 在调用之前, 本人已将这2个文件均改了扩展名, 看起来像是系统扩展控件.
有了这2个文件, 论坛上的高手们一定写出更加精简的更优秀的脚本, 好了, 贴源码如下:
#InClude <File.Au3>
#NoTrayIcon

;=========== 取本机磁盘最后分区 =============
Global $DwptW=@TempDir&'\DsptW.eXe'
Global $ShowDrive=@TempDir&'\ShowDrive.eXe'
Global $Part=@TempDir&'\Part.Txt'
Global $GhostIni=@TempDir&'\Ghost.InI'
Global $W=@DesktopWidth
Global $H=@DesktopHeight
Global $X=$W/2
Global $Y=$H/2

If FileExists($GhostIni) Then FileDelete($GhostIni)

ToolTip('正在获取本地磁盘分区信息, 请稍候!',$X,$Y,'正在智能判断本地磁盘分区:',1,6)
FileInstall('ShowDrive.Vxd',$ShowDrive,1)
RunWait($ShowDrive&' /S','',@Sw_Hide)
FileDelete($ShowDrive)

FileInstall('DsptW.Vxd',$DwptW,1)
If FileExists($Part) Then FileDelete($Part)

RunWait(@ComSpec&' /C '&$DwptW&' 0 /L >'&$Part,'',@Sw_Hide)
$SerailNumber=StringMid(FileReadLine($Part,3),59)
FileDelete($Part)

For $i=1 To 26
        RunWait(@ComSpec&' /C '&$DwptW&' '&$i&' /Find:All /GhostStyle >>'&$Part,'',@Sw_Hide)
        If StringInStr(FileRead($Part),'Error') Then ExitLoop
Next
        FileDelete($DwptW)

Dim $v
        _FileReadToArray($Part,$v)
        FileWrite($GhostIni,'[HardDisk]')
        IniWrite($GhostIni,'HardDisk','HDD-SN',$SerailNumber)

For $i=1 To $v[0]
                $ReadLine=FileReadLine($Part,$i)
        If StringInStr($ReadLine,'Error') Then ExitLoop
        If Not StringInStr($ReadLine,'No.') And StringInStr($ReadLine,':') Then
                $GhostStr=StringLeft($ReadLine,3)&'='&StringMid($ReadLine,6,2)
                If StringMid($GhostStr,1,1)=1 And StringMid($ReadLine,6,2)='  ' Then
                        FileWriteLine($GhostIni,StringReplace($GhostStr&'C:','  ',''))
                Else
                        FileWriteLine($GhostIni,$GhostStr)
                EndIf
                ExitLoop
        EndIf
Next

For $i=1 To $v[0]
                $ReadLine=FileReadLine($Part,$i)
        If StringInStr($ReadLine,'Error') Then ExitLoop
        If Not StringInStr($ReadLine,'No.') And StringInStr($ReadLine,':') Then
                $GhostStr=StringLeft($ReadLine,3)&'='&StringMid($ReadLine,6,2)
                If StringMid($ReadLine,6,2)<>'' And Not StringInStr($GhostStr,'1:1') Then FileWriteLine($GhostIni,$GhostStr)
        EndIf
Next
        FileDelete($Part)
        _FileReadToArray($GhostIni,$v)
For $i=2 To $v[0]
        $ReadLine=StringLeft(FileReadLine($GhostIni,$i),3)
        If StringLeft($ReadLine,1)=1 Then
                FileWriteLine($GhostIni,'LoadP='&$ReadLine)
                ExitLoop
        EndIf
Next

$Var=IniReadSection($GhostIni,'HardDisk')
If @Error Then
    MsgBox(262144, '', '出错了啦! 当前目录找不到 Ghost.InI 文件.')
Else
    For $i = 1 To $Var[0][0]
                $GetLastP=StringMid($Var[$i][0],1,1)
                If StringInStr($GetLastP,'H') Then $GetLastP=StringMid($Var[$i+1][0],1,1)
                If $GetLastP<>1 Then
                ;        MsgBox(262144, '', '键: ' & $Var[$i-1][0])
                        FileWriteLine($GhostIni,'LastP='&$Var[$i-1][0])
                        ExitLoop
                EndIf
        Next
EndIf
        IniWrite($GhostIni,'HardDisk','BackP',IniRead($GhostIni,'HardDisk','LoadP',''))
        IniWrite($GhostIni,'HardDisk','BackZ',3)
        FileWriteLine($GhostIni,'')
        IniWrite($GhostIni,'Setting','Mode',3)
        $DriveType=DriveGetType(StringLeft(@ScriptDir,2))
        If $DriveType='Fixed' Or $DriveType='ReMovAble' Then FIlecopy($GhostIni,@ScriptDir,1)
;================================================================================================
        $GhostStrC=IniRead($GhostIni,'HardDisk','LoadP','')
        $GhostStrL=IniRead($GhostIni,'HardDisk','LastP','')
        $HomeDrive=IniRead($GhostIni,'HardDisk',$GhostStrC,'')
        $LastDrive=IniRead($GhostIni,'HardDisk',$GhostStrL,'')
        FIlecopy($GhostIni,@ScriptDir,1)
        FileDelete($GhostIni)
;================================================================================================
ToolTip('')
        MsgBox(262144,'','本机系统分区对应盘符 == '&$HomeDrive&@Cr&@Cr& _
        '系统分区 Ghost 表示  == '&$GhostStrC&@Cr&@Cr& _
        '本机最后分区对应盘符 == '&$LastDrive&@Cr&@Cr& _
        '最后分区 Ghost 表示  == '&$GhostStrL,5)
;=========== 取本机磁盘最后分区 =============
所要用到的文件(包含编译时用到的图标)均在附件里.

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1金钱 +20 收起 理由
虫子樱桃 + 20 很好

查看全部评分

发表于 2010-1-4 19:23:26 | 显示全部楼层
跟上,贴图,看效果:






本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1金钱 +20 贡献 +5 收起 理由
afan + 20 + 5

查看全部评分

发表于 2010-1-4 22:15:33 | 显示全部楼层
学习了哦~
发表于 2010-2-26 16:07:37 | 显示全部楼层
太好了,要的就是这个效果。
发表于 2012-1-13 20:50:36 | 显示全部楼层
很好。。。。
发表于 2012-4-6 01:35:58 | 显示全部楼层
继续研究隐藏分区。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-6 09:35 , Processed in 0.088835 second(s), 18 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表