Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to call c++ .dll with object file library in vb 6 [modified]

how to call c++ .dll with object file library in vb 6 [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestionc++
20 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ _Superman_

    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.

    Z Offline
    Z Offline
    zhiyuan16
    wrote on last edited by
    #5

    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

    _ 1 Reply Last reply
    0
    • Z zhiyuan16

      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

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #6

      Read the documentation for Exporting from a DLL[^]

      «_Superman_» I love work. It gives me something to do between weekends.

      Z 1 Reply Last reply
      0
      • Z zhiyuan16

        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

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #7

        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

        nave [OpenedFileFinder] [My Blog]

        Z 1 Reply Last reply
        0
        • _ _Superman_

          Read the documentation for Exporting from a DLL[^]

          «_Superman_» I love work. It gives me something to do between weekends.

          Z Offline
          Z Offline
          zhiyuan16
          wrote on last edited by
          #8

          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.

          _ 1 Reply Last reply
          0
          • Z zhiyuan16

            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.

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #9

            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.

            Z 3 Replies Last reply
            0
            • N Naveen

              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

              nave [OpenedFileFinder] [My Blog]

              Z Offline
              Z Offline
              zhiyuan16
              wrote on last edited by
              #10

              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

              N 1 Reply Last reply
              0
              • _ _Superman_

                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.

                Z Offline
                Z Offline
                zhiyuan16
                wrote on last edited by
                #11

                yes, somebody already created the .dll, i just would like to use it. so how i can use these function directly? also one library has several classes, how to use it properly? thanks..

                1 Reply Last reply
                0
                • _ _Superman_

                  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.

                  Z Offline
                  Z Offline
                  zhiyuan16
                  wrote on last edited by
                  #12

                  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 Sub

                  i 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

                  _ 1 Reply Last reply
                  0
                  • Z zhiyuan16

                    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 Sub

                    i 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

                    _ Offline
                    _ Offline
                    _Superman_
                    wrote on last edited by
                    #13

                    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.

                    Z 1 Reply Last reply
                    0
                    • Z zhiyuan16

                      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

                      N Offline
                      N Offline
                      Naveen
                      wrote on last edited by
                      #14

                      As I said before you cannot call a c++ class's member function from a vb app.

                      nave [OpenedFileFinder] [My Blog]

                      Z 1 Reply Last reply
                      0
                      • _ _Superman_

                        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.

                        Z Offline
                        Z Offline
                        zhiyuan16
                        wrote on last edited by
                        #15

                        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

                        1 Reply Last reply
                        0
                        • N Naveen

                          As I said before you cannot call a c++ class's member function from a vb app.

                          nave [OpenedFileFinder] [My Blog]

                          Z Offline
                          Z Offline
                          zhiyuan16
                          wrote on last edited by
                          #16

                          thanks, how i can export the functions of dll step by step? thanks a lot

                          CPalliniC 1 Reply Last reply
                          0
                          • Z zhiyuan16

                            thanks, how i can export the functions of dll step by step? thanks a lot

                            CPalliniC Offline
                            CPalliniC Offline
                            CPallini
                            wrote on last edited by
                            #17

                            If you haven't DLL source code then you can't. However, you may develop (with C/C++) a new DLL that will act as wrapper of the original one (i.e. an adapter [^]). For details on building a VB6 callable DLL, 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]

                            In testa che avete, signor di Ceprano?

                            1 Reply Last reply
                            0
                            • _ _Superman_

                              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.

                              Z Offline
                              Z Offline
                              zhiyuan16
                              wrote on last edited by
                              #18

                              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

                              _ 1 Reply Last reply
                              0
                              • Z zhiyuan16

                                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

                                _ Offline
                                _ Offline
                                _Superman_
                                wrote on last edited by
                                #19

                                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.

                                Z 1 Reply Last reply
                                0
                                • _ _Superman_

                                  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.

                                  Z Offline
                                  Z Offline
                                  zhiyuan16
                                  wrote on last edited by
                                  #20

                                  however i couldn't open it. software just reminded me to choose type which will be open, after that, just showed me how many dll. i downloaded dependency viewer 1.0. what is problem i made. thanks.

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups