Jump to content



Photo

List optical drives and store in variable


  • Please log in to reply
5 replies to this topic

#1 am632

am632

    Polymath

  • Active Members
  • PipPipPipPip
  • 205 posts

Posted 06 March 2011 - 02:40 PM

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







#2 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 23,252 posts

Posted 06 March 2011 - 02:52 PM

am632,

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

M23
My UDFs:
Spoiler

#3 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 18,240 posts

Posted 06 March 2011 - 03:02 PM

This is how add to a ComboBox (no error checking added) for your reference. Plus have a look at _WinAPI_GetDriveType() in WinAPIEx.au3 by Yashied.
AutoIt         
_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

UDF List:
Spoiler

#4 am632

am632

    Polymath

  • Active Members
  • PipPipPipPip
  • 205 posts

Posted 06 March 2011 - 03:06 PM

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

#5 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 18,240 posts

Posted 06 March 2011 - 03:08 PM

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, 09 April 2013 - 04:22 PM.

UDF List:
Spoiler

#6 engjcowi

engjcowi

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 28 May 2011 - 02:01 PM

Looks useful thanks
Drunken Frat-Boy Monkey Garbage




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users