Re: [Dev-C++] Problem using DLL (compiled in DEV-C++) in Visual Basic
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Aaron W. <Aar...@My...> - 2001-08-22 02:28:48
|
First of all, sorry for the long post, but it is all important.
Bad DLL Calling Convention, means that it doesnt accept the values passed to
it.
For ex, if you had a DLL called MyDLL.dll, and a function called MyRet, then
use the following.
Private Declare Function MyRet lib "MyDLL.dll"() as Integer
**Private Declare Function MyRet lib "MyDLL.dll"(ByVal A as Integer) as
Integer**
This second one, will cause the error.
I have not yet figured out why Dev-c++ does this, I have managed to stop it
mangling the export names, however.
just add this to a CPP:
#include <windows.h>
#define DLLEXPORT extern "C" __declspec (dllexport)
int WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
return TRUE;
}
DLLEXPORT int Ret(int val1){
return 1;
}
This will export the Ret function as Ret and not Ret__FFV@12 or similar.
I dont think when compiling, that DEV-C++ or MingW compiler, recognises it
as a function I say this because if you add this to the above CPP
DLLEXPORT int Ret(int val1){
**MessageBox(0,"Hello","Hello VB",1);**
return 1;
}
and call this: Private Declare Sub MyRet lib "MyDLL.dll"()
and on Form_Load call MyRet it will display the msgbox not needing the
arguments passed to it.
Wilksey
----- Original Message -----
From: "Elektro" <el...@wo...>
To: <dev...@li...>
Sent: Tuesday, August 21, 2001 17:14
Subject: [Dev-C++] Problem using DLL (compiled in DEV-C++) in Visual Basic
Somebody has compiled a DLL in DEV-C++ and used in VB later ?
I have compiled a DLL in DEV-C++ but it don´t work in VB, I have the message
"DLL convention call type is incorrect"
#include <windows.h>
# define DLLIMPORT __declspec (dllexport)
BOOL WINAPI DllMain( HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved){
return TRUE;
}
DLLIMPORT int suma(int a,int b){
return a+b;
}
DLLIMPORT int resta(){
return 7*8;
}
DLLIMPORT int multiplica(int a,int b){
return a*b;
}
DLLIMPORT int nada(){
return a*45;
}
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|