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