获取网路碟机UNC路径-danis
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> 综合其它


获取网路碟机UNC路径

发表时间:2008/10/13 19:26:20 评论(0) 浏览(4795)  评论 | 加入收藏 | 复制
   
摘 要:获取网路碟机UNC路径
正 文:
获取网路碟机UNC路径

Const NO_ERROR             As Long = 0
Const ERROR_MORE_DATA      As Long = 234
Const ERROR_BAD_DEVICE     As Long = 1200
Const ERROR_NO_NETWORK     As Long = 1222
Const ERROR_NOT_SUPPORTED  As Long = 50
Const ERROR_NOT_CONNECTED  As Long = 2250
Const ERROR_EXTENDED_ERROR As Long = 1208
Const ERROR_NO_NET_OR_BAD_PATH As Long = 1203
Const ERROR_CONNECTION_UNAVAIL As Long = 1201
Declare Function WNetGetConnectionA Lib "mpr.dll" (ByVal lpszLocalName As String, _
                 ByVal lpszRemoteName As String, cbRemoteName As Long) As Long

Function GetUNCPath(ByVal strDriveLetter As String, ByRef strUNCPath As String) As Long
  On Local Error GoTo GetUNCPath_Err
  Dim strMsg        As String
  Dim lngReturn     As Long
  Dim strLocalName  As String
  Dim strRemoteName As String
  Dim lngRemoteName As Long

  strLocalName = strDriveLetter
  strRemoteName = String$(255, Chr$(32))
  lngRemoteName = Len(strRemoteName)

  lngReturn = WNetGetConnectionA(strLocalName, strRemoteName, lngRemoteName)

  If lngReturn = NO_ERROR Then
     GetUNCPath = NO_ERROR
     strUNCPath = Trim$(strRemoteName)
     strUNCPath = Left$(strUNCPath, Len(strUNCPath) - 1)
  Else
     GetUNCPath = lngReturn
     strUNCPath = strDriveLetter & "\"
  End If
    
GetUNCPath_End:
  Exit Function
    
GetUNCPath_Err:
  GetUNCPath = ERROR_NOT_SUPPORTED
  strUNCPath = strDriveLetter
  Resume GetUNCPath_End
End Function

Function Load_UNCPath()
  Dim strUNC As String
  If GetUNCPath("F:", strUNC) = NO_ERROR Then
     MsgBox "The UNC of the specified drive is " & strUNC
  Else
     MsgBox "There was a problem, sorry!"
  End If
End Function

Access软件网交流QQ群(群号:198465573)
 
 相关文章
隐藏access数据库主窗口的方法\DoCmd.RunComman...  【竹笛  2004/9/24】
优化 DoCmd.RunCommand acCmdAppMinim...  【andymark  2009/2/6】
DoCmd.RunCommand方法常量含义(部分)  【网上收集  2010/5/6】
Docmd.RunCommand方法之 参数说明\DoCmd.Ru...  【羽扇子君  2011/3/3】
函数Function与Sub过程的区别  【杜超-2号  2013/4/7】
常见问答
技术分类
相关资源
文章搜索
关于作者

danis

文章分类

文章存档

友情链接