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

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 03-09-2005
aggg63 aggg63 is offline
Miembro
 
Registrado: sep 2005
Posts: 31
Poder: 0
aggg63 Va por buen camino
Acceso a DLL

Hola.

Estoy desarrollando un motor para jugar a las damas españolas http://www.terra.es/personal9/aggg63/damas/damas.htm con la interficie CheckerBoard http://www.fierz.ch/checkers.htm de Martin Fierz. Ed Gilbert ha desarrollado una DLL que accede a las bases de datos de finales de las damas americanas http://pages.prodigy.net/eyg/Checkers/egdb_rev3.zip. He creado un pequeño programa que intenta acceder a las bases de datos, pero no me carga bien las funciones que exporta la DLL. A continuacion teneis un resumen de las unidades que uso. La primera funcion me identifica la base de datos pero cuando intento abrir un handle con la segunda, me da un error. ¿Alguien puede ayudarme un poco? Gracias.

Código Delphi [-]
 unit uTiposEGDB;
 
 interface
 
 const
   // Color definitions
   EGDB_BLACK = 0; EGDB_WHITE = 1;
   // Values returned by handle->lookup()
   EGDB_UNKNOWN = 0; // value not in the database
   EGDB_WIN = 1; EGDB_LOSS = 2; EGDB_DRAW = 3;
   EGDB_NOT_IN_CACHE = 4; // conditional lookup and position not in cache
   // MTC macros
   MTC_THRESHOLD = 10; MTC_LESS_THAN_THRESHOLD = 1;
   MTC_UNKNOWN = 0;
 
 type
   // Tipos de tablas de finales
   EGDB_TYPE = ( EGDB_KINGSROW_WLD=0, EGDB_KINGSROW_MTC,
   EGDB_CAKE_WLD, EGDB_CHINOOK_WLD,
   EGDB_KINGSROW32_WLD, EGDB_KINGSROW32_MTC,
   EGDB_CHINOOK_ITALIAN_WLD, EGDB_KINGSROW32_ITALIAN_WLD,
   EGDB_KINGSROW32_ITALIAN_MTC);
   // for database lookup stats
   EGDB_STATS = record
   lru_cache_hits,lru_cache_loads,autoload_hits,db_requests,
   db_returns, db_not_present_requests: cardinal;
 end;
 
   EGDB_BITMAP_TYPE = (EGDB_NORMAL=0, EGDB_ROW_REVERSED);
   // This is KingsRow's definition of a checkers position.
   EGDB_NORMAL_BITMAP = record
   black,white,king: cardinal;
 end;
 
   // This is Cake's definition of a board position.
   EGDB_ROW_REVERSED_BITMAP = record
   black_man,black_king,white_man,white_king: cardinal;
 end;
 
   EGDB_BITMAP = record
   case integer of
     0: (normal: EGDB_NORMAL_BITMAP);
     1: (row_reversed: EGDB_ROW_REVERSED_BITMAP);
   end;
   PEGDB_BITMAP = ^EGDB_BITMAP;
   PEGDB_STATS = ^EGDB_STATS;
   // The driver handle type
   PEGDB_driver = ^TEGDB_driver;
   TEGDB_driver = record
   lookup: function (handle: PEGDB_driver; position: PEGDB_BITMAP;
   color: integer; cl: integer):longint; cdecl;
   reset_stats: procedure (handle: PEGDB_driver);
   get_stats: function (handle: PEGDB_driver): PEGDB_STATS;
   verify: function (handle: PEGDB_driver): integer;
   close: function (handle: PEGDB_driver): integer;
   internal_data: pointer;
 end;
 
 type
   TFMensajes = procedure(texto: pAnsiChar); cdecl;
 
 var
   FicheroTexto: TextFile;
   HandleDLL: THandle;
   function IdentificarTablaFinales(directory: pAnsiChar;
     var db_type: EGDB_TYPE; var max_pieces: Integer):integer; stdcal;
   function AbrirTablaFinales(bitmap_type: EGDB_BITMAP_TYPE; pieces,
     cache_mb: Integer;directory: pAnsiChar; FMensajes: TFMensajes) : PEGDB_DRIVER;
       cdecl; external 'egdb.dll' index 6;
 
 procedure FMensaje(texto: pAnsiChar); cdecl;
 begin
   AssignFile(FicheroTexto,'FicheroEGDB.txt');
   Rewrite(FicheroTexto);
   Write(FicheroTexto,texto);
   CloseFile(FicheroTexto);
 end;
 
 function CargarFuncionDLL(FicheroDLL: String; var HandleDLL:
   THandle; Nombre: String; Indice: Integer=-1) :Pointer;
 begin
   Result:=nil;
   HandleDLL:=0;
   HandleDLL:=LoadLibrary(pAnsiChar(FicheroDLL));
   If HandleDLL=0 then Exit;
   If Indice<0 then
     Result:=GetProcAddress(HandleDLL,pAnsiChar(Nombre))
   else
     Result:=GetProcAddress(HandleDLL,pAnsiChar(Indice));
 end;
 
 function DescripcionTipoEGDB(tipo: EGDB_TYPE):string;
 begin
   case tipo of
     EGDB_KINGSROW_WLD: result:='KingsRow WLD';
     EGDB_KINGSROW_MTC: result:='KingsRow MTC';
   end;
 end;
 
 procedure TForm1.btnIdentificarTFClick(Sender:TObject);
 var
   directorio: pAnsiChar;
   TipoEGDB: EGDB_TYPE;
   HandleEGDB: PEGDB_DRIVER;
   piezas: Integer;
   tipo: Integer;
   FMensajes: TFMensajes;
 begin
   HandleDLL:=LoadLibrary('egdb.dll');
   IdentificarTablaFinales:=CargarFuncionDLL'egdb.dll',HandleDLL,'egdb_identify');
   directorio:='c:\damas\damas\egdb\cake';
   IdentificarTablaFinales(directorio,TipoEGDB,piezas);
   memResultados.Lines.Add('Tipo EGDB: '+DescripcionTipoEGDB(TipoEGDB));
   memResultados.Lines.Add('Piezas: '+inttostr(piezas));
   AbrirTablaFinales:=CargarFuncionDLL('egdb.dll',HandleDLL,'egdb_open',6);
   // ERROR AL EJECUTAR LA SIGUIENTE LINEA
   HandleEGDB:=AbrirTablaFinales(EGDB_NORMAL,piezas,300,directorio,FMensajes);
   FreeLibrary(HandleDLL);
 end;

Última edición por dec fecha: 03-09-2005 a las 17:19:21. Razón: (Encerrar el código en la etiqueta DELPHI)
Responder Con Cita
 



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 04:37:23.


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