Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 02-06-2007
jorge82 jorge82 is offline
Baneado
 
Registrado: jun 2005
Ubicación: Mérida, Yucatán, México
Posts: 75
Poder: 19
jorge82 Va por buen camino
Agregar un puerto al firewall de Windows

Código de una función para agregar un puerto como excepción al firewall de Windows XP SP2.
Truco basado a su vez en el truco 382 (Como agregar una aplicación al firewall de Windows).

Código Delphi [-]
uses
   ComObj;

const
   NET_FW_SCOPE_ALL = 0;
   NET_FW_SCOPE_LOCAL_SUBNET = 1;
   NET_FW_IP_PROTOCOL_TCP = 6;
   NET_FW_IP_PROTOCOL_UDP = 17;
      
procedure AgregarPuerto(APort: Integer; AName: string);
var
   fwMgr: Variant;
   Profile: Variant;
   Port: Variant;
begin
   fwMgr := CreateOleObject('HNetCfg.FwMgr');
   Profile := fwMgr.LocalPolicy.CurrentProfile;
   Port := CreateOleObject('HNetCfg.FwOpenPort');
   // El nombre con el que aparecerá la excepción en el Firewall de Windows.
   Port.Name := AName;
   Port.Protocol := NET_FW_IP_PROTOCOL_TCP; // O NET_FW_IP_PROTOCOL_UDP, si el puerto es UDP. 
   Port.Port := APort;
   // El puerto tiene un alcance global, si quieres que el alcance del puerto solo sea una
   // subred local entonces Port.Scope := NET_FW_SCOPE_LOCAL_SUBNET; 
   Port.Scope := NET_FW_SCOPE_ALL;  
   Port.Enabled := TRUE;
   // Agregamos el puerto al firewall.
   Profile.GloballyOpenPorts.Add(Port);
end;
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 11:04:36.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi