Dan Appelman's network APIs
Hi,
Is there anyone familiar with Dan Appelman's dwNetwork class and
WNetGetUniversalName in particular?
Following extract from my program concerning UNC works fine on NT network
with NT and W98 workstations. But for W95 workstation it always fails with
.LastError= 1200 (...BAD_DEVICE)
Below double line is a code, which I called "pure API". Unfortunately it
accepts only a drive letter (I really need full path) but it returns a
correct UNC for passed drive for the same W95 workstation. What can be wrong
and/or specific for W95?
Dim objNet As New dwNetwork
Dim objRemoteName As New dwRemoteNameInfo
Const sprocName = vbCrLf & "(:GetUNC)"
Set objRemoteName =
objNet.WNetGetUniversalName(sSourcePath,REMOTE_NAME_INFO_LEVEL)
With objRemoteName
sUniversalName = .lpUniversalName
sConnectionName = .lpConnectionName
sRemainingPath = .lpRemainingPath
End With
With objNet
If .LastError <> 0 Then
MsgBox "Network Error: " & .LastError & sprocName,vbInformation,
frm.Caption
End if
End With '/*objNet*/
Exit_Procedure:
Set objNet = Nothing
Set objRemoteName = Nothing
Exit Function
========================================
==="pure API"===========================
Public Function GetUNCPath(strDriveLetter As String) As String
dim lngReturn as Long
Dim lpszLocalName As String
Dim lpszRemoteName As String
Dim lRemoteName As Long
lpszLocalName = strDriveLetter
lpszRemoteName = String$(255, Chr$(32))
lRemoteName = Len(lpszRemoteName)
lngReturn =WNetGetConnection(lpszLocalName,lpszRemoteName,lRemoteName)
GetUNCPath = Left$(lpszRemoteName, lRemoteName)
Thanks for your time
Regards
Cat