Drive.GetInformation problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • SiNisTer
    Forum Member
    • Mar 2007
    • 187

    Drive.GetInformation problem

    Guys,
    I have created a multimedia application and put most of the video content on a DvD drive. The AMS application (i.e the *.exe) is on the users hardrive. What I want to do is to loop through all the CDROM drives that a user may have on his pc and get the Volume label (Label: Multi-Media_A) as well as the Drive letter for that particular drive. I though it would be an easy task but it turned out it wasnt!!

    I used the Drive.Enumerate action to get a list of all of the drives in a table. Then looped through that list to seprate the CR-Rom drives, but when I use the Drive.GetInformation action to read its Volume label I fell into a problem. It specifically needs the drive letter to be entered in the "Drive" Parameter or a set variable like _SourceFolder and didnt recoginze the variable i used during the loop function...

    Please lend a hand guys...

    Thank you
  • Imagine Programming
    Indigo Rose Customer
    • Apr 2007
    • 4252

    #2
    When you use
    Code:
    sDrive="C:"
    nType=Drive.GetType(sDrive);
       if(nType==5)then  --Confirms that its a CDROM or DVDROM drive:)
           --Your actions here:)
       end
    and place that in your For loop and the actions for adding it to a list or something like that, in the place where you now can read "--Your actions here"
    Bas Groothedde
    Imagine Programming :: Blog

    AMS8 Plugins
    IMXLH Compiler

    Comment

    • Esfahan
      Forum Member
      • Oct 2007
      • 233

      #3
      may be useful...
      Attached Files

      Comment

      • SiNisTer
        Forum Member
        • Mar 2007
        • 187

        #4
        @C B programming and webdesign
        Hey man, the function you posted already has been given a value to the Sdrive variable mate. Your method will work perfectly but the problem Im having is that I dont know the drive letter as the user can have multiple CD-Roms.

        @ Esfahan
        Thanks for the post mate...Ill be sure to check it out

        Comment

        • SiNisTer
          Forum Member
          • Mar 2007
          • 187

          #5
          Ahh! Finally

          After breaking my head all night I finally managed it! It was infact quite simple and I just didnt see it. (@Esfahan The - local R = 2; line is what really made me think a little)

          Anyway these are the codes I made. I figured it might be useful to some ppl so I'm posting a slightly modified version of my code which copies a specified file or folder by first checking the Volume Name, since I noticed that there were lots of users with this problem with no real solution posted. Just copy-paste these codes into your project and change the variables. Or download the example:
          *Note: Make sure that you insert a CD or DVD into your DVD/CD-ROM and change the variables to suit your needs before continuing. I have specified the values that you have to change . .

          Code:
          local sLabel;
          --Get the list of *ALL* drives
          local tblDrives = Drive.Enumerate();
          
          --[[The Type of Drive In This case its a (5) CDROM  (2 = Removable Drives (USB) (3 = Fixed Drive) (5 = Optical drives) 
              Change the DriveValue if you want to search a differnt drive]]
          DriveValue = 5
          --Loop thrugh the Table
          for n, DriveLetter in tblDrives do
          
          ---------------------------------EDIT THE FOLLOWING DATA (ONLY THE ONES IN BETWEEN "" MARKS)--------------------------------------
          
          	--[[ERROR MESSAGE INFO (IN CASE THE VOLUME LABEL WAS NOT FOUND
          	============================================================]]
          	--Error Message Title
          	SErrorMsgTitle = "WARNING: NO VOLUME FOUND"
          	--Error Message
          	sErrorMsg = "Sorry the required volume was not found in you DVD-ROM\r\Make sure you insert the correct volume and try again . . .";
          	--===========================================================
          	--THE DIRECTORY YOU WANT TO COPY OR COPY FROM. CHANGE THE FOLDER PATH WITHIN THE "" MARKS
          	TheSourceDir = DriveLetter.."Multimedia\\Videos\\*.*"--copies all the files in the folder
          	--WHERE YOU WANT THE FILES COPIED
          	TheDestDir = "C:\\A Sucessful Business [Presentaion]" 
          	--THE VOLUME LABEL YOU WANT TO COPY FROM
          	Expected_Volume_Name = "MULTI-MEDIA_A" --Remeber that the name is case sensitive. You have to type it *exactly* how it appears in windows explorer
          
          	
          ---------------------------------------------DO NOT EDIT THE FOLLOWING DATA-----------------------------------------------------------------------------	
          --[[*Note: You can however change the (File.Copy) any action that you want but make sure you set the default values right 
                                                  and change and edit the variables accordingly]]	
          	
          	--Get the Drive type
          	local nType = Drive.GetType(DriveLetter);
          	--If we're looking for a CD-ROM
          	if nType == String.ToNumber(DriveValue) then
          		local dinfo = Drive.GetInformation(DriveLetter);
          		if dinfo then
          		sLabel = dinfo.Label;	
          				
          		--Check if Destination Directory exists		
          		DOES__FOLDER_EXIST = Folder.DoesExist(TheDestDir);
          		
          		--If Volume was found and it is a DVD-ROM Drive
          		if sLabel == Expected_Volume_Name and nType == String.ToNumber(DriveValue) then
          		--If Destination Directory Exists then Start Copying
          		if DOES__FOLDER_EXIST == true then
          		StatusDlg.Show(MB_ICONINFORMATION, false);
          		StatusDlg.ShowProgressMeter(true);
          		File.Copy(TheSourceDir, TheDestDir, true, true, false, true)
          		StatusDlg.Hide(); 
          		else
          		--If Destination Directory Does *NOT* Exists then ask the user ether to create a directory or not
          		CreateQuestion = Dialog.Message("CREATE FOLDER", "The destination folder doesn't exist.\r\n Do you want to create the following directory:\r\n\r\n"..TheDestDir, MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1);
          		if CreateQuestion == IDYES then
          		Folder.Create(TheDestDir);
          		StatusDlg.Show(MB_ICONINFORMATION, false);
          		StatusDlg.ShowProgressMeter(true);
          		File.Copy(TheSourceDir, TheDestDir, true, true, false, true)
          		StatusDlg.Hide(); 
          		else
          		Dialog.Message("CANCELLED", "The copying process has been terminated", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
          		end
          		end
          			
          		else
          		--The Error Msg if the volume was not found
          			Dialog.Message(SErrorMsgTitle, sErrorMsg, MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
          			end
          		end
          	end
          end

          Heres an example if you want download instead. Maybe I'll upload this in the examples section cos I noticed it didn't have something an example of how this should be carried out...Btw thank you for offering your hand guys! I do appreciate it...
          Attached Files
          Last edited by SiNisTer; 07-25-2008, 02:28 AM. Reason: Forgot to post the example

          Comment

          • Imagine Programming
            Indigo Rose Customer
            • Apr 2007
            • 4252

            #6
            hahah sorry mate, didn't see that:P
            Code:
            function IsDriveCDROM(sDrive) --or DVDRom
            bReturn = false;
            nType=Drive.GetType(sDrive);
               if(nType==5)then  --Confirms that its a CDROM or DVDROM drive:)
                   bReturn = true;
               end
            return bReturn
            end
            
            tDrives = Drive.Enumerate();
            for i, sDrive in tDrives do
            bIsDrive=IsDriveCDROM(sDrive)
                if(bIsDrive==true)then
                    --actions
                end
            end
            Maybe this will help some people?
            Bas Groothedde
            Imagine Programming :: Blog

            AMS8 Plugins
            IMXLH Compiler

            Comment

            • SiNisTer
              Forum Member
              • Mar 2007
              • 187

              #7
              @ C B programming and webdesign

              Code:
              function IsDriveCDROM(sDrive) --or DVDRom
              bReturn = false;
              nType=Drive.GetType(sDrive);
                 if(nType==5)then  --Confirms that its a CDROM or DVDROM drive:)
                     bReturn = true;
                 end
              return bReturn
              end
              Thanks bro,
              That does improve my code...

              Comment

              Working...
              X