how to call c++ .dll with object file library in vb 6 [modified]
-
dear all i have read something in internet how to call c++ .dll, and tried to declare functions in vb 6, but however after i compiled, the error was there:" can't find DLL entry point in xxxx.dll". so how to invoke the c++ member function in one .dll, someone can give me help to realize step by step. thanks a lot in advance. note: probably one library has several classes, so how can i know which library i can use or how to use it? rgds
modified on Wednesday, May 13, 2009 9:09 PM
-
dear all i have read something in internet how to call c++ .dll, and tried to declare functions in vb 6, but however after i compiled, the error was there:" can't find DLL entry point in xxxx.dll". so how to invoke the c++ member function in one .dll, someone can give me help to realize step by step. thanks a lot in advance. note: probably one library has several classes, so how can i know which library i can use or how to use it? rgds
modified on Wednesday, May 13, 2009 9:09 PM
Are you exporting the C++ class from the DLL? If so, the member function names are mangled and exported. Use a tool like depends.exe that comes along with Visual Studio and look at the exported function name. Use the same name in your VB code.
«_Superman_» I love work. It gives me something to do between weekends.
-
dear all i have read something in internet how to call c++ .dll, and tried to declare functions in vb 6, but however after i compiled, the error was there:" can't find DLL entry point in xxxx.dll". so how to invoke the c++ member function in one .dll, someone can give me help to realize step by step. thanks a lot in advance. note: probably one library has several classes, so how can i know which library i can use or how to use it? rgds
modified on Wednesday, May 13, 2009 9:09 PM
-
zhiyuan16 wrote:
so how to invoke the c++ member function in one .dll
I guess only c functions exported from the dll can be called from VB.
-
Are you exporting the C++ class from the DLL? If so, the member function names are mangled and exported. Use a tool like depends.exe that comes along with Visual Studio and look at the exported function name. Use the same name in your VB code.
«_Superman_» I love work. It gives me something to do between weekends.
-
thanks for your reply. i didn't export. how to export it? i got .DLL only with object file library. as well as documentation. thanks
Read the documentation for Exporting from a DLL[^]
«_Superman_» I love work. It gives me something to do between weekends.
-
thanks for your reply. i knew i need to export the c++ dll function first, and then i can call it. but i don't know how to export step by step? i got the dll already. how to export? please help me. thanks a lot rgds
You can call a c function exported in a c/c++ dll from a VB application. And to export a c function all you have to do is put the following keywords in front of the function to export as shown below
extern "C" __declspec( dllexport )
void AnotherCFunc(); extern "C" - is used to avoid the name mangling -
Read the documentation for Exporting from a DLL[^]
«_Superman_» I love work. It gives me something to do between weekends.
-
thanks a lot. i have read the articles how to export functions names in .dll. but this .dll was created by user. so here i just got .dll. nothing else, so how to export the function names? thanks.
Do you mean somebody else has created the dll and not you? If so, the functions have already been exported. Use Dependency Viewer (depends.exe) and open the dll file. It will list all the functions that have been exported. Check the actual name of the function and use that in the VB code.
«_Superman_» I love work. It gives me something to do between weekends.
-
You can call a c function exported in a c/c++ dll from a VB application. And to export a c function all you have to do is put the following keywords in front of the function to export as shown below
extern "C" __declspec( dllexport )
void AnotherCFunc(); extern "C" - is used to avoid the name mangling -
Do you mean somebody else has created the dll and not you? If so, the functions have already been exported. Use Dependency Viewer (depends.exe) and open the dll file. It will list all the functions that have been exported. Check the actual name of the function and use that in the VB code.
«_Superman_» I love work. It gives me something to do between weekends.
-
Do you mean somebody else has created the dll and not you? If so, the functions have already been exported. Use Dependency Viewer (depends.exe) and open the dll file. It will list all the functions that have been exported. Check the actual name of the function and use that in the VB code.
«_Superman_» I love work. It gives me something to do between weekends.
my code is following:
Private Declare Function DataFormat Lib "icon_vc80_40d.dll" (ByVal cpIpAddress As String, _
ByVal dnsFlag As Boolean) As Boolean
Private Sub Command1_Click()Dim a As String Dim b As Boolean Dim c As String
a = Text1.Text
c = DataFormat(a, True)
Text2.Text = c
End Subi used this code to test the .dll, but the error occurred: didn't find .dll file. or couldn't find entry point of .dll. what is problem? Note: ICON_API icon::DataFormat::DataFormat ( const DataFormat& df, bool cloneComponents = true ) Copy constructor. Parameters: [in] df DataFormat object to copy. [in] cloneComponents Specifies if a deep or shallow copy is made. Thread Safety: Not thread safe. The data being copied can change at any time. could you help me to check, is this right? the Note above just showed dataformat() detail.
modified on Thursday, May 14, 2009 2:46 AM
-
my code is following:
Private Declare Function DataFormat Lib "icon_vc80_40d.dll" (ByVal cpIpAddress As String, _
ByVal dnsFlag As Boolean) As Boolean
Private Sub Command1_Click()Dim a As String Dim b As Boolean Dim c As String
a = Text1.Text
c = DataFormat(a, True)
Text2.Text = c
End Subi used this code to test the .dll, but the error occurred: didn't find .dll file. or couldn't find entry point of .dll. what is problem? Note: ICON_API icon::DataFormat::DataFormat ( const DataFormat& df, bool cloneComponents = true ) Copy constructor. Parameters: [in] df DataFormat object to copy. [in] cloneComponents Specifies if a deep or shallow copy is made. Thread Safety: Not thread safe. The data being copied can change at any time. could you help me to check, is this right? the Note above just showed dataformat() detail.
modified on Thursday, May 14, 2009 2:46 AM
I made a suggestion twice in my earlier posts. Please look at that.
«_Superman_» I love work. It gives me something to do between weekends.
-
thanks a lot for your help. my one .dll has several classes, so how i can use these funtion properly in vb. thanks a lot
-
I made a suggestion twice in my earlier posts. Please look at that.
«_Superman_» I love work. It gives me something to do between weekends.
thanks a lot, i have documentation of .dll, so i know the actual function name, is this right? sorry, i dun know more this point. now i used the code to test one function DataFormat() what i posted in previous reply. so the error occurred: file not found: icon.dll. so what is problem? and also i have several classes in one library, how i can call the functions properly?thanks. rdgs
-
As I said before you cannot call a c++ class's member function from a vb app.
-
If you haven't
DLL
source code then you can't. However, you may develop (withC/C++
) a new DLL that will act as wrapper of the original one (i.e. an adapter [^]). For details on building aVB6
callableDLL
, see this great article series [^]. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Do you mean somebody else has created the dll and not you? If so, the functions have already been exported. Use Dependency Viewer (depends.exe) and open the dll file. It will list all the functions that have been exported. Check the actual name of the function and use that in the VB code.
«_Superman_» I love work. It gives me something to do between weekends.
-
dear friend i have downloaded the Dependency Viewer software and installed it, however i just could get the .dll in .exe file. so can't get export funcions. any problem? thanks a lot
Open the .DLL file in dependency viewer and look at the right hand side pane.
«_Superman_» I love work. It gives me something to do between weekends.
-
Open the .DLL file in dependency viewer and look at the right hand side pane.
«_Superman_» I love work. It gives me something to do between weekends.