Вы не должны были выглядеть очень тяжело.
Private Function EnableDisableICS(ByVal sPublicConnectionName As String, ByVal sPrivateConnectionName As String, ByVal bEnable As Boolean)
Dim bFound As Boolean
Dim oNetSharingManager, oConnectionCollection, oItem, EveryConnection, objNCProps
oNetSharingManager = CreateObject("HNetCfg.HNetShare.1")
oConnectionCollection = oNetSharingManager.EnumEveryConnection
For Each oItem In oConnectionCollection
EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection(oItem)
objNCProps = oNetSharingManager.NetConnectionProps(oItem)
If objNCProps.name = sPrivateConnectionName Then
bFound = True
MsgBox("Starting Internet Sharing For: " & objNCProps.name)
If bEnable Then
EveryConnection.EnableSharing(1)
Else
EveryConnection.DisableSharing()
End If
End If
Next
oConnectionCollection = oNetSharingManager.EnumEveryConnection
For Each oItem In oConnectionCollection
EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection(oItem)
objNCProps = oNetSharingManager.NetConnectionProps(oItem)
If objNCProps.name = sPublicConnectionName Then
bFound = True
MsgBox("Internet Sharing Success For: " & objNCProps.name)
If bEnable Then
EveryConnection.EnableSharing(0)
Else
EveryConnection.DisableSharing()
End If
End If
Next
Return Nothing 'bEnable & bFound
End Function
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
EnableDisableICS("YOUR ACTIVE NETWORK", "YOUR ADAPTOR TO SHARE", True)
End Sub
Это произошло прямо с SuperUser
Есть ли какие-либо шаги шагом руководство, что тип УИ и тулбокса элементов я должен добавить, чтобы сделать его работу? –