当前位置: 首页>>代码示例>>Python>>正文


Python Dispatch.Scope方法代码示例

本文整理汇总了Python中win32com.client.Dispatch.Scope方法的典型用法代码示例。如果您正苦于以下问题:Python Dispatch.Scope方法的具体用法?Python Dispatch.Scope怎么用?Python Dispatch.Scope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32com.client.Dispatch的用法示例。


在下文中一共展示了Dispatch.Scope方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RegisterWithFirewall

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Scope [as 别名]
def RegisterWithFirewall(exe_name, description):
    # Register our executable as an exception with Windows Firewall.
    # taken from  http://msdn.microsoft.com/library/default.asp?url=\
    # /library/en-us/ics/ics/wf_adding_an_application.asp
    from win32com.client import Dispatch

    # Scope
    NET_FW_SCOPE_ALL = 0

    # IP Version - ANY is the only allowable setting for now
    NET_FW_IP_VERSION_ANY = 2

    fwMgr = Dispatch("HNetCfg.FwMgr")

    # Get the current profile for the local firewall policy.
    profile = fwMgr.LocalPolicy.CurrentProfile

    app = Dispatch("HNetCfg.FwAuthorizedApplication")

    app.ProcessImageFileName = exe_name
    app.Name = description
    app.Scope = NET_FW_SCOPE_ALL
    # Use either Scope or RemoteAddresses, but not both
    # app.RemoteAddresses = "*"
    app.IpVersion = NET_FW_IP_VERSION_ANY
    app.Enabled = True

    # Use this line if you want to add the app, but disabled.
    # app.Enabled = False

    profile.AuthorizedApplications.Add(app)
开发者ID:buildbot,项目名称:buildbot,代码行数:33,代码来源:windows_service.py


注:本文中的win32com.client.Dispatch.Scope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。