jbauer22
asked on
How to get the drive mapping from a drive letter?
I need to get the drive mapping of a specific drive letter.
i.e. I provide "F" and the function returns "//blah/blahblah"
The catch is, I can't use Microsoft Scripting Runtime as a resource. I would preferably like to do this using on of the following Reference Libraries:
Visual Basic for Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OR using an API function
Why not use Microsoft Scripting Runtime you ask? Because I'm trying to compile an executable on an NT4 Server and I don't want to install it. I just want to compile an executable and move it to a directory. If I reference MSR I get a Object Error when I try to run it on NT4. I tried installing the application by creating a package but it ended up causing problems. We couldn't get the server to respond after rebooting.
Any help would be greatly appreciated.
i.e. I provide "F" and the function returns "//blah/blahblah"
The catch is, I can't use Microsoft Scripting Runtime as a resource. I would preferably like to do this using on of the following Reference Libraries:
Visual Basic for Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OR using an API function
Why not use Microsoft Scripting Runtime you ask? Because I'm trying to compile an executable on an NT4 Server and I don't want to install it. I just want to compile an executable and move it to a directory. If I reference MSR I get a Object Error when I try to run it on NT4. I tried installing the application by creating a package but it ended up causing problems. We couldn't get the server to respond after rebooting.
Any help would be greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here's my function
Public Function GetMapping(ByVal strDrive As String) As String
Dim strMapping As String * 255
Dim lngLength As Long
'--- Set Drive letter to proper format
strDrive = Left(strDrive, 1) & ":"
'--- Get Lenth of Buffer
lngLength = Len(strMapping)
'--- Get Mapping
WNetGetConnection strDrive, strMapping, lngLength
'--- Remove Nulls
GetMapping = NV(strMapping)
End Function
'--- I use this globally
Public Function NV(varValue As Variant) As String
If (InStr(varValue, Chr(0)) > 0) Then
varValue = Left(varValue, InStr(varValue, Chr(0)) - 1)
ElseIf IsNull(varValue) Then
varValue = ""
End If
NV = varValue
End Function