本程序是利用vb读写文件来实现的,再通过调用计算机中的explorer运行新建的文件,程序思想是通过dos命令建立虚拟无线热点,因此你的计算机必须要求带无线网卡,如果你的计算机有无线网卡但不能运行,请尝试升级网卡驱动。由于运行当中会调用explorer程序,和某些计算机病毒的投放方法有所相同,所以程序在运行时会引起一些安全软件的误判。程序运行时会在C:\Users\Administrator\Documents目录下生成文件。 还有许多不足,希望大家指出改进!
程序源码如下:
Public a As Integer, e As Integer, f As Integer, b As String, c As String, d As String Private Sub Command2_Click() b = Text1.Text c = Text2.Text d = "netsh wlan set hostednetwork mode=allow" If b = "" Or c = "" Then MsgBox "请填写新建无线网络名称或密码!", 48, "错误!" Else If Len(c) = 8 Then Open "C:\Users\Administrator\Documents\wifibuild.bat" For Output As #1 Print #1, "netsh wlan set hostednetwork mode=allow", "ssid="; b, "key="; c Print #1, "netsh wlan start hostednetwork" Close #1 Shell "explorer.exe " & "C:\Users\Administrator\Documents\wifibuild.bat", 1 Label5.Caption = "已连接" Timer1.Enabled = True Else MsgBox "密码长度应为8位!", 48, "错误!" End If End If End Sub Private Sub Command3_Click() If Dir("C:\Users\Administrator\Documents\wifibuild.bat") <> "" Then Open "C:\Users\Administrator\Documents\wifiend.bat" For Output As #1 Print #1, "netsh wlan set hostednetwork mode=disallow" Shell "explorer.exe " & "C:\Users\Administrator\Documents\wifiend.bat", 1 Close #1 Timer1.Enabled = False Else MsgBox "您还没有创建wifi热点!", 48, "错误!" End If End Sub Private Sub Form_Load() a = 0 e = 0 f = 0 End Sub Private Sub Form_Unload(Cancel As Integer) If Dir("C:\Users\Administrator\Documents\wifibuild.bat") <> "" Then Kill "C:\Users\Administrator\Documents\wifibuild.bat" End If If Dir("C:\Users\Administrator\Documents\wifiend.bat") <> "" Then Kill "C:\Users\Administrator\Documents\wifiend.bat" End If End Sub
Private Sub Option1_Click() Text2.PasswordChar = "" End Sub
Private Sub Option2_Click() Text2.PasswordChar = "*" End Sub
Private Sub Timer1_Timer() r: a = a + 1 If a = 60 Then e = e + 1 a = -1 GoTo r End If If e = 60 Then f = f + 1 e = 0 End If Label6.Caption = f & "小时" & e & "分钟" & a & "秒" End Sub
附图: 1.未连接 2.已连接 3. 4.打开网络和共享中心——》更改适配器设置,会发现多了个无线网络连接2 5.设置宽带共享 之后你就可以用你的手机连接你的电脑共享网络上网,再也不怕月末流量报警了有木有! 注意: 程序运行点击创建wifi时会出现如下情况 点允许执行就行了,我试过用cmd.exe直接打开新建的文件,好像不行,所以只能用explorer了。
完整的Word格式文档51黑下载地址:
vb建无线wifi热点(附图).doc
(224.5 KB, 下载次数: 16)
|