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. Visual Basic
  4. how to call c++ DLL in vb 6

how to call c++ DLL in vb 6

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestionc++
13 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.
  • Z Offline
    Z Offline
    zhiyuan16
    wrote on last edited by
    #1

    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

    D B C 3 Replies Last reply
    0
    • Z zhiyuan16

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There are different types of .DLL files. If it's a COM-based .DLL, you can add a reference to it, then instantiate the classes in it using Dim:

      Dim x As New SomeClassInLibrary
      

      If it's a library .DLL, then you have to use the Declare statement to setup the call. But, in order to use this, you MUST have the documentation on the functions you want to use so you can properly write the parameter information into the Declare. Without it, you're guessing and are going to get it wrong.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      Z 1 Reply Last reply
      0
      • Z zhiyuan16

        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

        B Offline
        B Offline
        Baran M
        wrote on last edited by
        #3

        Check this Link and this also Step by Step: Calling C++ DLLs from VC++ and VB - Part 2

        Z 1 Reply Last reply
        0
        • D Dave Kreskowiak

          There are different types of .DLL files. If it's a COM-based .DLL, you can add a reference to it, then instantiate the classes in it using Dim:

          Dim x As New SomeClassInLibrary
          

          If it's a library .DLL, then you have to use the Declare statement to setup the call. But, in order to use this, you MUST have the documentation on the functions you want to use so you can properly write the parameter information into the Declare. Without it, you're guessing and are going to get it wrong.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

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

          thanks for your reply, my dll has 2 files: icon_c(object file library) and icon.dll. i have documentation already and detail of all functions' parameters. so how i can call the .dll functions in vb step by step. i also know i need to export the function name of .DLL. then i can call in vb, but i dun know how to export in .dll. i need your further help. thanks a lot. Note: someone already created the .dll, i just want to use it. rdgs

          modified on Thursday, May 14, 2009 2:44 AM

          1 Reply Last reply
          0
          • B Baran M

            Check this Link and this also Step by Step: Calling C++ DLLs from VC++ and VB - Part 2

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

            thanks, i have read it already. the difference is i got .dll already. in part 2, that is user created own .dll, they can export by themselves..here, i can't export or i dun know how to export functions name in .DLL. thanks. please help me, how to export functions name of .DLL.

            D 1 Reply Last reply
            0
            • Z zhiyuan16

              thanks, i have read it already. the difference is i got .dll already. in part 2, that is user created own .dll, they can export by themselves..here, i can't export or i dun know how to export functions name in .DLL. thanks. please help me, how to export functions name of .DLL.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              zhiyuan16 wrote:

              that is user created own .dll, they can export by themselves..here, i can't export or i dun know how to export functions name in .DLL

              You don't have to export anything - it's already being done by the .DLL. The VB code in that example shows you how to Declare functions supplied by an external library. Granted, there are no parameters in those two functions exposed by the example .DLL, but you add those just like you add parameters to normal VB functions you define.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008

              Z 1 Reply Last reply
              0
              • Z zhiyuan16

                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

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                Why are you still using VB6 ?

                Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

                1 Reply Last reply
                0
                • D Dave Kreskowiak

                  zhiyuan16 wrote:

                  that is user created own .dll, they can export by themselves..here, i can't export or i dun know how to export functions name in .DLL

                  You don't have to export anything - it's already being done by the .DLL. The VB code in that example shows you how to Declare functions supplied by an external library. Granted, there are no parameters in those two functions exposed by the example .DLL, but you add those just like you add parameters to normal VB functions you define.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007, 2008

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

                  thanks for your reply, i tried to do that already. the error occurred: "file not found: dll or couldn't find entry point of member function". so what happened? need your further help. thanks

                  D 1 Reply Last reply
                  0
                  • Z zhiyuan16

                    thanks for your reply, i tried to do that already. the error occurred: "file not found: dll or couldn't find entry point of member function". so what happened? need your further help. thanks

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    The name of the function you use in the Declare statement must match EXACTLY what the exported function name in the .DLL is. Or, you can use the Alias keyword in the Declare statement to provide the exported name and name the function anything you want in your code. Also, the .DLL has to be either in the same folder as your .EXE that is calling it, or in a folder listed in the PATH environment variable.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008

                    Z 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      The name of the function you use in the Declare statement must match EXACTLY what the exported function name in the .DLL is. Or, you can use the Alias keyword in the Declare statement to provide the exported name and name the function anything you want in your code. Also, the .DLL has to be either in the same folder as your .EXE that is calling it, or in a folder listed in the PATH environment variable.

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                           2006, 2007, 2008

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

                      thanks alot friend. sorry to ask you one more question: i just would like to confirm we can call all c++ .dll in vb? that means the member functions of c++ .dll were already exported for any c++ .DLL? thanks Rgds

                      D 1 Reply Last reply
                      0
                      • Z zhiyuan16

                        thanks alot friend. sorry to ask you one more question: i just would like to confirm we can call all c++ .dll in vb? that means the member functions of c++ .dll were already exported for any c++ .DLL? thanks Rgds

                        D Offline
                        D Offline
                        Dave Kreskowiak
                        wrote on last edited by
                        #11

                        Yes

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                             2006, 2007, 2008

                        Z 1 Reply Last reply
                        0
                        • D Dave Kreskowiak

                          Yes

                          A guide to posting questions on CodeProject[^]
                          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                               2006, 2007, 2008

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

                          thanks. i have one more question: sorry. if one DLL has one or several classes and their own member functions. how i can call their own corresponding member functions. could you provide me with any detail. thanks a lot in advance. rgds

                          D 1 Reply Last reply
                          0
                          • Z zhiyuan16

                            thanks. i have one more question: sorry. if one DLL has one or several classes and their own member functions. how i can call their own corresponding member functions. could you provide me with any detail. thanks a lot in advance. rgds

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #13

                            It would have to be exposed at a COM-based .DLL. You can't get at them otherwise. PInvoke won't do you any good since it only works with function library .DLL's.

                            A guide to posting questions on CodeProject[^]
                            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                 2006, 2007, 2008

                            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