Su win 7 va su win 8 no --- che du cojoni
codice:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
' Create a ManagementClass object
Dim managementClass As System.Management.ManagementClass = New System.Management.ManagementClass("Win32_Share")
' Create ManagementBaseObjects for in and out parameters
Dim inParams As System.Management.ManagementBaseObject = managementClass.GetMethodParameters("Create")
Dim outParams As System.Management.ManagementBaseObject
' Set the input parameters
inParams("Description") = "My Shared Files"
inParams("Name") = "TIE"
inParams("Path") = ("C:\Test") ' This is a path to existing directory
inParams("Type") = 0
' Disk Drive
' Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, Nothing)
' Check to see if the method invocation was successful
If (CType(outParams.Properties("ReturnValue").Value, Integer) <> 0) Then
Throw New Exception("Unable to share directory.")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub