Calling A C++ Dll Frim VB.NET
-
I tried this the other day. I now have more information that I did not have before. I have a DLL called spoem.dll I Have a LIB called spoem.lib In C++ there are the lines: #define SPOEM_API __declspec(dllimport) #pragma message("automatic link to spoem.lib") // <== add this line #pragma comment(lib, "spoem.lib") This last line I guess calls a linker the the LIB file. My understanding is that the DLL has no entry points. Each function in C gets linked intot he program calling this line. #pragma comment(lib, "spoem.lib") Is there any way in VB.NET to mimic this same behavior . I need to link this LIB file into my VB.NET project. Thanks
-
I tried this the other day. I now have more information that I did not have before. I have a DLL called spoem.dll I Have a LIB called spoem.lib In C++ there are the lines: #define SPOEM_API __declspec(dllimport) #pragma message("automatic link to spoem.lib") // <== add this line #pragma comment(lib, "spoem.lib") This last line I guess calls a linker the the LIB file. My understanding is that the DLL has no entry points. Each function in C gets linked intot he program calling this line. #pragma comment(lib, "spoem.lib") Is there any way in VB.NET to mimic this same behavior . I need to link this LIB file into my VB.NET project. Thanks
No, there isn't. A lib file is used during the linking of the C++ object files to get an .EXE. The lib files can ONLY be used with C/C++. They're of absolutely no use to your VB/VB.NET code. You can only use the .DLL version calling the functions it exposes.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
No, there isn't. A lib file is used during the linking of the C++ object files to get an .EXE. The lib files can ONLY be used with C/C++. They're of absolutely no use to your VB/VB.NET code. You can only use the .DLL version calling the functions it exposes.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
So to dot my I's and cross mt T's. Since I did not write this DLL, and have no control over it. This DLL cannot be used in a VB.NET application. Whenever I use
mlauahi wrote:
Since I did not write this DLL, and have no control over it. This DLL cannot be used in a VB.NET application.
That's not what I said. I said the .LIB file was useless. I didn't say the .DLL couldn't be used. The problem with the entry points is because the name you're using doesn't match the name in the .DLL. You can see the function exports if you open the .DLL in the
Dependancy Walker
utility. You can find it at http://www.dependencywalker.com/[^]Dave Kreskowiak Microsoft MVP - Visual Basic