Jump to content

Array and DriveGetDrive help

Recommended Posts

Using My_Drivers.ini (can be located root of any fixed, usb or cd drive)as a tag file to locate and set the drive as well as reading the info. Everything seemed to be working fine till I tried on a machine with an empty floppy and a couple empty sd card readers. Started getting error no disk please insert disk or something similar.  It's not crashing just excessive error popups.

I tried replacing the second error check with a DriveStatus check but failed miserably. I'm fairly new to arrays but usually I stick to it long enough I can find a solution. This time I'm lost, been trying a couple days on and off and no success. Everything I tried to modify or remove failed

            If @error Then

Please Help!

Global $Profile = IniRead('X:\ProgramData\DEI_PE\Profile.ini', 'MyProfile', 'Profile', 'Unknown')

Func Get_Drive()
    Local $aArray, $aDrives = DriveGetDrive("ALL")
    If @error = 0 Then
        For $i = 1 To $aDrives[0]
            $aArray = _FileListToArrayRec($aDrives[$i] & "", "My_Drivers.ini", 1, -1, 1, 2)
            If @error Then
            For $j = 1 To $aArray[0]
                ;_ArrayDisplay($aArray, '', '', 0, Default, '')
                $tString = StringSplit($aArray[1], "\")
                _ArrayAdd($aArray, $tString)
                _ArrayDelete($aArray, 4)
                _ArrayDelete($aArray, 2)
                _ArrayDelete($aArray, 0)
                ;_ArrayDisplay($aArray, '', '', 0, Default, '')
            Global $Array = ($aArray[0])
            If IniRead($aArray[0], 'Load_at_boot', 'Auto_Load', 'Off') = "Off" Then
                Global $Auto = "Off"
            ElseIf IniRead($aArray[0], 'Load_at_boot', 'Auto_Load', 'Off') = "On" Then
                Global $Auto = "On"
            Global $MyDevices = $aArray[1] & "\My_Drivers\My_Devices\" & $Profile
            Global $MyProfile = $Profile
EndFunc   ;==>Get_Drive

This is just a snippet from the entire code but everything relies on the location and info store by ini file. Need to search all fixed, usb and cd drives

Edited by trashy
Link to post
Share on other sites

Tried DriveGetDrive("REMOVABLE") and also tried DriveGetDrive("FIXED")

Separately they work with no annoying please insert disk(I'll tell you what to insert)

I see no way to combine the two types, one or the other or all?

Edited by trashy
Link to post
Share on other sites

My goal was to find a tag file at the root of any drive. Using the array the way I was I would get the dreaded Please insert disk popup on empty floppy or card reader etc... It was driving me nuts it wasn't a major problem but I wasn't satisfied. For me to say this is nuts I had to think keep it simple dumb it down a little and finally!!!!!!!!  I think this really is simple sweet

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>

Global $aArray = DriveGetDrive($DT_ALL)
Global $tagfile = "\My_Drivers.ini";<<<<<<<<<<<<Here's your tag file

If @error Then
    ; An error occurred when retrieving the drives.
    MsgBox($MB_SYSTEMMODAL, "", "It appears an error occurred.")

Global $aFILEINFO[UBound($aArray)][4]

For $i = 1 To $aArray[0]
    $aFILEINFO[$i][0] = StringUpper($aArray[$i])
    $aFILEINFO[$i][1] = DriveStatus($aFILEINFO[$i][0])
    If $aFILEINFO[$i][1] = "READY" Then
        $bArray = FileFindFirstFile($aFILEINFO[$i][0] & $tagfile)
        If $bArray = "-1" Then
            $bArray = ""
            $bArray = $tagfile
        $aFILEINFO[$i][2] = $bArray
        $aFILEINFO[$i][3] = $aFILEINFO[$i][0]  & $bArray
    _ArraySwap($aFILEINFO, 0, 1, True)
_ArrayDisplay($aFILEINFO, '', '', 0, Default, '')


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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...