lectura de un DLL -

lectura de un DLL -

Postby Busmatic_wpb » Thu Aug 03, 2017 1:27 am

Buenas amigos listeros saludes a la distancia.

Haber quien m epuede echar una mano. Miren est funcion es de un lector sin contacto necsito leer los parametreos de este api y aprender un poco mas
utilza una libreria ctacs.DLL

Como podria utilizar hacer esto para utilizar la dll agradezco desde ya la ayuda No tengo conicimiento en est ar :roll: ea.

Calling CT-API Functions

Esta es funcion en C

#include <stdio.h>
#include <ct_api.h>
int main(int argc, char *argv[])
{
char ret;
unsigned short ctn;
unsigned short pn;
unsigned char sad;
unsigned char dad;
// REQUEST ICC
unsigned char command[] = { 0x20, 0x12, 0x01, 0x00, 0x00 };
unsigned short lenc = sizeof(command);
unsigned char response[300];
unsigned short lenr = sizeof(response);
unsigned short i;
ctn = 1;
pn = 1;
// Initialize card terminal
ret = CT_init(ctn, pn);
if (ret != OK)
{
printf("Error: CT_init failed with error %d\n", ret);
return 1;
}
sad = 2; // Source = Host
dad = 1; // Destination = Card Terminal
// Send command
ret = CT_data(ctn, &dad, &sad, lenc, command, &lenr, response);
if (ret != OK)
printf("Error: CT_data failed with error %d\n", ret);
else
{
// Display response
printf("Response: ");
for (i = 0; i < lenr; i++)
printf("%02X ", response[i]);
printf("\n");
}
// Close card terminal
ret = CT_close(ctn);
if (ret != OK)
printf("Error: CT_close failed with error %d\n", ret);
return 0;
}


Ahora esta manera pero el programa entra no muestra nada y sale sin errores.


Function Milagros()

Local ctn :=1 , pn := 1

hDLL := LoadLibrary( "ctacs.DLL")

?? CT_init(ctn, pn)

FreeLibrary( hDLL )
return nil

DLL FUNCTION CT_init( ctn AS PTR , pn AS PTR ) AS LONG LIB "ctacs.DLL"
Regards.
S.I.T.U.
Sistemas Inteligentes de transporte urbano
http://www.situcr.com
oscarchacon@Situcr.com
Desarrollos BA4/B4j androide
User avatar
Busmatic_wpb
 
Posts: 162
Joined: Wed Feb 22, 2017 2:19 am

Re: lectura de un DLL -

Postby Antonio Linares » Thu Aug 03, 2017 5:12 am

DLL FUNCTION CT_init( ctn AS LONG, pn AS LONG ) AS LONG LIB "ctacs.DLL"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: lectura de un DLL -

Postby Busmatic_wpb » Sat Aug 05, 2017 1:47 am

Gracias .

Se comporta igual por otro lado intente de esta manera pero el tipo de campo que puse en la llamada de la dll haber si esta correcta.

#include "FiveWin.ch"
#include "dll.ch"


FUNCTION LEEC1()

Local notUsed:="" , notUsed1:=""

Local MAXIMUM_SMARTCARD_READERS:=10
Local SCARD_SCOPE_USER:=0
Local SCARD_S_SUCCESS :=0

hDLL := LoadLibrary( "WINSCARD.DLL")



RetVar :="" &&cardinal;
ReaderList :=space(1) && string;
ReaderListSize := 0 &&integer;
FContext :=space(30)

v :={MAXIMUM_SMARTCARD_READERS} &&array[0..MAXIMUM_SMARTCARD_READERS] of string;
i :=0 &&integer;

RetVar := SCardEstablishContext(SCARD_SCOPE_USER, @notUsed, @notUsed1, @FContext)

FreeLibrary( hDLL )
return nil



