我想制作一个热点应用程序,但我的主要问题是ICS无法自动打开。我已经在这个问题上搜索了整个网络,但没有找到有用的东西。请在此处与希望我能在这里得到一些帮助。
答案 0 :(得分:0)
你一定不是很努力。
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