久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

如何透過程序來控制 Windows XP防火墻的開關(guān)

瀏覽:139日期:2023-07-02 15:28:57

Dim;objFW;As;Object;;;Set;objFW;=;CreateObject('HNetCfg.FwMgr').LocalPolicy.CurrentProfileWith;objFW.FirewallEnabled;=;True;';True;開啟;,;False;關(guān)閉.ExceptionsNotAllowed;=;True;';[;不允許例外;];選項;,;True;勾;,;反之則不勾End;With或procedure;Set_WindowsXP_FireWall(Enable:;boolean);//;需引用;winsvc,;shellapi//;Set_WindowsXP_FireWall(false);;//;關(guān)閉Windows;Xp;防火//varSCM,;hService:;LongWord;sStatus:;TServiceStatus;beginif;Enable;=;false;thenbeginSCM;:=;OpenSCManager(nil,;nil,;SC_MANAGER_ALL_ACCESS);hService;:=;OpenService(SCM,;PChar('SharedAccess'),;SERVICE_ALL_ACCESS);ControlService(hService,;SERVICE_CONTROL_STOP,;sStatus);CloseServiceHandle(hService);end;end;設(shè)定Port;的部份,不過還沒測試!不過我還是希望寫成簡單形式的函數(shù)庫呼叫方式,大家一起測試吧!出處:http://www-new.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22122056.htmlExample;of;both;adding;and;removing;a;tcp;port;from;the;globaly;open;ports;list;(in;Windows;XP;firewall)Regards,Russell//;Include;ActiveX;and;ComObj;in;uses;clause;(also;Variants;for;D6;and;up)constNET_FW_PROFILE_DOMAIN;;;;;;=;;0;NET_FW_PROFILE_STANDARD;;;;=;;1;constNET_FW_IP_PROTOCOL_TCP;;;;;=;6;NET_FW_IP_PROTOCOL_UDP;;;;;=;17;constNET_FW_SCOPE_ALL;;;=;;0;constNET_FW_IP_VERSION_ANY;;;;;;=;;2;implementation{$R;*.DFM}procedure;TForm1.Button1Click(Sender:;TObject);var;;ovMgr:;OleVariant;ovProfile:;;;;;OleVariant;ovPort:OleVariant;begin//;Create;manager;interfaceovMgr:=CreateOleObject('HNetCfg.FwMgr');//;Resource;protectiontry//;Get;local;profile;interfaceovProfile:=ovMgr.LocalPolicy.CurrentProfile;//;Resource;protectiontry//;Create;new;port;interfaceovPort:=CreateOleObject('HNetCfg.FwOpenPort');try//;Set;port;propertiesovPort.Port:=81;ovPort.Name:='Whatever';ovPort.Scope:=NET_FW_SCOPE_ALL;ovPort.IpVersion:=NET_FW_IP_VERSION_ANY;ovPort.Protocol:=NET_FW_IP_PROTOCOL_TCP;ovPort.Enabled:=True;//;Resource;protectiontry//;Add;to;globally;open;portsovProfile.GloballyOpenPorts.Add(ovPort);//////;....;do;whatever;....////finally//;Remove;from;globally;open;portsovProfile.GloballyOpenPorts.Remove(81,;NET_FW_IP_PROTOCOL_TCP);end;finally//;Release;interfaceovPort:=Unassigned;end;finally//;Release;interfaceovProfile:=Unassigned;end;finally//;Release;interfaceovMgr:=Unassigned;end;end;

主站蜘蛛池模板: 嵊泗县| 白水县| 商都县| 阿拉善盟| 尉氏县| 洪雅县| 鄂州市| 杭州市| 保定市| 海南省| 呼玛县| 遂溪县| 阳泉市| 台前县| 裕民县| 梅河口市| 酒泉市| 长治市| 当涂县| 分宜县| 桐梓县| 府谷县| 巴彦淖尔市| 澄迈县| 自治县| 南雄市| 桐梓县| 松滋市| 邹城市| 横峰县| 海林市| 奈曼旗| 沙湾县| 镇平县| 溧阳市| 晋宁县| 西丰县| 大邑县| 原阳县| 那曲县| 绥化市|