我使用此代码共享文件夹:
Public Sub Share()
Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams("Description") = "My Description"
inParams("Name") = "Share Name"
inParams("Path") = "D:\Folder"
inParams("Type") = &H0
Dim outParams As ManagementBaseObject = managementClass.InvokeMethod("Create", inParams, Nothing)
If Convert.ToUInt32(outParams.Properties("ReturnValue").Value) <> 0 Then MessageBox.Show("Unable to share directory.")
MessageBox.Show("Shared folder successfully!")
End
Sub
Run Code Online (Sandbox Code Playgroud)
现在我想要的是定义可以通过网络访问该文件夹的用户?我怎么能这样做?
谢谢!
此博客文章介绍了如何设置共享权限:
该代码是用C#编写的,因此将其移植到VB中不是问题。
| 归档时间: |
|
| 查看次数: |
2827 次 |
| 最近记录: |