自己捣鼓的虚拟光驱源码,高手帮忙分析下!!!!
本帖最后由 CJHFIRE 于 2009-7-11 17:01 编辑运行后拖放*.iso到界面的框中自动挂载镜像到X:盘,怎样调高虚拟光驱镜像的挂载速度?所需的驱动ISODrive.sys及isocmd.exe可从UltraISO安装目录下drivers目录中提取]#include <GuiConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <Process.au3>
#include <Debug.au3>
;Opt('MustDeclareVars', 1)
Global $sFilename = @ScriptFullPath
Global $isofile
Dim $pthDrive, $pthDir, $pthFName, $pthExt
$isocmddir=@AppDataCommonDir&"\isocmd.exe"
;~ if not FileExists($isocmddir) Then
FileInstall("isocmd.exe",$isocmddir)
$sysdir=@AppDataCommonDir&"\ISODrive.sys"
;~ if not FileExists($sysdir)Then
FileInstall("ISODrive.sys",$sysdir)
$hGui = GUICreate("虚拟光驱", 180, 20, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CLIPSIBLINGS,$WS_EX_TOPMOST ),$WS_EX_ACCEPTFILES) ;接受拖放文件
$Edit = GUICtrlCreateLabel("请拖放光盘镜像到方框中!", 1, 1, 178, 18, $ES_CENTER)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
;GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetState(-1, $GUI_ACCEPTFILES) ;接受拖放文件
GUICtrlSetBkColor($Edit, 0xff0000)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
if FileExists ($isocmddir) Then FileDelete($isocmddir)
if FileExists ($sysdir) Then FileDelete($sysdir)
ExitLoop
Case $msg = $GUI_EVENT_DROPPED
$isofile = @GUI_DragFile
$isocmdshort=FileGetShortName($isocmddir)
$isofileshort=FileGetShortName($isofile)
$eachPath = _PathSplit($isofile, $pthDrive, $pthDir, $pthFName, $pthExt)
If $isofile = "" Then
GUICtrlSetData($Edit,"请拖放光盘镜像到方框中!")
ElseIf StringRight($isofile, 3) <> "iso" And StringRight($isofile, 3) <> "udf"And StringRight($isofile, 3) <> "exe" Then
GUICtrlSetData($Edit,"并不是一个支持的映像文件!")
Else
ShellExecute($isocmdshort,"-r ","","open",@SW_HIDE )
ShellExecute($isocmdshort,"-is ","","open",@SW_HIDE)
ShellExecute($isocmdshort,"-changge 1 x: ","","open",@SW_HIDE)
ShellExecute($isocmdshort,"-mount x: "&$isofileshort,"","open",@SW_HIDE)
ShellExecute($isocmdshort,"-v ","","open",@SW_HIDE)
GUICtrlSetData($Edit,"镜像已加载!")
GUICtrlSetBkColor(-1, 0x00ff00)
;MsgBox(0, "恭喜!", "创建虚拟光驱成功!"&@LF&$pthDrive&$pthDir&$pthFName&$pthExt&"已加载!")
EndIf
Case $msg = $GUI_EVENT_PRIMARYDOWN
$isofile =GUICtrlRead($Edit)
$isocmdshort=FileGetShortName($isocmddir)
$isofileshort=FileGetShortName($isofile)
$eachPath = _PathSplit($isofile, $pthDrive, $pthDir, $pthFName, $pthExt)
_RunDOS($isocmdshort&" -eject x:")
GUICtrlSetData($Edit,"请拖放光盘镜像到方框中!")
GUICtrlSetBkColor(-1, 0xff0000)
EndSelect
WEnd
Exit
东西很不错,我完善了下。做出了成品。要的兄弟pm我吧 即然有兄弟做成了成品,就把源码贴出来分享一下罗,呵呵 终于明白什么叫差距了,原作者把源码共享了,而有些人修改了,变成了自己的作品。而源码呢?哎。 是啊·不厚道,可耻 终于明白什么叫差距了,原作者把源码共享了,而有些人修改了,变成了自己的作品。而源码呢?哎。
G,man。 发表于 2010-6-11 10:11 http://www.autoitx.com/images/common/back.gif
呵呵,我们没办法控制别人的行为
但是这无碍于我们互助分享的精神 是个好东东 不错的东西 偶以前也写过类似的东西,贴出来给大家批一下吧:
功能:获取ISO中GHO的相对路径$FilePath=FileOpenDialog ( "请选择镜像文件", @ScriptDir, "所有支持的文件格式(*.GHO;*.ISO;*.MDF;*.MDS)Ghost镜像文件(*.GHO)|IMageX镜像文件(*.WIM)|所有文件(*.*)",3)
If StringRight($FilePath,3)="gho" Then
ElseIf StringRight($FilePath,3)="iso" Or StringRight($FilePath,3)="mdf" Or StringRight($FilePath,3)="mds"Then
FileInstall("isocmd.exe",@TempDir&"\isocmd.exe")
fileInstall("ISODrive.sys",@TempDir&"\ISODrive.sys")
FileDelete(@TempDir&"\ISODriver.log")
RunWait("cmd /c isocmd.exe -Number 1 & isocmd.exe -Install &" & _
"isocmd.exe -print >"&@TempDir&"\ISODriver.log ",@TempDir,@SW_HIDE)
$ISODriverLine=FileReadLine(@TempDir&"\ISODriver.log",2)
; MsgBox(4096,"haha",$FilePath)
If Not @error Then
$ISODriverA=StringSplit($ISODriverLine,"[")
$ISODriverB=StringSplit($ISODriverA,"]")
$ISODriver=StringLeft($ISODriverB,1)
; MsgBox(4096,"haha",$ISODriver)
RunWait("cmd /c isocmd.exe -Install & isocmd -Mount "&$ISODriver&': "'&$FilePath&'" ',@ScriptDir,@SW_HIDE)
Sleep(100)
Dim $DriverType,$DriverSpace1,$resetnum
While 1
If $resetnum>=200 Then ExitLoop
Dim $DriverType=DriveGetFileSystem($ISODriver&':')
If $DriverType="CDFS" Then
$DriverSpace1=DriveSpaceTotal($ISODriver&':')
If $DriverSpace1 > 3 Then ExitLoop
EndIf
Sleep(50)
$resetnum+=1
WEnd
Sleep(100)
$ISOFile=FileOpenDialog("请选择系统文件",$ISODriver&":","系统文件(*.GHO)",3)
$IsoFilein=StringTrimLeft($ISOFile,3)
If $IsoFilein<>"" Then
MsgBox(4096,"您所选的文件为",$IsoFilein)
Else
MsgBox(4096,"错误","请重新选择GHOST文件")
EndIf
Else
MsgBox(4096,"错误","无法找到驱动器 "&@CRLF &"请重试")
EndIf
RunWait("cmd /c isocmd.exe -remove",@ScriptDir,@SW_HIDE)
EndIf
页:
[1]