daemontools.au3

  • Hi,

    ich hab mal eine UDF-Sammelung zum steuern von daemontools gebastelt - vielleicht braucht die ja mal jemand - , da ich sowas noch nicht gefunden habe.

    daemontools.au3

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    ;----------------------------------------------------------------------------------------;
    ; Daemon Tools Functions ;
    ; by Leviathan ;
    ; tested using 4.08HE ;
    ; Author: Leviathan; https://autoit.de/www.autoit.de ;
    ; thanks to bernd670 ;
    ;----------------------------------------------------------------------------------------;

    [/autoit] [autoit][/autoit] [autoit]

    ;----------------------------------------------------------------------------------------;
    ; _unmountdtools( ByRef $path, ByRef $device) ;
    ; $path = path to the daemon.exe ;
    ; $device = 0-4 which should be unmounted; 4 = all devices ;
    ; Returns by success : 1 ;
    ; Returns by wrong path : 2 ;
    ; Returns by wrong device: 3 ; ;
    ;----------------------------------------------------------------------------------------;
    Func _unmountdtools($path, $device)
    If StringRegExp($path, "(daemon.exe)", 0, 1) = 1 then
    If StringRegExp($device, "[01234]") = 1 AND StringLen($device) = 1 Then
    If $device = 4 Then
    Run ($path&" -unmount 0")
    Run ($path&" -unmount 1")
    Run ($path&" -unmount 2")
    Run ($path&" -unmount 3")
    Return 1
    Else
    Run ($path&" -unmount "&$device&" ")
    Return 1
    EndIf
    Else
    Return 3
    EndIf
    Else
    Return 2
    EndIf
    Endfunc ;==> _unmountdtools(ByRef $path, ByRef $device)

    [/autoit] [autoit][/autoit] [autoit]

    ;----------------------------------------------------------------------------------------;
    ; _emulationoptionsdtools($path, $option, $state) ;
    ; Description: lock: locks the dll / noicon: no taskbar icon ;
    ; $path = path to the daemon.exe ;
    ; $option = safedisc, securom, laserlock, rmps, all ;
    ; $state = 1 for on / 0 for off ;
    ; Returns by success : 1 ;
    ; Returns when failed : 0 ;
    ;----------------------------------------------------------------------------------------;
    Func _emulationoptionsdtools($path, $option, $state)
    Dim $pattern = "(safedisc)|(securom)|(laserlock)|(rmps)|(all)"
    If StringRegExp($path, "(daemon.exe)", 0, 1) = 1 AND StringRegExp($option, $pattern, 0,1) = 1 AND StringRegExp($state, "[01]", 0, 1) = 1 AND StringLen($state) = 1 Then
    Select
    Case $option = "safedisc"
    If $state = 1 Then Run ($path&" -safedisc on ")
    If $state = 0 Then Run ($path&" -safedisc off ")
    Return 1
    Case $option = "securom"
    If $state = 1 Then Run ($path&" -securom on ")
    If $state = 0 Then Run ($path&" -securom off ")
    Return 1
    Case $option = "laserlock"
    If $state = 1 Then Run ($path&" -laserlock on ")
    If $state = 0 Then Run ($path&" -laserlock off ")
    Return 1
    Case $option = "rmps"
    If $state = 1 Then Run ($path&" -rmps on ")
    If $state = 0 Then Run ($path&" -rmps off ")
    Return 1
    Case $option = "all"
    If $state = 1 Then
    Run ($path&" -safedisc on ")
    Run ($path&" -securom on ")
    Run ($path&" -laserlock on ")
    Run ($path&" -rmps on ")
    Return 1
    EndIf
    If $state = 0 Then
    Run ($path&" -safedisc off ")
    Run ($path&" -securom off ")
    Run ($path&" -laserlock off ")
    Run ($path&" -rmps off ")
    Return 1
    EndIf
    EndSelect
    Else
    Return 0
    EndIf
    EndFunc ;==> _emulationoptionsdtools($path, $option, $state)

    [/autoit] [autoit][/autoit] [autoit]

    ;----------------------------------------------------------------------------------------;
    ; _mountdtools( $path, $image , $device) ;
    ; Description: mounts an image to a device ;
    ; $path = path to the daemon.exe ;
    ; $image = path to the imagefile ;
    ; $device = 0-3 ;
    ; Returns by success : 1 ;
    ; Returns when failed : 0 ;
    ; thx to bernd670 - DANKE ;
    ;----------------------------------------------------------------------------------------;
    Func _mountdtools($path, $image, $device)
    If StringRegExp($path, "(daemon.exe)", 0, 1) = 1 And StringRegExp($device, "[0123]") = 1 And StringLen($device) = 1 Then
    $command = '"'&$path & '" -mount ' & $device & ', "' & $image & '"'
    run('"'&$path & '" -mount ' & $device & ', "' & $image & '"')
    If @Error Then
    Return 0
    Else
    Return 1
    EndIf
    Else
    Return 0
    EndIf
    EndFunc ;==>_mountdtools

    [/autoit] [autoit][/autoit] [autoit]

    ;----------------------------------------------------------------------------------------;
    ; optionsdtools($path, $option) ;
    ; Description: lock: locks the dll / noicon: no taskbar icon ;
    ; $path = path to the daemon.exe ;
    ; $option = noicon, lock ;
    ; Returns by success : 1 ;
    ; Returns when failed : 0 ;
    ; WARNING USE ONLY IF YOU KNOW WHAT THEY DO!!!! ;
    ;----------------------------------------------------------------------------------------;
    Func _optionsdtools($path, $option)
    If StringRegExp($path, "(daemon.exe)", 0, 1) = 1 And StringRegExp($option, "(lock)|(noicon)") = 1 Then
    Select
    Case $option = "lock"
    Run ($path&" -lock")
    Return 1
    Case $option = "noicon"
    Run ($path&" -noicon")
    Return 1
    EndSelect
    Else
    Return 0
    EndIf
    EndFunc ;==> _optionsdtools($path, $option)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #cs
    Additional information for _optiondtools(§path, §option)
    # -lock
    used to lock the DLL operation to be sure no unauthorized program can load daemon.dll and use its functions. Used mainly in autostart (if 'Autolock' option is enabled), but can be used in command line too. Unlocking can be done from Virtual DAEMON manager or other GUI that is currently running. Note that locking has no effect on DAEMON Manager itself or other programs which have been 'authorized' by us to use the DLL.
    # -noicon
    this option is used to prevent DAEMON Tools from creating a taskbar icon. It has no effect if DAEMON manager is already running or you specified another command (except 'lock') in the command line! DAEMON manager automatically exits after command is executed and does not create taskbar icon.
    #ce

    [/autoit]

    Beispiel:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    #include <daemontools.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $gui = GUICreate("d-tools example", 166, 18, 193, 115, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
    GUICtrlCreatePic("",0,0,166,18,-1,$GUI_WS_EX_PARENTDRAG)
    $mountbutton = GUICtrlCreateButton("mount", 0, 0, 81, 17, 0)
    GUICtrlSetState(-1,$GUI_ONTOP)
    $unmountbutton = GUICtrlCreateButton("unmount", 88, 0, 73, 17, 0)
    GUICtrlSetState(-1,$GUI_ONTOP)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    Global $pathdt = FileOpenDialog("daemon.exe", @WorkingDir, "Exe (*.exe)", 1, "daemon.exe")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    If $msg = $mountbutton Then _mount()
    If $msg = $unmountbutton Then _unmount()
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _mount()
    $image = FileOpenDialog("Select Image", "", "All images (*.iso;*.bwt;*.bin;*.cdi;*.b5t;*.b6t;*.ccd;*.cue;*.mds;*.mdf;*.nrg;*.pdi;*.img)| All files (*.*)")
    $result = _mountdtools($pathdt, $image, 0)
    If $result = 0 Then MsgBox(0,"Error", "Error while mounting")
    ToolTip("mounted")
    sleep(1000)
    ToolTip("")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _unmount()
    _unmountdtools($pathdt, 0)
    ToolTip("unmounted")
    sleep(1000)
    ToolTip("")
    EndFunc

    [/autoit]

    Vielleicht braucht das mal einer XD