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. How to assign class variable value using loadlibrary function

How to assign class variable value using loadlibrary function

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
6 Posts 4 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, Im using LoadLibrary function to load a dll.To call a function,we will use GetProcAddress.But how to assign a value to a variable in that dll. Can anyone pls help me? Thanks,

    K C C 3 Replies Last reply
    0
    • P Pryabu

      Hi, Im using LoadLibrary function to load a dll.To call a function,we will use GetProcAddress.But how to assign a value to a variable in that dll. Can anyone pls help me? Thanks,

      K Offline
      K Offline
      kapax5
      wrote on last edited by
      #2

      Maybe this would help:

      #pragma data_seg (".commondata")
      extern /*type-name*/ /*variable-name*/ = /* value */
      #pragma data_seg ()

      For more information, look here[^].

      1 Reply Last reply
      0
      • P Pryabu

        Hi, Im using LoadLibrary function to load a dll.To call a function,we will use GetProcAddress.But how to assign a value to a variable in that dll. Can anyone pls help me? Thanks,

        C Offline
        C Offline
        Code o mat
        wrote on last edited by
        #3

        The documentation[^] says:

        GetProcAddress Function

        Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL). ...

        So you probnably can access exported variables the same way as functions.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

        1 Reply Last reply
        0
        • P Pryabu

          Hi, Im using LoadLibrary function to load a dll.To call a function,we will use GetProcAddress.But how to assign a value to a variable in that dll. Can anyone pls help me? Thanks,

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

          Why don't you define an accessor function in the DLL? :)

          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
          • C CPallini

            Why don't you define an accessor function in the DLL? :)

            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
            #5

            The dll is given by some vendor. Just im using that one. I cant define functions in dll.

            C 1 Reply Last reply
            0
            • P Pryabu

              The dll is given by some vendor. Just im using that one. I cant define functions in dll.

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

              OK. As side note, it is really strange that the vendor exposes a DLL's variable. :)

              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