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. C / C++ / MFC
  4. VB6 Project to VC6

VB6 Project to VC6

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 2 Posters 1 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
    MikeRWinter
    wrote on last edited by
    #1

    Hi all I have a VB project that I wish to port to VC. The VB project makes use of a dll file, for which I do not have a .lib or .h file. is there any way I can do what I am trying to do? Sorry if this is a dumn question! Cheers Mike

    Richard Andrew x64R 1 Reply Last reply
    0
    • M MikeRWinter

      Hi all I have a VB project that I wish to port to VC. The VB project makes use of a dll file, for which I do not have a .lib or .h file. is there any way I can do what I am trying to do? Sorry if this is a dumn question! Cheers Mike

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Assuming you have the VB source code, you will just need to convert the dll function declarations to C++ declarations.

      M 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        Assuming you have the VB source code, you will just need to convert the dll function declarations to C++ declarations.

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

        Thanks for taking the time to help! Previously when I have done a similar thing to this, I have had an associated header and lib file. I would normally go to Projects, settings, and add "MyLib.lib" to object\library modules. Is there another way of adding the dll to the project? Again thanks for any help Mike

        Richard Andrew x64R 1 Reply Last reply
        0
        • M MikeRWinter

          Thanks for taking the time to help! Previously when I have done a similar thing to this, I have had an associated header and lib file. I would normally go to Projects, settings, and add "MyLib.lib" to object\library modules. Is there another way of adding the dll to the project? Again thanks for any help Mike

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          Well, since you don't have a .lib file for the dll, I don't see that you need to add it to the project, per se. In order to call the functions in the dll you'll have to use LoadLibrary, and GetProcAddress. Are you familiar with those two functions?

          M 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            Well, since you don't have a .lib file for the dll, I don't see that you need to add it to the project, per se. In order to call the functions in the dll you'll have to use LoadLibrary, and GetProcAddress. Are you familiar with those two functions?

            M Offline
            M Offline
            MikeRWinter
            wrote on last edited by
            #5

            no - just looking them up!

            M 1 Reply Last reply
            0
            • M MikeRWinter

              no - just looking them up!

              M Offline
              M Offline
              MikeRWinter
              wrote on last edited by
              #6

              well, Im part of the way there! I have tried this: HINSTANCE hDLL = NULL; FARPROC DLLFunc; hDLL = LoadLibrary("MyDLL.dll"); if(hDLL) { DLLFunc = GetProcAddress(hDLL,"MyFunction"); FreeLibrary(hDLL); } I get a handle to the dll, but GetProcAddress fails. I have tried this with a different dll, and this appeared to work, so may be there is something unusual with MyDLL.dll - is there a way of finding out what functions are in the dll? The VB program declares a variable as well - "Dim WithEvents obj As CVeronixCtl" how would this be handled? Thanks again for your time and patience! Mike

              Richard Andrew x64R 1 Reply Last reply
              0
              • M MikeRWinter

                well, Im part of the way there! I have tried this: HINSTANCE hDLL = NULL; FARPROC DLLFunc; hDLL = LoadLibrary("MyDLL.dll"); if(hDLL) { DLLFunc = GetProcAddress(hDLL,"MyFunction"); FreeLibrary(hDLL); } I get a handle to the dll, but GetProcAddress fails. I have tried this with a different dll, and this appeared to work, so may be there is something unusual with MyDLL.dll - is there a way of finding out what functions are in the dll? The VB program declares a variable as well - "Dim WithEvents obj As CVeronixCtl" how would this be handled? Thanks again for your time and patience! Mike

                Richard Andrew x64R Offline
                Richard Andrew x64R Offline
                Richard Andrew x64
                wrote on last edited by
                #7

                The spelling of the function name in GetProcAddress must be exact. You can also try calling GetLastError like this:

                DWORD Error = 0;
                DLLFunc = GetProcAddress(hDLL, "MyFunction" );
                if ( ! DLLFunc )
                Error = GetLastError();

                This will tell you the reason that the call failed. You can find out the exported functions inside the DLL, by using the program Dumpbin that comes with the SDK. dumpbin /EXPORTS MyDll.dll

                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