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 08-11-2014
mayusod mayusod is offline
Registrado
 
Registrado: sep 2004
Posts: 3
Poder: 0
mayusod Va por buen camino
Cool importar una dll de c++

Hola chicos a ver si alguin me puede decir por que esto no funciona

Código:
fichero de cabecera .h
#ifndef _CGLOGICSWINAPI_H_
#define _CGLOGICSWINAPI_H_
#if _MSC_VER > 1000
#pragma once
#endif
#ifdef __cplusplus
extern "C" { // only need to export C interface if used by C++ source code
#endif
#ifdef _COMPILING_THE_DLL_
#define CGLOGICS_API __declspec(dllexport)
#else
#define CGLOGICS_API __declspec(dllimport)
#endif
// API functions recommended for new integrations
CGLOGICS_API short __stdcall registerEvents3CG( void (__cdecl *cgStatusCall)( int amount, short status, short mode ),
void (__cdecl *cgErrorCall)( int errorCode, char* errorText, char* extInfo ),
void (__cdecl *cgLevelWarningCall)( short warningType, long denomination, short numberOf, char* typeString, #ifdef __cplusplus
}
#endif
#endif
y ahora la conversion a Delphi

Código Delphi [-]
 
unit CGLOGICSWINAPI;
interface
uses
{$IFDEF WIN32}
Windows,Dialogs,SysUtils;
{$ELSE}
Wintypes, WinProcs;
{$ENDIF}
{$IFNDEF _CGLOGICSWINAPI_H_}
{$DEFINE _CGLOGICSWINAPI_H_}
{$IFDEF _MSC_VER > 1000}
{ #pragma once }
{$ENDIF}
{$IFDEF __cplusplus}
{$ENDIF}
type
TProcStatus = procedure ( amount: Integer; status , mode:SmallInt); cdecl;
TProcError = procedure ( errorCode: Integer; errorText,extInfo : PChar); cdecl;
TProcLevelWarning = procedure (warningType:SmallInt; denomination: LongInt; numberOf :SmallInt;
typeString,denominationString,warningMessage,extInfo:PChar); cdecl;
TCashSession = Procedure(infoType: SmallInt;amount: LongInt; extInfo: PChar); cdecl;
 
function registerEvents3CG(ProcStatus: TProcStatus; ProcError:TProcError;
ProcLevelWarning:TProcLevelWarning; ProcCashSession:TCashSession;
message: PChar): SmallInt cdecl {$IFDEF WIN32} stdcall {$ENDIF};
 
{$IFDEF __cplusplus}
{$ENDIF}
{$ENDIF}
procedure ProcStatus( amount: Integer; status , mode:SmallInt); cdecl;
Procedure ProcError( errorCode: Integer; errorText,extInfo : PChar); cdecl;
procedure ProcLevelWarning(warningType:SmallInt; denomination: LongInt; numberOf :SmallInt;
typeString,denominationString,warningMessage,extInfo:PChar); cdecl;
Procedure CashSession(infoType: SmallInt;amount: LongInt; extInfo: PChar); cdecl;
 
implementation
procedure ProcStatus( amount: Integer; status , mode:SmallInt); cdecl;
begin
ShowMessage('amount:'+IntToStr(amount)+' statut:'+IntTostr(Status)+' mode:'+IntTostr(Mode));
end;
 
Procedure ProcError( errorCode: Integer; errorText,extInfo : PChar); cdecl;
begin
ShowMessage('errorCode:'+IntToStr(errorCode)+' errorText:'+errorText+' extInfo:'+extInfo);
end;
 
procedure ProcLevelWarning(warningType:SmallInt; denomination: LongInt; numberOf :SmallInt;
typeString,denominationString,warningMessage,extInfo:PChar); cdecl;
begin
ShowMessage('warningType:'+IntToStr(warningType)+' denomination:'+IntToStr(denomination)
+' numberOf:'+IntToStr(numberOf)+' typeString:'+typeString+' denominationString:'+denominationString
+' warningMessage:'+warningMessage+' extInfo:'+extInfo);
end;
 
Procedure CashSession(infoType: SmallInt;amount: LongInt; extInfo: PChar); cdecl;
begin
ShowMessage('infoType:'+IntToStr(infoType)+' amount:'+IntToStr(amount)+' extInfo:'+extInfo);
end;
 
function registerEvents3CG; external 'CGLOGICS.DLL';
 
end.

y asi es como lo llamo desde mi programa

Código Delphi [-]
  
unit UcashGuard;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, Mask, rxToolEdit, rxCurrEdit,CGLOGICSWINAPI;
type
TForm1 = class(TForm)
btnIniApi: TButton;
BitBtn1: TBitBtn;
Label1: TLabel;
EditPuerto: TCurrencyEdit;
procedure btnIniApiClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
hDll: THandle;
MensajeCG : String;
end;
var
Form1: TForm1;
implementation
 
{$R *.dfm}
 
procedure TForm1.btnIniApiClick(Sender: TObject);
begin
MensajeCG:='';
registerEvents3CG(ProcStatus,ProcError,ProcLevelWarning,CashSession,PAnsichar(MensajecG));
end;
end.

alguna idea de porque cuando ejecuto el boton "Ini apli" me da el siguiente error
---------------------------
Cashguard
---------------------------
Access violation at address 100332F9 in module 'CGLOGICS.DLL'. Write of address 00404DBD.
---------------------------
Aceptar
---------------------------

gracias espero sus respuestas

Última edición por nlsgarcia fecha: 09-11-2014 a las 05:47:47.
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Importar un txt jafera Conexión con bases de datos 10 25-12-2009 16:55:22
Importar ActiveX sanyco Varios 1 15-09-2006 02:42:13
Importar una dll vasgab API de Windows 0 21-07-2006 23:44:09
Importar DBF a Gdb vtdeleon Firebird e Interbase 4 14-05-2005 18:16:40
importar de excel joanajj Servers 3 04-08-2004 12:35:02


La franja horaria es GMT +2. Ahora son las 19:00:27.


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