Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 23-03-2007
smartlog smartlog is offline
Registrado
 
Registrado: mar 2007
Posts: 1
Poder: 0
smartlog Va por buen camino
Comprobar puerto 80 desde inno setup

Hola soy nuevo en este hilo y queria explicaros mi caso, quizá no esté dando con el hilo adecuado, pero tengo que empezar por algun sitio.

Estoy haciendo un instalador con inno setup 5.11 que utiliza pascal scripting y necesitaría comprobar si el puerto 80 , ya está ocupado. Esto viene porque también instalaré apache con el instalador y claro si el puerto ya está ocupado...

Muchas gracias por vuestra atención...
Responder Con Cita
  #2  
Antiguo 26-03-2007
Avatar de Ñuño Martínez
Ñuño Martínez Ñuño Martínez is offline
Moderador
 
Registrado: jul 2006
Ubicación: Ciudad Catedral, Españistán
Posts: 6.000
Poder: 25
Ñuño Martínez Tiene un aura espectacularÑuño Martínez Tiene un aura espectacular
Inno Setup permite cargar y utilizar una DLL. Mira en la ayuda del mismo, en la sección "Pascal Scripting: Using DLLs" para más información.
__________________
Proyectos actuales --> Allegro 5 Pascal ¡y Delphi!|MinGRo Game Engine
Responder Con Cita
  #3  
Antiguo 26-03-2007
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 24
seoane Va por buen camino
Bueno, la dll para comprobar si el puerto esta ocupado te la doy yo.
Código Delphi [-]
library Puertos;

uses
  Windows, Winsock;

{$R *.res}

type
  MIB_TCPROW = record
    dwState: DWORD;
    dwLocalAddr: DWORD;
    dwLocalPort: DWORD;
    dwRemoteAddr: DWORD;
    dwRemotePort: DWORD;
  end;
  PMIB_TCPROW = ^MIB_TCPROW;

  MIB_TCPTABLE = record
    dwNumEntries: DWORD;
    table: array[0..0] of MIB_TCPROW;
  end;
  PMIB_TCPTABLE = ^MIB_TCPTABLE;

function GetTcpTable(pTcpTable: PMIB_TCPTABLE; var pdwSize: DWORD;
  bOrder: BOOL): DWORD; stdcall; external 'iphlpapi.dll';

function EstaOcupado(Puerto: Integer): BOOL; stdcall;
var
  TcpTable: PMIB_TCPTABLE;
  Size, i: DWORD;
begin
  Result:= FALSE;
  GetMem(TcpTable,sizeof(MIB_TCPTABLE));
  Size:= 0;
  if GetTcpTable(TcpTable, Size, TRUE) = ERROR_INSUFFICIENT_BUFFER then
  begin
    FreeMem(TcpTable);
    GetMem(TcpTable,Size);
  end;
  try
    if (GetTcpTable(TcpTable, Size, TRUE) = NO_ERROR) then
      for i:= 0 to TcpTable.dwNumEntries - 1 do
        if (TcpTable.table[i].dwState = 2) then
          if htons(TcpTable.table[i].dwLocalPort) = Puerto then
        begin
          Result:= TRUE;
          break;
        end;
  finally
    FreeMem(TcpTable);
  end;
end;

exports EstaOcupado;

begin
end.
La librería anterior exporta la función "EstaOcupado" que devuelve TRUE si el puerto esta ocupado. Desde delphi la llamaríamos así:
Código Delphi [-]
// La declaramos
function EstaOcupado(Puerto: Integer): BOOL; stdcall; external 'Puertos.dll';

// La usamos
  ShowMessage(BoolToStr(EstaOcupado(80),TRUE));
Al parecer, según Ñuño, con Pascal Scripting se pueden llamar funciones incluidas en una dll, así que con esto debería ser suficiente para hacer lo que tu quieres.

Última edición por seoane fecha: 26-03-2007 a las 15:09:27.
Responder Con Cita
  #4  
Antiguo 26-03-2007
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 24
seoane Va por buen camino
Estuve haciendo un par de pruebas en Inno setup, y teniendo en cuenta que es el primer script que hago no parece muy difícil. Añadí la dll "Puertos.dll" a los archivos del proyecto y utilizo el siguiente script:
Código:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
AppName=My Program
AppVerName=My Program 1.5
AppPublisher=My Company, Inc.
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
CreateAppDir=no
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "C:\Puertos.dll"; DestDir: "{tmp}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[code]
//importing a Windows API function
function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer;
external 'MessageBoxA@user32.dll stdcall';

//importing a custom DLL function
function EstaOcupado(Puerto: Integer): Boolean;external 'EstaOcupado@files:Puertos.dll stdcall';

function NextButtonClick(CurPage: Integer): Boolean;
var
  hWnd: Integer;
begin
  if CurPage = wpWelcome then begin
    hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
    if EstaOcupado(80) then
      MessageBox(hWnd, 'Esta ocupado', 'MessageBoxA', MB_OK)
    else
      MessageBox(hWnd, 'No esta ocupado', 'MessageBoxA', MB_OK);
  end;
  Result := True;
end;

Última edición por seoane fecha: 26-03-2007 a las 16:06:19.
Responder Con Cita
Respuesta



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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
ayuda con inno setup Alexita22 OOP 1 09-08-2006 07:12:25
inno setup 5 Cosgaya Varios 0 10-01-2006 13:09:38
Inno Setup Ini? marceloalegre Varios 2 07-12-2005 20:49:17
ayuda con inno setup Clantt Varios 1 07-10-2005 17:30:11
Inno Setup tarco35 Varios 0 09-04-2005 16:48:01


La franja horaria es GMT +2. Ahora son las 23:40:59.


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