Getting the UNC sharename for a mapped drive letter

  • Thread starter Thread starter Adam Froio
  • Start date Start date
A

Adam Froio

Hi,

Is there a way to look up a mapped drive letter's share name using VB.NET?

I'd like to get \\server\share from O:\

I'm pretty sure it can be done by looking it up in the registry or using
WMI, but I'm wondering if there's an easier way.

Thanks!
Adam
 
Hi,
You can use the following API

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


Then use the following code to call this API


Dim y As String
y = Space(100)

WNetGetConnection("Y:", y, 100)
MsgBox(y)

Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks
 
Back
Top