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-30 23:52:10
|
The error is that the DLL which Dev makes, does not see the functions as
being a function, you cant have things passed to it.
You can call it from DEV, but not VB.
I have tried several things, the only way i could do it is by making one in
MSVC++, i have example code for that.
But the examples come out exactly the same as when trying to make your own.
Try downloading the Borland C++ 5.5 Compiler, which is free, and try
compiling DLL's in that, i dont know if it does or not.
Aaron
----- Original Message -----
From: "Elektro" <el...@wo...>
To: <dev...@li...>
Sent: Thursday, August 30, 2001 18:32
Subject: Re: [Dev-C++] Problem using DLL (compiled in DEV-C++) in Visual
Basic
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´s 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´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
|