Public Type NETRESOURCE dwScope As Long dwType As Long '用于指定网络的资源类型 dwDisplayType As Long dwUsage As Long lpLocalName As String '指定本地设备 lpRemoteName As String '指定远程网络名 lpComment As String lpProvider As String '指定提供网络资源的供应商 End Type'lpPassword为远程资源的口令,lpUserName为远程资源的用户名,dwFlags标志位用于指定登录时是否重新连接 Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long 'dwFlags设为零或CONNECT_UPDATE_PROFILE。如为零,而且建立的是永久性连接,则在windows下次重新启动时仍会重新连接 'fForce如为TRUE,表示强制断开连接(即使连接的资源上正有打开的文件或作业) Public Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long ================= 共同学习,共同进步
感谢您使用微软产品。您可以通过ADSI方式的IADsFileShare对象得到目录的共享信息包括共享名。 如下例查询共享目录"E:\test"的信息: Dim fserv As Object Dim share As Object Dim shareNew As Object Dim ShareRoot As StringPrivate Sub Command1_Click() ShareRoot = "WinNT://" Set fserv = GetObject("WinNT://COMPUTERNAME/LanmanServer")
Debug.Print "**************************" For Each share In fserv If share.Path = "E:\test" Then Debug.Print share.Name Debug.Print share.Path Debug.Print share.Class Debug.Print share.HostComputer End If Next shareEnd Sub请参考下面的例子: Q234234 How to Manage File Shares Using ADSI http://support.microsoft.com/support/kb/articles/q234/2/34.asp- 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款 (http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。 为了为您创建更好的讨论环境,请参加我们的用户满意度调查 (http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
然后用API函数:REGOPENKEY,REGCLOSEKEY和其他REG开头的函数到注册表里找。
dwScope As Long
dwType As Long '用于指定网络的资源类型
dwDisplayType As Long
dwUsage As Long
lpLocalName As String '指定本地设备
lpRemoteName As String '指定远程网络名
lpComment As String
lpProvider As String '指定提供网络资源的供应商
End Type'lpPassword为远程资源的口令,lpUserName为远程资源的用户名,dwFlags标志位用于指定登录时是否重新连接
Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
'dwFlags设为零或CONNECT_UPDATE_PROFILE。如为零,而且建立的是永久性连接,则在windows下次重新启动时仍会重新连接
'fForce如为TRUE,表示强制断开连接(即使连接的资源上正有打开的文件或作业)
Public Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long
=================
共同学习,共同进步
Dim fserv As Object
Dim share As Object
Dim shareNew As Object
Dim ShareRoot As StringPrivate Sub Command1_Click() ShareRoot = "WinNT://" Set fserv = GetObject("WinNT://COMPUTERNAME/LanmanServer")
Debug.Print "**************************"
For Each share In fserv
If share.Path = "E:\test" Then
Debug.Print share.Name
Debug.Print share.Path
Debug.Print share.Class
Debug.Print share.HostComputer
End If
Next shareEnd Sub请参考下面的例子:
Q234234 How to Manage File Shares Using ADSI
http://support.microsoft.com/support/kb/articles/q234/2/34.asp- 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
编译通不过。
编译通不过。
Set share = fserv.Create("fileshare", "DWNLDShare")报错。“424 要求对象”