编码实现用程序开端口
时 间: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群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- Inputbox输入密码打开查...(12.23)
- 【Access Dsum示例】...(12.16)
- Inputbox输入密码打开窗...(12.13)
- 【Access DCount示...(12.02)

学习心得
最新文章
- 按回车键后光标移动到下一条记录的V...(02.12)
- Access快速开发平台--要实现...(02.10)
- Access快速开发平台--让Pe...(02.08)
- 【Access Dsum示例】用D...(02.07)
- Access对子窗体的数据进行平均...(02.05)
- Access快速开发平台附件上传,...(01.18)
- 【IIF函数示例】用iif函数判断...(01.18)
- Access快速开发平台--如何获...(01.17)
- Access快速开发平台--如何获...(01.15)
- 【Access Format示例】...(01.13)