Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.



Public Function strGetUNC(ByVal DriveLetter As String) As String
'                   Ron Mittelman  Rmittelman@ Visto.com
'Here 's a function that can convert a drive letter to a UNC path name.
' Public Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocationName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long
On Error Resume Next
Dim sReturnVal As String
Dim lSize As Long
Dim lResult As Long
strGetUNC = ""
sReturnVal = Space$(255)
lSize = Len(sReturnVal)
DriveLetter = DriveLetter & ":"
DriveLetter = Left$(DriveLetter, InStr(1, DriveLetter, ":"))
lResult = WNetGetConnection(DriveLetter, sReturnVal, lSize)
If lResult = 0 Then
    lSize = InStr(1, sReturnVal, Chr$(0))
    strGetUNC = Left$(sReturnVal, lSize - 1)
End If
'Sub TESTstrGetUNC()
'    MsgBox strGetUNC("c") ' UNCDrive should  contain \\Renrtp\D:
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1

Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.

Public Function strGetUNC(ByVal DriveLetter As String) As String
'                   Ron Mittelman  Rmittelman@ Visto.com
'Here 's a function that can convert a drive letter to a UNC path name.
' Public Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocationName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long
On Error Resume Next
Dim sReturnVal As String
Dim lSize As Long
Dim lResult As Long
strGetUNC = ""
sReturnVal = Space$(255)
lSize = Len(sReturnVal)
DriveLetter = DriveLetter & ":"
DriveLetter = Left$(DriveLetter, InStr(1, DriveLetter, ":"))
lResult = WNetGetConnection(DriveLetter, sReturnVal, lSize)
If lResult = 0 Then
    lSize = InStr(1, sReturnVal, Chr$(0))
    strGetUNC = Left$(sReturnVal, lSize - 1)
End If
'Sub TESTstrGetUNC()
'    MsgBox strGetUNC("c") ' UNCDrive should  contain \\Renrtp\D:
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1