AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Firewall Meldung erzwingen
Thema durchsuchen
Ansicht
Themen-Optionen

Firewall Meldung erzwingen

Ein Thema von QuickAndDirty · begonnen am 15. Jan 2013 · letzter Beitrag vom 21. Jan 2013
 
hathor
(Gast)

n/a Beiträge
 
#6

AW: Firewall Meldung erzwingen

  Alt 15. Jan 2013, 17:27
Nicht getestet:

http://code.google.com/p/ryulib4delp...all.pas?edit=1

Delphi-Quellcode:
unit FireWall;

interface

uses
  ActiveX, ComObj,
  Classes, SysUtils;

const
  NET_FW_PROFILE2_DOMAIN = 1;
  NET_FW_PROFILE2_PRIVATE = 2;
  NET_FW_PROFILE2_PUBLIC = 4;

  NET_FW_SCOPE_ALL = 0;
  NET_FW_IP_VERSION_ANY = 2;

  NET_FW_IP_PROTOCOL_TCP = 6;
  NET_FW_ACTION_ALLOW = 1;

procedure AddPortToFirewall(Caption:string; PortNumber:Cardinal);
procedure AddExceptionToFirewall(Caption, Executable: string);

implementation

procedure AddPortToFirewall(Caption:string; PortNumber:Cardinal);
var
  fwMgr,port:OleVariant;
  profile:OleVariant;
begin
  fwMgr := CreateOLEObject('HNetCfg.FwMgr');
  profile := fwMgr.LocalPolicy.CurrentProfile;
  port := CreateOLEObject('HNetCfg.FWOpenPort');
  port.Name := Caption;
  port.Protocol := NET_FW_IP_PROTOCOL_TCP;
  port.Port := PortNumber;
  port.Scope := NET_FW_SCOPE_ALL;
  port.Enabled := true;
  profile.GloballyOpenPorts.Add(port);
end;

procedure AddExceptionToFirewall(Caption, Executable: string);
var
  FirewallMsg: OleVariant;
  Application: OleVariant;
  CurrentProfile: OleVariant;
begin
  CoInitialize(nil);
  try
    FirewallMsg := CreateOLEObject('HNetCfg.FwMgr');
    CurrentProfile := FirewallMsg.LocalPolicy.CurrentProfile;
    Application := CreateOLEObject('HNetCfg.FwAuthorizedApplication');
    Application.ProcessImageFileName := Executable;
    Application.Name := Caption;
    Application.Scope := NET_FW_SCOPE_ALL;
    Application.IpVersion := NET_FW_IP_VERSION_ANY;
    Application.Enabled := True;
    CurrentProfile.AuthorizedApplications.Add(Application);
  finally
    CoUninitialize;
  end;
end;

end.
Mehr Infos:
http://www.activexperts.com/activmon...ndowsfirewall/
http://www.sevenforums.com/tutorials...exception.html
http://www.sevenforums.com/tutorials...-settings.html
.
.

Geändert von hathor (15. Jan 2013 um 17:50 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:37 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz