Sign in to follow this  
Followers 0
froufrou

Imapi2 Help

9 posts in this topic

#1 ·  Posted (edited)

i read all the post on the imapi2 UDF but this one little thing is driving me crazy.

if i use this code of course i get the drive letters one after another in a msgbox.

but how would i get the drive letters to fill in a combo box.

$ids = _IMAPI2_DrivesGetID()
If $ids[0] = 0 Then Exit
For $i = 1 To $ids[0]
;~; Get the object
    $drive = _IMAPI2_DriveGetObj($ids[$i])
    If IsObj($drive) = 0 Then ContinueLoop
$letters = _IMAPI2_DriveGetLetter($drive)
MsgBox(4096,"",$letters)
    Next

And just in case anyone cares,i've been using autoit for bout 6 months and just want to thank the developers,its a great program.

and i read the forums all the time for answers to my problems,but i just couldnt find an answer to this one.And this is my first post here.

Edited by froufrou

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi & welcome to the forums :D

The first one's free :D

$hWnd = GUICreate("Drives", 300, 50)

$ids = _IMAPI2_DrivesGetID()
If $ids[0] = 0 Then Exit
For $i = 1 To $ids[0]
;~; Get the object
    $drive = _IMAPI2_DriveGetObj($ids[$i])
    If IsObj($drive) = 0 Then ContinueLoop
    $letters = _IMAPI2_DriveGetLetter($drive)
    If $i = 1 Then
        $combo = GUICtrlCreateCombo($letters & ":", 10, 10, 280)
    Else

        GUICtrlSetData(-1, $letters & ":")
    EndIf

;~  MsgBox(4096, "", $letters)
Next
GUISetState(@SW_SHOW)
Do
Until GUIGetMsg() = -3
Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Thank-You for the welcome and the quick reply.

I included the whole script so you could see whats happens.Only one drive will be inserted to the combo.i plan on combining the 2 combos once i can figure this drive letter problem out.

and by the way Thank you very much for these wonderful Imapi2 functions.

#include <Array.au3>
#include<File.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 440, 60, 192, 124)
$Combo1 = GUICtrlCreateCombo("", 144, 16, 289, 25)
$Combo2 = GUICtrlCreateCombo("", 16, 16, 33, 25)
GUISetState(@SW_SHOW)
HotKeySet("{ESC}", "Terminate")
$ids = _IMAPI2_DrivesGetID()
If $ids[0] = 0 Then Exit
For $i = 1 To $ids[0]
;~; Get the object
    $drive = _IMAPI2_DriveGetObj($ids[$i])
    If IsObj($drive) = 0 Then ContinueLoop
    $letters = _IMAPI2_DriveGetLetter($drive)
    If $i = 1 Then
    EndIf
;~ MsgBox(4096,"",$letters)
Next
_ArrayTrim($ids, 13)
_ArrayTrim($ids, 61, 1)
$yu = _ArrayToString($ids, "|", 1)

GUICtrlSetData($Combo1, $yu)
GUICtrlSetData($Combo2, $letters & ":")



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd


Func Terminate()
    Exit 0
EndFunc  ;==>Terminate

; #FUNCTION#;===============================================================================
;
; Name...........: _IMAPI2_DrivesGetID
; Description ...: Returns the unique id for all the drives on the system
; Syntax.........: _IMAPI2_GetDrivesID()
; Parameters ....:
; Return values .: Success - An array with all the unique ids for the drives on the system (element 0 is count)
;               : Failure -
; Author ........: Andreas Karlsson (monoceres)
; Modified.......:
; Remarks .......:
; Related .......: _IMAPI2_StartDrive
; Link ..........;
; Example .......; No
;
;;==========================================================================================

Func _IMAPI2_DrivesGetID()
    Local $oDiscmaster, $iCount
    $oDiscmaster = ObjCreate("IMAPI2.MsftDiscMaster2")
    If Not IsObj($oDiscmaster) Then Return -1
    $iCount = $oDiscmaster.Count()
    Local $sArray[$iCount + 1]
    $sArray[0] = 0
    For $i = 1 To $iCount
        If StringMid($oDiscmaster.Item($i - 1), 5, 4) = "scsi" Then
            ReDim $sArray[$sArray[0] + ($iCount - $i + 1)]
        Else
            $sArray[0] += 1
            $sArray[$sArray[0]] = $oDiscmaster.Item($i - 1)
        EndIf
    Next
    $oDiscmaster = ""
    Return $sArray
EndFunc  ;==>_IMAPI2_DrivesGetID

; #FUNCTION# ====================================================================================================

================
; Name...........: _IMAPI2_DriveGetObj
; Description ...: Get the object of a drive using the unique id for the drive
; Syntax.........: _IMAPI2_DriveGetObj($sUniqueId)
; Parameters ....: $sUniqueId - Unique id for the drive to get object
; Return values .: Success - Object to the drive
; Author ........: Andreas Karlsson (monoceres)
; Modified.......:
; Remarks .......:
; Related .......: _IMAPI2_GetDrivesID
; Link ..........;
; Example .......; No
; ====================================================================================================

