Sign in to follow this  
Followers 0
Draeko

Drive Size

2 posts in this topic

I've been working on an application that runs under BartPE and will, among other things, automatically download an image using Ghost for us.

What I can't figure out is a way to have AutoIt read the size of an entire drive (not a volume) so the user can choose a custom parition size for the Ghost image. I want to be able to create a GUI that will display the entire drive size via a slidebar or other type of interface.

Does anyone know of a way within AutoIt that I can do this? Or failing that, is there a CLI command I can use and have AutoIt read the result from to get the information I need?

Share this post


Link to post
Share on other sites



This?

#include <GuiConstants.au3>

Dim $out

$foo = Run("diskpart.exe", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
If @error Then
    MsgBox(16, "Error", "diskpart.exe not run")
    Exit
EndIf

StdinWrite($foo, "list disk")
StdinWrite($foo)

While 1
    $out &= StdoutRead($foo)
    If @error Then ExitLoop
WEnd
    
$var = StringRegExp($out, "\d*.GB", 3)
;_ArrayDisplay($var)

$hGui = GuiCreate("Test", 300, 200)

$diskLabel = GUICtrlCreateLabel("Selected size: 0", 70, 30, 120, 17)

$diskSlider = GUICtrlCreateSlider(30, 50, 220, 30)
GUICtrlSetLimit(-1, $var[0])

$selButton = GUICtrlCreateButton("Select", 20, 150, 50, 25)

GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    Case $selButton
        MsgBox(64, "Message", "Selected " & GUICtrlRead($diskSlider) & " GB")
    EndSwitch
WEnd

Func WM_HVSCROLL($hWnd, $Msg, $wParam, $lParam)
    
    Switch $LParam
    Case GUICtrlGetHandle($diskSlider)
        GUICtrlSetData($diskLabel, "Selected size: " & GUICtrlRead($diskSlider) & " GB")
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0