473,497 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting the UNC sharename for a mapped drive letter

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
Nov 20 '05 #1
3 8958
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

Nov 20 '05 #2
Thanks Anand!

I'll try that now.

Adam

"Anand Balasubramanian(MSFT)" <an****@online.microsoft.com> wrote in message
news:Mr**************@cpmsftngxa07.phx.gbl...
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

Nov 20 '05 #3
That worked -- thanks again!

Adam

"Anand Balasubramanian(MSFT)" <an****@online.microsoft.com> wrote in message
news:Mr**************@cpmsftngxa07.phx.gbl...
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

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1122
by: Arifah | last post by:
This is regarding File System Watchers of .Net on Windows NT. I think it works for win XP and 2000 machines. I want to watch for events on a mapped drive in NT machine .The drive letter is mapped...
3
6037
by: Mr. Smith | last post by:
Hi All. I need to be able to determine the IP address a drive letter is mapped to. When a user selects a file from a file open dialog, They will, as usual, navigate to the file they want via;...
2
5767
by: giloosh99 | last post by:
Hello, Im grabbing tables via VB code using visual foxpro ODBC drives. The tables directory is in a mapped network drive. The code works fine and does the job, however if the computer is idle for...
0
1261
by: John Dann | last post by:
I run a small LAN with a remote (PC) file store that automatically backs up our data every night. With VB6 there was no problem working with VB projects directly from the central file store. But on...
9
1598
by: KSC | last post by:
Hello, I have been looking through the docs on System.IO and cannot find a way to return a share name on a mapped drive. I have done this using FileSystemObject.Drive.ShareName, but I don't...
3
2139
by: (PeteCresswell) | last post by:
I'm writing a little app in which people open up text files that get massaged and then used to update other files. They us Common File Dialog to navigate to the input files. I'd like to record...
5
1564
by: Marc | last post by:
I am trying to run a web service that has pre-compiled dll's that reference dll's that are on a mapped drive. The web service can not load because it does not see that mapped drive and returns an...
1
3554
by: ArunRJ | last post by:
Hi All, I am new to the networking field. I recently had to share a folder in a Windows XP machine A with another XP machine B. The folder in machine A has some .xls files which I need to access...
5
5897
by: BigM | last post by:
Hi Guys, I am working up a little 'documents' section to an app of mine, where people can add links to docs on various share drives in our LAN, and they are displayed along with other details and...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.