DLL FUNCTION SCardEstablishContext( SCARD_SCOPE_USER AS LONG , notUsed AS VOID , notUsed1 AS VOID , @FContext AS STRING ) AS LONG PASCAL LIB "WINSCARD.DLL"
Regards.
S.I.T.U.
Sistemas Inteligentes de transporte urbano
http://www.situcr.com
oscarchacon@Situcr.com
Desarrollos BA4/B4j androide
User avatar
Busmatic_wpb
 
Posts: 162
Joined: Wed Feb 22, 2017 2:19 am

Re: lectura de un DLL -

Postby Antonio Linares » Sat Aug 05, 2017 6:48 am

Tienes un ejemplo en C de cómo se usa SCardEstablishContext() ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: lectura de un DLL -

Postby Busmatic_wpb » Sat Aug 05, 2017 8:27 pm

Gracias Linares.
Te envie un correo con l dll y un ejemplo en C.
Aprecio la ayuda.
Regards.
S.I.T.U.
Sistemas Inteligentes de transporte urbano
http://www.situcr.com
oscarchacon@Situcr.com
Desarrollos BA4/B4j androide
User avatar
Busmatic_wpb
 
Posts: 162
Joined: Wed Feb 22, 2017 2:19 am

Re: lectura de un DLL - EJEMPLO en Delphi

Postby Busmatic_wpb » Sat Aug 05, 2017 8:35 pm

EJEMPLO EN DELFI

Te puedo dar una idea con algo del código en Delphi, para que veas si puedes adaptarlo.

hDLL := LoadLibrary("WINSCARD.DLL")

//En los ejemplos uso varias constantes para mayor claridad, cuyos valores son los siguientes:
Const
MAXIMUM_SMARTCARD_READERS = 10;
SCARD_SCOPE_USER = 0;
SCARD_S_SUCCESS = 0;

Var
RetVar : cardinal;
ReaderList : string;
ReaderListSize : integer;
v : array[0..MAXIMUM_SMARTCARD_READERS] of string;
i : integer;

//Establecer el contexto para un usuario y guardarlo en FContext
RetVar := SCardEstablishContext(SCARD_SCOPE_USER, nil, nil, @FContext)
if RetVar = SCARD_S_SUCCESS then begin
RetVar := SCardListReadersA(FContext, nil, nil, ReaderListSize);
if RetVar = SCARD_S_SUCCESS then begin
SetLength(ReaderList, ReaderListSize);
SCardListReadersA(FContext, nil, Pointer(ReaderList), ReaderListSize);
for i := 0 to MAXIMUM_SMARTCARD_READERS do
if v[i] <> '' then
// Aquí debes almacenar en alguna lista los nombres de los lectores de tarjetas disponibles, que en este caso vienen reportados en la matriz v[]
End;
End;

//Lo que sigue es generalmente manejado en un thread aparte para no bloquear el interfase de usuario, pero puedes hacerlo como tu quieras.
//Hay que consultar el contexto para ver si algo ha cambiado

function CardWatcherThread(PContext: pointer): integer;
var
RetVar : cardinal;
RContext : cardinal;
RStates : array[0..1] of SCARD_READERSTATEA;
begin
try
RContext := cardinal(PContext^);
FillChar(RStates,SizeOf(RStates),#0);
RStates[0].szReader := SelectedReader; //Es un puntero al nombre del lector que hayas seleccionado
RStates[0].pvUserData := nil;
RStates[0].dwEventState := ActReaderState;
while ReaderOpen do
begin
RStates[0].dwCurrentState := RStates[0].dwEventState;
RetVar := SCardGetStatusChangeA(RContext, -1, RStates, 1);
ActReaderState := RStates[0].dwEventState;
PostMessage(NotifyHandle, WM_CARDSTATE, RetVar, 0);
end;
finally
Result := 0;
end;
end;
Regards.
S.I.T.U.
Sistemas Inteligentes de transporte urbano
http://www.situcr.com
oscarchacon@Situcr.com
Desarrollos BA4/B4j androide
User avatar
Busmatic_wpb
 
Posts: 162
Joined: Wed Feb 22, 2017 2:19 am


Return to FiveWin para CA-Clipper

Who is online

Users browsing this forum: No registered users and 3 guests