编码实现用程序开端口
时 间:2020-05-02 23:41:44
作 者:AngelHis ID:20576 城市:沈阳
摘 要:网上的例子——编码实现用程序开端口。
正 文:
Option Explicit
Sub aa(portcode As Integer) '编码实现用程序开端口
On Error GoTo 0
'Set Constants
Const NET_FW_IP_PROTOCOL_UDP = 17
Const NET_FW_IP_PROTOCOL_TCP = 6
Const NET_FW_SCOPE_ALL = 0
Const NET_FW_SCOPE_LOCAL_SUBNET = 1
'Declare variables
'Create the firewall manager object.
Dim fwMgr
Dim Profile
Dim Port
If portcode = 0 Then Exit Sub
Set fwMgr = CreateObject("HNetCfg.FwMgr")
' Get the current profile for the local firewall policy.
Set Profile = fwMgr.LocalPolicy.CurrentProfile
Set Port = CreateObject("HNetCfg.FWOpenPort")
Port.Name = "HTTP"
Port.Protocol = NET_FW_IP_PROTOCOL_TCP '6
Port.Port = portcode
'If using Scope, don't use RemoteAddresses
Port.Scope = NET_FW_SCOPE_ALL ' 0
'Use this line to scope the port to Local Subnet only
'port.Scope = NET_FW_SCOPE_LOCAL_SUBNET ' 1
Port.Enabled = True
'Use this line instead if you want to add the port, but disabled
'port.Enabled = FALSE
On Error Resume Next
Profile.GloballyOpenPorts.Add Port
If Err.Number <> 0 Then
MsgBox "Adding the port failed:" & Err.Description, , "Error Number: " & Err.Number
End If
End Sub
Access软件网官方交流QQ群 (群号:483923997) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access窗体导出PDF】...(04.08)
- 【Access窗体导出PDF】...(04.07)
- Access两种方式实现即时更...(03.01)
- Access隐藏与显示lacc...(01.12)
- 【Access高效办公】将每个...(12.23)
- Access21点游戏源代码(12.13)
- 【Access窗体导出Exce...(11.15)
- 【Access开发】Acces...(11.14)
- 通过Access宏录入数据到选...(11.10)
学习心得
最新文章
- 【Access修改记录示例】编辑选...(04.22)
- 【Access表名称命名建议】将A...(04.20)
- Access学习笔记--用Acce...(04.19)
- 【Access重复项查询示例】将A...(04.17)
- Access快速开发平台企业版--...(04.16)
- 【Access模块示例】通过模块代...(04.15)
- Access查询里面分组合计功能添...(04.13)
- 【Access删除查询】删除数字最...(04.12)
- 显示文件夹中所有文件的修改时间(04.11)
- 铁路工程管理系统;铁路工程管理小程...(04.10)