alicia99
asked on
how to call DLL from VB
How do I call a DLL from VB. After calling the DLL, how do I make use of it? Please explain in details! Besides, the DLL is exported from my class by using this:
class __declspec(dllexport) abc
{ ..... }
Since i export the whole class, how do I use one of the member function in VB6 ?
class __declspec(dllexport) abc
{ ..... }
Since i export the whole class, how do I use one of the member function in VB6 ?
ASKER
My question is not answered ! Why? I wish to know how am I going to call DLL from VB if only one of the member function in that class(Visual C++ 6) which I exported i wanna use only.
Is there any method that I can shortened the function name that i exported? I use "Depends" to view the DLL file that I've exported. I saw something like this:-
??0CATMException@@QAE@V?$b asic_strin g@DU?$char _traits@D@ std@@V?$al locator@D@ 2@@std@@@Z
The original function name is "CATMEexception"
Is it valid for me to export one of the member function in C++ while the function is inside a class or should the whole class be exported?
Thank you.
Is there any method that I can shortened the function name that i exported? I use "Depends" to view the DLL file that I've exported. I saw something like this:-
??0CATMException@@QAE@V?$b
The original function name is "CATMEexception"
Is it valid for me to export one of the member function in C++ while the function is inside a class or should the whole class be exported?
Thank you.
I think you need to register you dll (which seems to be ActiveX dll)
Then you can check in the references dialog box of the VB project and use the objectbrowser to analyse your class.
You are correct when you say that you need to export the whole class, normally, exporting a single function cannot be of use (except if the function is a completely standalone)
Then you can check in the references dialog box of the VB project and use the objectbrowser to analyse your class.
You are correct when you say that you need to export the whole class, normally, exporting a single function cannot be of use (except if the function is a completely standalone)
The mangled thing that you are seeing is due to not exporting the function properly from VC++
??0CATMException@@QAE@V?$b asic_strin g@DU?$char _traits@D@ std@@V?$al locator@D@ 2@@std@@@Z
This kind of exports are not acceptable by VB.The dll has to be compiled with .DEF file which has the Exports Table.If you compile this way you will not get those characters.
To call this function in VB
you have to declare it as API call in a module e.g
Public Declare Function Square Lib "vblibrary.dll" (ByVal itest As integer) As Long
Private sub Command1_click()
dim x as long
x=Square(5)
end sub
Hope this will help you...
??0CATMException@@QAE@V?$b
This kind of exports are not acceptable by VB.The dll has to be compiled with .DEF file which has the Exports Table.If you compile this way you will not get those characters.
To call this function in VB
you have to declare it as API call in a module e.g
Public Declare Function Square Lib "vblibrary.dll" (ByVal itest As integer) As Long
Private sub Command1_click()
dim x as long
x=Square(5)
end sub
Hope this will help you...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dear pushpak:
Please revert you answer to a comment, because this text is already given.
FYI: comments can be accepted as an answer too
Please revert you answer to a comment, because this text is already given.
FYI: comments can be accepted as an answer too
ASKER
How do I give syedAliF and angelIII points at the same time?
ASKER
Adjusted points from 35 to 45
ASKER
Helo Pushpak,
If i have included the DLL in my reference, do i still need to declare this:-
Declare Function hello Lib "vblibrary.dll" (ByVal itest As String) As String
As for syedAliF,
If i have the whole c++ class exported as a DLL, then it is a class, not a function! So how do I declare it?
I wish to use one or two function that belong to the C++ class only. How do i declare it using VB?
Please help. Thank you.
If i have included the DLL in my reference, do i still need to declare this:-
Declare Function hello Lib "vblibrary.dll" (ByVal itest As String) As String
As for syedAliF,
If i have the whole c++ class exported as a DLL, then it is a class, not a function! So how do I declare it?
I wish to use one or two function that belong to the C++ class only. How do i declare it using VB?
Please help. Thank you.
You have to make sure the function maintain the stack. This is in done when developing your dll. You must apply the _stdcall keyword.
So, you've one part right.. you do need the __declspec(dllexport), but you need the _stdcall. Here's an example..
_delcspec(dllexport) long _stdcall DebugPrint (LPSTR szMessage)
I hope this information is helpful..