Announcement

Collapse
No announcement yet.

search all HD and USB Drives

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • search all HD and USB Drives

    What I would like to do is when a users put in a USB Drive. My APP looks for it and finds it , Search \\usbdrive\myfile.dat. But I am missing the boat here. I never know what drive letter it will be? So can't put f:\ or h:\ cause I never know what letter it will be..
    Inv. Mark Nelson

  • #2
    What happened when you tried...
    Code:
    open "\\usbDrive\myfile.dat" FOR INPUT AS #6742
    ...????

    Then again, if your user has to insert the thing, he or she must be there and you could prompt them for a drive letter.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      How do I know what drive to use?
      Inv. Mark Nelson

      Comment


      • #4
        You said you found "\\usbdrive" !!!

        Try that in your OPEN - just like I typed it!!!
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          This code will return all drives present. Removable drives such as Floppy, CD-ROM/DVD or USB sticks are reported as DRIVE_REMOVABLE. I would check for all drives of this type but skip drive A:\, this would be acceptable in most cases.

          Code:
          #Compile Exe
          #Dim All
          #Include "win32api.inc"
          Function PBMain
           
            Local i As Long
            Local sDrives As String
            Local szType As Asciiz * 128
           
            sDrives = String$(GetLogicalDriveStrings(0, ByVal %Null), $Nul)
            GetLogicalDriveStrings Len(sDrives), ByVal StrPtr(sDrives)
            sDrives = RTrim$(sDrives, $Nul)
           
            For i = 1 To ParseCount(sDrives, $Nul)
                Select Case Const GetDriveType(Parse$(sDrives, $Nul, i))
                       Case %DRIVE_UNKNOWN: szType = "DRIVE_UNKNOWN"
                       Case %DRIVE_NO_ROOT_DIR: szType = "DRIVE_NO_ROOT_DIR"
                       Case %DRIVE_REMOVABLE: szType = "DRIVE_REMOVABLE"
                       Case %DRIVE_FIXED: szType = "DRIVE_FIXED"
                       Case %DRIVE_REMOTE: szType = "DRIVE_REMOTE"
                       Case %DRIVE_CDROM: szType = "DRIVE_CDROM"
                       Case %DRIVE_RAMDISK: szType = "DRIVE_RAMDISK"
                       Case Else: szType = "Unknown type"
                End Select
                MsgBox Parse$(sDrives, $Nul, i) + $CrLf + "Drive Type: " + szType, , "Drive Number #" + Format$(i)
            Next i
           
          End Function
          kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

          Comment


          • #6
            I took \\usbdrive\myfile.dat to mean a placeholder.
            kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

            Comment


            • #7
              Silly me.

              I mistook "My APP looks for it and finds it " as "My APP looks for it and finds it."

              Guess I should have studied the posted code more carefully, huh?
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                I suppose Mark's first sentence wasn't 100% clear. People who do not have a good grasp of the API would not know where to start, thus no code will be shown.

                In this case, the question was fairly easy. I even took the code from a previous post I located via POFFS:

                http://www.powerbasic.com/support/fo...ML/009207.html
                Last edited by Kev Peel; 6 May 2008, 10:28 AM.
                kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                Comment

                Working...
                X