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. Loading dll in c++

Loading dll in c++

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
11 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.
  • P Offline
    P Offline
    Pryabu
    wrote on last edited by
    #1

    Hi, How to check whether the dll can be loaded in c++? Thanks,

    L 1 Reply Last reply
    0
    • P Pryabu

      Hi, How to check whether the dll can be loaded in c++? Thanks,

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Use the LoadLibraryEx()[^] function.

      It's time for a new signature.

      P 1 Reply Last reply
      0
      • L Lost User

        Use the LoadLibraryEx()[^] function.

        It's time for a new signature.

        P Offline
        P Offline
        Pryabu
        wrote on last edited by
        #3

        Yeah,I have loaded the dll and its returning 0x11000000 value in HINSTANCE But while getting the address of that function,its returning value 0x00000000. Whats the reason? If we open a dll in notepad, it should contain the function names right? but this is dll is not showing any fn names in notepad. Please tell me why GetProcAdress is returning NULL value? Thanks,

        C L 3 Replies Last reply
        0
        • P Pryabu

          Yeah,I have loaded the dll and its returning 0x11000000 value in HINSTANCE But while getting the address of that function,its returning value 0x00000000. Whats the reason? If we open a dll in notepad, it should contain the function names right? but this is dll is not showing any fn names in notepad. Please tell me why GetProcAdress is returning NULL value? Thanks,

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          Maybe a function name mangling issue. Why don't you use the Dependecy Walker tool [^] to see function names? :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          P 1 Reply Last reply
          0
          • P Pryabu

            Yeah,I have loaded the dll and its returning 0x11000000 value in HINSTANCE But while getting the address of that function,its returning value 0x00000000. Whats the reason? If we open a dll in notepad, it should contain the function names right? but this is dll is not showing any fn names in notepad. Please tell me why GetProcAdress is returning NULL value? Thanks,

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Have you correctly exported your function names with __declspec(dllexport)?

            It's time for a new signature.

            P 1 Reply Last reply
            0
            • P Pryabu

              Yeah,I have loaded the dll and its returning 0x11000000 value in HINSTANCE But while getting the address of that function,its returning value 0x00000000. Whats the reason? If we open a dll in notepad, it should contain the function names right? but this is dll is not showing any fn names in notepad. Please tell me why GetProcAdress is returning NULL value? Thanks,

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Put this before class and function names that you want to export from the dll.

              extern "C"

              This will prevent the C++ way of mangling the names. Theres nothing wrong in mangling but if you export a function like

              int Sum(int, int)

              C++ will NOT reduce that to _Sum, like C and like you might expect. That means when you import that into your program, you can't simply search for "Sum" but have to follow C++ name mangling rules and search for THAT name.

              ...byte till it megahertz...

              1 Reply Last reply
              0
              • C CPallini

                Maybe a function name mangling issue. Why don't you use the Dependecy Walker tool [^] to see function names? :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                P Offline
                P Offline
                Pryabu
                wrote on last edited by
                #7

                Yes.I have used Dependency walker. But its showing only 4 functions DllCanUnLoadNow,DllGetClassObject,DllRegisterServer,DllUnregisterServer. But I can use the functions in .net. In c++ only, its not working.

                C 1 Reply Last reply
                0
                • L Lost User

                  Have you correctly exported your function names with __declspec(dllexport)?

                  It's time for a new signature.

                  P Offline
                  P Offline
                  Pryabu
                  wrote on last edited by
                  #8

                  No.This dll is given by a vendor.This is not our dll.

                  L 1 Reply Last reply
                  0
                  • P Pryabu

                    No.This dll is given by a vendor.This is not our dll.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    Karthika85 wrote:

                    This dll is given by a vendor.

                    Then they are the people you need to talk to, as they should have both the source code and the instructions on how to use the functions.

                    It's time for a new signature.

                    P 1 Reply Last reply
                    0
                    • L Lost User

                      Karthika85 wrote:

                      This dll is given by a vendor.

                      Then they are the people you need to talk to, as they should have both the source code and the instructions on how to use the functions.

                      It's time for a new signature.

                      P Offline
                      P Offline
                      Pryabu
                      wrote on last edited by
                      #10

                      ok thanks

                      1 Reply Last reply
                      0
                      • P Pryabu

                        Yes.I have used Dependency walker. But its showing only 4 functions DllCanUnLoadNow,DllGetClassObject,DllRegisterServer,DllUnregisterServer. But I can use the functions in .net. In c++ only, its not working.

                        C Offline
                        C Offline
                        CPallini
                        wrote on last edited by
                        #11

                        Karthika85 wrote:

                        only 4 functions DllCanUnLoadNow,DllGetClassObject,DllRegisterServer,DllUnregisterServer.

                        That's because it is a COM server and you have to use the COM way (e.g. via CoCreateInstance [^] function) to access it's functionality. :)

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                        [My articles]

                        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