Results 1 to 6 of 6

Thread: Getting the Share Name

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    Pune, Maharashtra, India
    Posts
    16

    Unhappy

    hi there,
    I am in a real jam.
    in my application, there is a databse on a client's machine that should be accessed from the server.
    Suppose it's path is 'C:\Database'
    how do i get the UNC path for the above mentioned folder. For ex: '\\clientName\clientName_C\Database'. Else how can i access the client database path from the server.

    in short is there a API to get the share name of the drive ??

    Please reply asap at [email protected]

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    This may help but on reading your question a second time I'm not sure if this is what you want...


    Use the very useful but not very well known Scripting Runtime.

    Click on PROJECT / REFERENCES and select "Microsoft Scripting Runtime" from the list.

    In code;

    Code:
    Dim fso As New FileSystemObject
    Dim drv As Drive
    
    For Each drv In fso.Drives
        Debug.Print drv.DriveLetter & vbTab & drv.ShareName
    Next
    This will display the drive letter and sharename for each drive on your system in the Immediate Window.
    You can use

    [variable] = fso.Drives("S").Sharename

    to get the sharename of the S: drive for example.


    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    Pune, Maharashtra, India
    Posts
    16

    Thumbs down

    Hey, thanx for the same
    But it will not work.
    you see, the sharename property is used only for mapped drives of other computers.
    i used all the fso's. doesn't work
    what i want is to know the sharename of my drive itself.
    in the api listing there is an API called WnetGetuniversalName or something like that.
    know how to use that ???
    Thanx once again

  4. #4
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    Did you ever get this problem resolved?

    I am looking for the exact same solution....

  5. #5
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Have you tried using the registry? In Windows 95, 98, and Millenium, there is the following key:

    HKLM\Security\Access\

    And each sub key under this key represents a shared folder. Since I don't have these OSs, I can't give you more info on this one.

    In other Windows OSs, the key is:

    HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares\

    And each value in this key represents a shared folder. The data for each value contains the actual path, as in "Path=c:\data\databases".

    So, you could loop through each key/value (depending on OS) and look for the one that contains the path to the database. To get the actual share, just add the computer name to the front. To get the computername, you can do Environ("%computername%).
    ~seaweed

  6. #6
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    Thanks, but that only solves half my problem.

    See my newer post for the whole picture:

    http://www.vbforums.com/showthread.p...hreadid=241285

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width