Announcement

Collapse
No announcement yet.

GetLogicalDrives Not Finding Mapped Network Drives?

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

  • GetLogicalDrives Not Finding Mapped Network Drives?

    Here is a stripped down excerpt of a routine I use frequently in my programs to find the available drives. This works fine for all drives except mapped network drives.

    For example, I have my daughters computer mapped as drive "Z" in Windows XP. If I run the code below, drive Z is not detected. But if I open the mapped drive in Windows first, THEN this code finds the mapped drive without problems.

    So how do I get my program to detect the mapped drive on it's own?

    Code:
     drives=GetLogicalDrives()
      FOR a=0 TO 25                    '** Get Drives
        IF BIT(drives,a)=1 THEN
          pp$=CHR$(65+a)+":\"
          b=GetDriveType(BYCOPY pp$)
          IF b=>2 AND b<=6 THEN
            a$="Drive "+CHR$(65+a)+":    "
            IF a=0 OR a=1 THEN
              a$=a$+"(Floppy Disk)"
            ELSEIF b=%DRIVE_FIXED THEN
              a$=a$+"("+volname$+")"
            ELSEIF b=%DRIVE_REMOVABLE THEN
              a$=a$+"(Removable Disk)"
            ELSEIF b=%DRIVE_REMOTE THEN
              a$=a$+"(Network Drive)"
            ELSEIF b=5 THEN
              a$=a$+"(CD-ROM)"
            END IF
          END IF
        END IF
      NEXT a
    Anthony Watson, Mountain Software
    www.mountainsoftware.com

  • #2
    You do realize your code reports nothing unless GetDriveType returns something in the range 2 to 6, right?

    You may well be already detecting Z: but not reporting it because it has an unexpected type. Try adding one more ELSE and report "unable to determine Drive type for drive XXX " and see what happens.
    Code:
    %DRIVE_UNKNOWN     = 0
    %DRIVE_NO_ROOT_DIR = 1
    %DRIVE_REMOVABLE   = 2
    %DRIVE_FIXED       = 3
    %DRIVE_REMOTE      = 4
    %DRIVE_CDROM       = 5
    %DRIVE_RAMDISK     = 6
    If "Z:" is an unknown (value 0), removeable (value 1) or a ramdisk (value 6) your code you would not even know it exists.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]ystems.com
    http://www.talsystems.com

    Comment


    • #3
      Michael,

      I've been using that code for years, and used to restrict the drive types for other reasons. I just never pulled it out. Still, I just removed the offending lines and it didn't change anything. I can read my mapped network drive "Z" fine if I connect through Windows first. But if I don't connect, GetLogicalDrives and GetDriveType don't see it's even there.

      I don't know enough about networking to fix it.

      Thanks,

      Anthony
      Anthony Watson, Mountain Software
      www.mountainsoftware.com

      Comment


      • #4
        If the mapped drive/folder share is password protected then it won't show until credentials have been verified. If the credentials have been stored by Explorer then they will be re-verified when an Explorer window is opened. Obviously this won't apply to non-passworded drives but it's a thought.
        kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

        Comment


        • #5
          The mapped network drive is not password protected, but it does have write access disabled (so I can read from the drive on my daughters computer, but not delete or modify anything).

          Windows XP explorer shows the drive as "Disconnected" until I open it. Then it changes to "Connected" and will then be detected by GetLogicalDrives.

          I guess I'm asking how to find disconnected drives and connect to them programmatically?

          Anthony
          Anthony Watson, Mountain Software
          www.mountainsoftware.com

          Comment


          • #6
            I guess I'm asking how to find disconnected drives and connect to them programmatically?
            Registry: HKCU\Network\<drive letter>

            Comment


            • #7
              I guess I'm asking how to find disconnected drives and connect to them programmatically?
              See Win API functions WNetAddConnection2 and WNetConnectionDialog.
              Scott Slater
              Summit Computer Networks, Inc.
              www.summitcn.com

              Comment


              • #8
                I would say it has to do with the "Reconnect on bootup" concept.
                Basically until the drive has been touched somehow, it may be listed, but not connected.
                Engineer's Motto: If it aint broke take it apart and fix it

                "If at 1st you don't succeed... call it version 1.0"

                "Half of Programming is coding"....."The other 90% is DEBUGGING"

                "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                Comment


                • #9
                  PB/WIN: Connecting reconnecting a mapped network drive or network share

                  The "netConnectShare" function will also reconnect a mapped drive that is mapped, but has been disconnected for some reason. Tested on a Windows XP VM
                  kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                  Comment

                  Working...
                  X