Foxtable(狐表)用户栏目专家坐堂 → [求助]文件夹共享问题


  共有1927人关注过本帖树形打印复制链接

主题:[求助]文件夹共享问题

帅哥哟,离线,有人找我吗?
pcxjxjhkw
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1791 积分:12764 威望:0 精华:1 注册:2013/7/18 15:51:00
[求助]文件夹共享问题  发帖心情 Post By:2015/11/24 11:10:00 [只看该作者]

如何用代码将指定文件夹共享并设置为隐藏?

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/24 11:20:00 [只看该作者]

mark 创建共享文件夹

 

Try
    Dim managementClass As New System.Management.ManagementClass("Win32_Share")
   
    Dim inParams As object = managementClass.GetMethodParameters("Create")
    Dim outParams As object
   
    inParams("Description") = "注释"
    inParams("Name") = "test共享"
    inParams("Path") = "d:\test"
    inParams("Type") = &H0
   
    outParams = managementClass.InvokeMethod("Create", inParams, Nothing)
   
    If CUInt(outParams.Properties("ReturnValue").Value) <> 0 Then
        msgbox("设置失败")
    Else
        msgbox("OK")
    End If
Catch ex As exception
    msgbox(ex.message)
End Try

 


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/24 11:24:00 [只看该作者]

取消共享

 

try
    Dim selectQuery As New System.Management.SelectQuery("Select * fr-om Win32_Share Where Name = '" & "test共享" & "'")
    Dim searcher As New System.Management.ManagementObjectSearcher(selectQuery)
    For Each mo As object In searcher.[Get]()
        mo.InvokeMethod("Delete", Nothing, Nothing)
    Next
    msgbox("OK")
catch ex As exception
    msgbox(ex.message)
End try


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/24 11:24:00 [只看该作者]

记得添加引用 System.Management.dll

 回到顶部