Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #11  
Antiguo 23-08-2005
Avatar de lucasarts_18
lucasarts_18 lucasarts_18 is offline
Miembro
 
Registrado: mar 2005
Ubicación: Villa Alemana,Chile
Posts: 1.087
Poder: 23
lucasarts_18 Va por buen camino
Hola:

Aquí encontré un ejemplo que llama a una función específica del API del ODBC.

Código Delphi [-]
 
   function SQLGetInfo(hDb: Longint; InfoType: Word; Info: pointer; Len: Integer;
              var RetLen: Integer): Integer; far; external 'ODBC' index 45;

Aquí está accediendo a una DLL, especifícamente a una del ODBC..

Aquí está todo el código completo..

Código Delphi [-]
 
 {$A+,B-,D+,F-,G+,I+,K+,L+,N+,P+,Q-,R-,S+,T-,V+,W-,X+,Y+}
 {$M 20480,4096}
 unit main;
 
 { SETUP:
     1) Make sure an ODBC Data Source is configured in the BDE correctly.
     2) The program must have access to the ODBC.DLL.
     3) Configure the TDatabase Object to open an ODBC Data Source.
     4) Run program.
 }
 interface
 
 uses
   Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   StdCtrls, DB, DBTables, Grids, DBGrids, DbiTypes, DbiErrs, DbiProcs;
 
 type
   TMainForm = class(TForm)
     ODBCDb: TDatabase;
     GetODBCInfo: TButton;
     OutMemo: TMemo;
     procedure FormCreate(Sender: TObject);
     procedure GetODBCInfoClick(Sender: TObject);
   private
     { Private declarations }
   public
     { Public declarations }
   end;
 
 var
   MainForm: TMainForm;
 
 implementation
 
 {$R *.DFM}
 
 const
   MaxLen = 100;
   { These are ODBC Constants for the SQLGetInfo function }
   SQL_DATABASE_NAME = 16;
   SQL_DRIVER_NAME = 6;
   SQL_DATA_SOURCE_NAME = 2;
   SQL_DRIVER_VER = 7;
   SQL_USER_NAME = 47;
   SQL_MAX_TABLE_NAME_LEN = 35;
   SQL_SERVER_NAME = 13;
 
 { Call the SQLGetInfo function within the ODBC.DLL.  By using the TDUMP
   utility, you can get the function names and indexes. }
 function SQLGetInfo(hDb: Longint; InfoType: Word; Info: pointer; Len: Integer;
              var RetLen: Integer): Integer; far; external 'ODBC' index 45;
 
 procedure TMainForm.FormCreate(Sender: TObject);
 begin
   { Clear the Memo and open the database. }
   OutMemo.Lines.Clear;
   ODBCDb.Open;
 end;
 
 { This function is all you need to setup ODBC calls.  The DbiGetProp
   will retrieve the Native ODBC Handle so ODBC call can be made. }
 procedure TMainForm.GetODBCInfoClick(Sender: TObject);
 var
   DBInfo: array[0..MaxLen] of char;
   NumRead: Integer;
   Len: Word;
   VersionInfo: Integer;
   hNatDb: longint; { Native Db handle that is used for the ODBC functions}
 
 begin
   OutMemo.Lines.Clear;
   { Get the Native ODBC database handle. }
   Check(DbiGetProp(hDbiObj(ODBCDb.Handle), dbNATIVEHNDL, @hNatDb,
              sizeof(hNatDb), Len));
 
   { Call the ODBC function and display the results. }
   OutMemo.Lines.Add('Native Database Handle: ' + IntToStr(hNatDb));
   SQLGetInfo(hNatDb, SQL_DATABASE_NAME, @DBInfo, MaxLen, NumRead);
   OutMemo.Lines.Add('Database Name: ' + StrPas(DBInfo));
   SQLGetInfo(hNatDb, SQL_DRIVER_NAME, @DBInfo, MaxLen, NumRead);
   OutMemo.Lines.Add('Driver Name: ' + StrPas(DBInfo));
   SQLGetInfo(hNatDb, SQL_DATA_SOURCE_NAME, @DBInfo, MaxLen, NumRead);
   OutMemo.Lines.Add('Data Source Name: ' + StrPas(DBInfo));
   SQLGetInfo(hNatDb, SQL_DRIVER_VER, @VersionInfo, sizeof(VersionInfo), NumRead);
   OutMemo.Lines.Add('Driver Version: ' + IntToStr(VersionInfo));
   SQLGetInfo(hNatDb, SQL_USER_NAME, @DBInfo, MaxLen, NumRead);
   OutMemo.Lines.Add('User Name: ' + StrPas(DBInfo));
   SQLGetInfo(hNatDb, SQL_MAX_TABLE_NAME_LEN, @VersionInfo, sizeof(VersionInfo), NumRead);
   OutMemo.Lines.Add('Maximum Table Name Length: ' + IntToStr(VersionInfo));
   SQLGetInfo(hNatDb, SQL_SERVER_NAME, @DBInfo, MaxLen, NumRead);
   OutMemo.Lines.Add('Server Name: ' + StrPas(DBInfo));
 end;
 end.

Espero que te sirva o sino a seguir averiguando...
Roman tiene razón, es una regla del foro no repetir hilos con el mismo tema, despues se hace más difícil buscar en el foro, si algún día alguien tiene un problema similar..

Saludos.
__________________
No todo es como parece ser...
Responder Con Cita
 


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 05:09:07.


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