Sign in to follow this  
Followers 0

List optical drives and store in variable

6 posts in this topic

Posted

Hi,

Can someone help me, I basically want a combobox that displays a list of optical drives (or just the burners if possible) and if one is selected then it will store it in a variable.

does anyone know how 2 do this?

thanks

Share this post


Link to post
Share on other sites



Posted

am632,

Try using the Search function - I remember seeing a UDF out there somewhere which identifies burner drives. :)

M23

Share this post


Link to post
Share on other sites

Posted

This is how add to a ComboBox (no error checking added) for your reference. Plus have a look at _WinAPI_GetDriveType() in by Yashied.

_Main()

Func _Main()
    Local $iCombo, $aDrive, $sDriveData = "Please Select A Drive..." & "|", $sRead
    GUICreate("Optical Drives", 210, 60)
    $iCombo = GUICtrlCreateCombo("", 5, 5)
    $iButton = GUICtrlCreateButton("Select", 140, 32.5, 65, 20)

    $aDrive = DriveGetDrive("CDROM")
    For $i = 1 To $aDrive[0]
        $sDriveData &= StringUpper($aDrive[$i]) & "\" & "|"
    Next
    GUICtrlSetData($iCombo, $sDriveData, "Please Select A Drive...")

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case -3
                Exit
            Case $iButton
                $sRead = GUICtrlRead($iCombo)
                If $sRead == "Please Select A Drive..." Then
                    MsgBox(16, "You Selected", "Please Select A Drive.")
                Else
                    MsgBox(16, "You Selected", $sRead)
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>_Main

Share this post


Link to post
Share on other sites

Posted

HI, thanks for the replys, your example is gr8, and i have just downloaded the udf which looks very useful

Share this post


Link to post
Share on other sites

Posted (edited)

Function:

#include <Constants.au3>

MsgBox($MB_SYSTEMMODAL, '', 'The media type of the E:\ drive is: ' & _GetDriveMediaType('E:'))

Func _GetDriveMediaType($sDrive)
    Local $oWMIService = ObjGet('winmgmts:\\.\root\cimv2')
    Local $oColItems = $oWMIService.ExecQuery('Select * From Win32_CDROMDrive Where Drive = "' & StringLeft($sDrive, 2) & '"', 'WQL', 0x30), $sReturn = ''
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            $sReturn &= $oObjectItem.MediaType
        Next
    EndIf
    Return SetError($sReturn = '', 0, $sReturn)
EndFunc   ;==>_GetDriveMediaType
Edited by guinness

Share this post


Link to post
Share on other sites

Posted

Looks useful thanks

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