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. Accessing a VC++ DLL in VB

Accessing a VC++ DLL in VB

Scheduled Pinned Locked Moved Visual Basic
c++performancehelpquestionannouncement
6 Posts 3 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.
  • U Offline
    U Offline
    User 572417
    wrote on last edited by
    #1

    I have a DLL created in VC, I need to call it from vb. I've declared the dll functions in vb like this: Declare Function PerfBal Lib "PSAEngine.dll" (ByVal oldperfbal As Double, ByVal NewDef As Double, ByVal VolPrepay As Double, ByVal ActAm As Double) As Double My VC++ function is: __declspec( dllexport ) double PerfBal(double oldperfbal, double newdef, double volprepay, double actam) { double result; result=oldperfbal-newdef-volprepay-actam; return(result); } Whenever I call it in my vb, it gives: Run-time error '453': Can't find DLL entry point PerfBal in PSAEngine.dll The dll is in the same directory as my vb project and executable. I even placed the dll in the system32 direction. I've tried to register the dll, all I get is psaengine.dll was loaded, but the dllregisterserver entry point was not found. Dllregisterserver may be be exported, or a corrupt version of psaengine.dll may be in memory. What am I doing wrong??

    S 1 Reply Last reply
    0
    • U User 572417

      I have a DLL created in VC, I need to call it from vb. I've declared the dll functions in vb like this: Declare Function PerfBal Lib "PSAEngine.dll" (ByVal oldperfbal As Double, ByVal NewDef As Double, ByVal VolPrepay As Double, ByVal ActAm As Double) As Double My VC++ function is: __declspec( dllexport ) double PerfBal(double oldperfbal, double newdef, double volprepay, double actam) { double result; result=oldperfbal-newdef-volprepay-actam; return(result); } Whenever I call it in my vb, it gives: Run-time error '453': Can't find DLL entry point PerfBal in PSAEngine.dll The dll is in the same directory as my vb project and executable. I even placed the dll in the system32 direction. I've tried to register the dll, all I get is psaengine.dll was loaded, but the dllregisterserver entry point was not found. Dllregisterserver may be be exported, or a corrupt version of psaengine.dll may be in memory. What am I doing wrong??

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      Use dumpbin /exports on the DLL to find out if the name(s) of the DLL functions were mangled. You'll probably find that they were. Modify your DLL's .def file to include specific PerfBal = PerfBal type lines and rebuild. This may well make a difference. Steve S

      U 1 Reply Last reply
      0
      • S Steve S

        Use dumpbin /exports on the DLL to find out if the name(s) of the DLL functions were mangled. You'll probably find that they were. Modify your DLL's .def file to include specific PerfBal = PerfBal type lines and rebuild. This may well make a difference. Steve S

        U Offline
        U Offline
        User 572417
        wrote on last edited by
        #3

        Great! That works. :) Is there a way to have the VB app find the dll without specifying the exact path to the dll in the declare?

        D 1 Reply Last reply
        0
        • U User 572417

          Great! That works. :) Is there a way to have the VB app find the dll without specifying the exact path to the dll in the declare?

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

          Yeah. The .DLL must be in the same directory the VB .EXE is in, or in a directory on the PATH statement somewhere. But you can't have VB "hunt" it down if it is not found because you can't modify the Declare statement in code. RageInTheMachine9532

          U 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Yeah. The .DLL must be in the same directory the VB .EXE is in, or in a directory on the PATH statement somewhere. But you can't have VB "hunt" it down if it is not found because you can't modify the Declare statement in code. RageInTheMachine9532

            U Offline
            U Offline
            User 572417
            wrote on last edited by
            #5

            I find that if I don't specify the exact path even if the dll is the same directory as the exe it still can't find it. Is that correct?

            D 1 Reply Last reply
            0
            • U User 572417

              I find that if I don't specify the exact path even if the dll is the same directory as the exe it still can't find it. Is that correct?

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

              Never had a problem with it. I've built several VB6 projects using libraries I've built into C .DLLs. All I ever had to do was put the DLL files into the same directory as the project and add a reference to the DLL's or to their Type Library files. RageInTheMachine9532

              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