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: Elektro <el...@wo...> - 2001-08-30 17:37:25
|
Thanks, but I have this code in VB and it fails:
Private Declare Function multiplica Lib "d:\elektro\proyect.dll" (byval a=
As integer,byval b As integer) As Integer
Private Sub Form_Activate()
MsgBox multiplica(2, 2)
End Sub
And this code for multiplica function in DEV-C++
DLLIMPORT int multiplica(int a,int b){
return a*b;
}
Where is the error ?
My DLL need the Win32 console subsistem and others DLL=B4s need the Win32=
GUI subsistem but I have selected in DEV-C++ Compile for Win32 (no=
console) , Create a DLL and Do not create a console in project and=
compiler options.
can it be the problem ?
*********** REPLY SEPARATOR ***********
On 22/08/01 at 3:31 Aaron Wilkes wrote:
>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=B4t 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;
>}
|