|
Esclareciendo
Mis disculpas por las infracciones.
Para tratar de obtener, la vinculación de la DLL con Delphi, realicé una DLL sencilla que solamente contiene la función
function plusone(val : Integer) : Integer; export; stdcall; que simplemente suma 1 al parámetro val
En el archivo DPR incluí la cláusula export de la siguiente manera
Exports
plusone name 'plusone@4',
La clase de C++ que cargará la DLL es así
/* Carga.h*/
#define USELIB
#ifdef USELIB
extern "C" {
int __declspec(dllimport) __stdcall plusone(int);
}
#endif //USELIB
ref class Carga
{
public:
Carga(void);
~Carga(void);
int SumaUno(int i);
protected:
#ifndef USELIB
HINSTANCE hMyDLL;
FARPROC lpfnplusone;
typedef int (*pIIFUNC)(int);
pIIFUNC plusone;
#endif //USELIB
/*Carga.cpp*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
Carga::Carga(void)
{
#ifndef USELIB
hMyDLL = LoadLibrary("D:\\Delphi to C++\\DLL\\MyDLL.dll");
if(hMyDLL == NULL)
PostQuitMessage(1);
lpfnplusone = GetProcAddress(HMODULE(hMyDLL), "_plusone");
if(lpfnplusone == NULL)
PostQuitMessage(2);
plusone = pIIFUNC(lpfnplusone);
#endif //USELIB
}
Carga::~Carga(void)
{
#ifndef USELIB
if (hMyDLL != NULL)
FreeLibrary(hMyDLL);
#endif //USELIB
}
int Carga::SumaUno(int i)
{
int temp = plusone(i);
return i;
}
El error a la hora de compilar es el siguiente:
Error 1 error LNK2028: unresolved token (0A00000A) "extern "C" int __stdcall plusone(int)" (?plusone@@$$J14YGHH@Z) referenced in function "public: int __clrcall Carga::SumaUno(int)" (?SumaUno@Carga@@$$FQ$AAMHH@Z) Carga.obj
Gracias anticipadas y disculpen lo extenso que quedó el mensaje
|