编码实现用程序开端口-AngelHis
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-模块/函数/VBA


编码实现用程序开端口

发表时间:2020/5/2 23:41:44 评论(0) 浏览(3301)  评论 | 加入收藏 | 复制
   
摘 要:网上的例子——编码实现用程序开端口。
正 文:
Option Compare Database
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群(群号:198465573)
 
 相关文章
如何打开1433端口\如何打开SQL2005的1433端口  【风行  2012/8/3】
如何打开sql server 2005 的1433端口  【杜超-2号  2013/10/19】
SQLServer 2005提示:无法打开到主机localhost...  【网络  2014/4/20】
勒索病毒防范及关闭445端口设置方法  【杜超  2017/5/15】
FTP、sqlsever外网访问端口映射设置  【凝听  2017/11/2】
SQL Server默认端口:1433端口   【缪炜  2018/6/1】
Access快速开发平台企业版--数据库服务器配置设置端口号方法  【麥田  2019/10/29】
常见问答
技术分类
相关资源
文章搜索
关于作者

AngelHis

文章分类

文章存档

友情链接