===========================
Func _IMAPI2_DriveGetObj($sUniqueId)
    Local $oRecorder = ObjCreate("IMAPI2.MsftDiscRecorder2")
    $oRecorder.InitializeDiscRecorder($sUniqueId)
    Return $oRecorder
EndFunc  ;==>_IMAPI2_DriveGetObj

; #FUNCTION# ====================================================================================================

================
; Name...........: _IMAPI2_DriveGetLetter
; Description ...: Gets the letter of a drive using the object for the drive
; Syntax.........: _IMAPI2_DriveGetLetter(ByRef $oRecorder)
; Parameters ....: $oRecorder - Object of the drive
; Return values .: Success - Letter
; Author ........: Andreas Karlsson (monoceres)
; Modified.......:
; Remarks .......:
; Related .......: _IMAPI2_DriveGetObj
; Link ..........;
; Example .......; No
; ====================================================================================================

===========================
Func _IMAPI2_DriveGetLetter(ByRef $oRecorder)
    Local $sTemp = $oRecorder.VolumePathNames
    Return StringLeft($sTemp[0], 1)
EndFunc  ;==>_IMAPI2_DriveGetLetter

Share this post


Link to post
Share on other sites

Just move the second GUICtrlSetData() inside the loop. Oh it also seems you're using a modification of my code that are filtering scsi devices so keep that in mind.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

You are Wonderful.Thank-You.I had to change a little more than that but what you said put me on it.Thanks Again. And i forgot i was using the modified func.I only did to weed out my virtual drive.but your Imapi2 udf is great.

THIS WORKS GREAT THANKS AGAIN

$ids = _IMAPI2_DrivesGetID()
If $ids[0] = 0 Then Exit
For $i = 1 To $ids[0]
;~; Get the object
    $drive = _IMAPI2_DriveGetObj($ids[$i])
    If IsObj($drive) = 0 Then ContinueLoop
    $letters = _IMAPI2_DriveGetLetter($drive)
    GUICtrlSetData($Combo2, $letters & ":")
Next
_ArrayTrim($ids, 13)
_ArrayTrim($ids, 61, 1)
$yu = _ArrayToString($ids, "|", 1)
GUICtrlSetData($Combo1, $yu)

MY MESS THAT DIDN'T IS HERE

$ids = _IMAPI2_DrivesGetID()
If $ids[0] = 0 Then Exit
For $i = 1 To $ids[0]
;~; Get the object
    $drive = _IMAPI2_DriveGetObj($ids[$i])
    If IsObj($drive) = 0 Then ContinueLoop
    $letters = _IMAPI2_DriveGetLetter($drive)
[u] If $i = 1 Then-------------------------------------------------HAD TO REMOVE THESE 2 LINES
    EndIf[/u]-------------------------------------------------------AND OF COURSE MOVE SECOND GUICtrlSetData() inside the loop like you said
;~ MsgBox(4096,"",$letters)
Next
_ArrayTrim($ids, 13)
_ArrayTrim($ids, 61, 1)
$yu = _ArrayToString($ids, "|", 1)

GUICtrlSetData($Combo1, $yu)
GUICtrlSetData($Combo2, $letters & ":")

Share this post


Link to post
Share on other sites

@monoceres

If you find the time i have another ?.I know this Imapi2 is old news but i'm lovin it. So that being said,if I use the following code,how do i get it to write the whole folder and not just the contents?

_IMAPI2_AddFolderToFS($fs, $folder)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@monoceres

If you find the time i have another ?.I know this Imapi2 is old news but i'm lovin it. So that being said,if I use the following code,how do i get it to write the whole folder and not just the contents?

_IMAPI2_AddFolderToFS($fs, $folder)
Hi!

There is no clean way to do this with the current UDF.

However it's easy as pie to add a CreateDirectory function, so I'll update the UDF right away. :D

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

@monoceres

Hey I appreciate your help,and thanks for the Func. Before i read your post i was trying new things.And by no means did i know what i was doing but i thought i would share what happened.The change i made is below.

Func _IMAPI2_AddFolderToFS(ByRef $oFileSystem, $sPath)
    Local $oRootDir
    $oRootDir = $oFileSystem.Root
    $oRootDir.AddTree($sPath, False)===============CHANGED
EndFunc  ;==>_IMAPI2_AddFolderToFS

Func _IMAPI2_AddFolderToFS(ByRef $oFileSystem, $sPath)
    Local $oRootDir
    $oRootDir = $oFileSystem.Root
    $oRootDir.AddTree($sPath, True)==============To TRUE
EndFunc  ;==>_IMAPI2_AddFolderToFS

By doing that, it adds the folder and its contents like i was wanting.Don't know why or how but i thought i would let you know.i burned 2 disk just to make sure it wasn't a fluke.

Again Thans for all the help,i'm sure i'll need more.

Share this post


Link to post
Share on other sites

Well hopefully last question on this subject.You never know though.I did get all the functions i've tried to work,finally got ISO burning to work :D . But my question is Did you or you know of anyone that got the progress function to work right?I too can get it flash updates right at the end of the burn,but thats it.The burning process pauses the whole script until done,i mean you can't even move the GUI.Which begs the question is there anyway to stop the pause of script while burning?

Thanks Again

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