Solved

Get UNC from mapped drive

Posted on 2004-08-24
6
472 Views
Last Modified: 2010-04-23
How do I get the UNC of a mapped drive in VB.NET? I don't want to use unmanaged code, if possible.
0
Comment
Question by:dbnewbie
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
prakash_prk earned 50 total points
ID: 11879628
Hi
try this

Public Declare Function WNetGetConnection Lib "mpr.dll" Alias _
             "WNetGetConnectionA" (ByVal lpszLocalName As String, _
             ByVal lpszRemoteName As String, ByRef cbRemoteName As Integer) As Integer

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ret As Integer
        Dim out As String = New String(" ", 260)
        Dim len As Integer = 260

        ret = WNetGetConnection("Q:", out, len)
        Msgbox(out)

    End Sub

regards Prakash
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11880547
I don't think that you will find a native method, unless you get really, really clever.  This should work as advertised.

Bob
0
 

Author Comment

by:dbnewbie
ID: 11882533
What is mpr.dll? Is it legacy code?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11882896
It is a Windows API library:

Multiple Provider Router DLL

Bob
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question