Ver Mensaje Individual
  #5  
Antiguo 17-07-2006
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Reputación: 23
maeyanes Va por buen camino
Veo que usas un TListView para obtener la lista de DLL's. Como la clase TListItem tiene una propiedad llamada Data, ahí podrías guardar el Handle de la DLL, así te evitas crear la clase TIntegers.

Aquí te pongo parte de tu código usando la propiedad Data de TListItem:

Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
var
  encontrado, n: integer;
  archivo: TSearchRec;
  nodo: TListItem;

begin
  LDLLs.Items.Clear;
  // Busca archivos DLL en el mismo directorio 
  encontrado:=FindFirst(ExtractFilePath(ParamStr(0))+'*.dll',faAnyFile,archivo);
  while encontrado=0 do
  begin
    nodo := ldlls.Items.Add;
    nodo.Caption := archivo.name;
    nodo.Data := Pointer(CargarLibreria(archivo.Name)); // Guardo el Handle del DLL.
    encontrado:=FindNext(archivo);
  end;
  FindClose(archivo);

  // Ejecutar funciones
  for n:=0 to LDlls.ITems.Count-1 do
  begin
    Ldlls.Items[n].Subitems.Clear;
    Ldlls.Items[n].Subitems.Add(GetName(Integer(LDlls.Items[i].Data)));
    Ldlls.Items[n].Subitems.Add(GetVersion(Integer(LDlls.Items[i].Data)));
    Ldlls.Items[n].Subitems.Add(Integer(LDlls.Items[i].Data)));
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
  n: integer;

begin
  for n := 0 to LDlls.Count - 1 do
    LiberarLibreria(Integer(LDlls.Items[i].Data))
end;

Saludos...
Responder Con Cita