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. Calling A C++ Dll Frim VB.NET

Calling A C++ Dll Frim VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharpc++
4 Posts 2 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.
  • M Offline
    M Offline
    mlauahi
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • M mlauahi

      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

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

      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

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        M Offline
        M Offline
        mlauahi
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • M mlauahi

          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

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

          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

          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