外部引用添加:System.Management.dll
Try
Dim managementClass As New System.Management.ManagementClass("Win32_Share")
Dim inParams = managementClass.GetMethodParameters("Create")
Dim outParams As System.Management.ManagementBaseObject
inParams("Description") = "某描述"
inParams("Name") = "某共享名称"
inParams("Path") = "D:\问题\RMT"
inParams("Type") = &H0
outParams = managementClass.InvokeMethod("Create", inParams, Nothing)
If CUInt((outParams.Properties("ReturnValue").Value)) <> 0 Then
msgbox("无法创建.")
Else
msgbox("创建成功")
End If
Catch ex As exception
msgbox(ex.message)
End Try