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. Using exported varible from dll

Using exported varible from dll

Scheduled Pinned Locked Moved C / C++ / MFC
questionjson
10 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
    MANISH RASTOGI
    wrote on last edited by
    #1

    Hi, I have exported dll from dll. I load dll using loadlibrary api. Using GetProceAddress I can get exported function pointer. But how can I use exported dll. __declspec(dllimport) only works when I link through .lib but in LoadLibrary? Thanks

    CPalliniC 1 Reply Last reply
    0
    • M MANISH RASTOGI

      Hi, I have exported dll from dll. I load dll using loadlibrary api. Using GetProceAddress I can get exported function pointer. But how can I use exported dll. __declspec(dllimport) only works when I link through .lib but in LoadLibrary? Thanks

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      manish rastogi wrote:

      Using GetProceAddress I can get exported function pointer. But how can I use exported dll.

      This way [^].

      manish rastogi wrote:

      __declspec(dllimport) only works when I link through .lib but in LoadLibrary?

      You don't need _declspec(dllimport) when you use explicit DLL linking (i.e. LoadLibrary). Actually, when you use explicit DLL linking, you don't need the library header file at all. :)

      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]

      In testa che avete, signor di Ceprano?

      M 1 Reply Last reply
      0
      • CPalliniC CPallini

        manish rastogi wrote:

        Using GetProceAddress I can get exported function pointer. But how can I use exported dll.

        This way [^].

        manish rastogi wrote:

        __declspec(dllimport) only works when I link through .lib but in LoadLibrary?

        You don't need _declspec(dllimport) when you use explicit DLL linking (i.e. LoadLibrary). Actually, when you use explicit DLL linking, you don't need the library header file at all. :)

        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]

        M Offline
        M Offline
        MANISH RASTOGI
        wrote on last edited by
        #3

        Sir, Thanks for your quick response. I want to import data. Suppose I exported data from dll using this way __declspec(dllexport) long g_lValue. How can I access it using explicit dll linking. Thanks

        CPalliniC 1 Reply Last reply
        0
        • M MANISH RASTOGI

          Sir, Thanks for your quick response. I want to import data. Suppose I exported data from dll using this way __declspec(dllexport) long g_lValue. How can I access it using explicit dll linking. Thanks

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

          Why don't you (write and) export the accessors (i.e. get/set functions) of your integer 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]

          In testa che avete, signor di Ceprano?

          M 1 Reply Last reply
          0
          • CPalliniC CPallini

            Why don't you (write and) export the accessors (i.e. get/set functions) of your integer 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]

            M Offline
            M Offline
            MANISH RASTOGI
            wrote on last edited by
            #5

            Sir, I can do this by writing get/set functions. I want to know this only It is possible or not.

            CPalliniC 1 Reply Last reply
            0
            • M MANISH RASTOGI

              Sir, I can do this by writing get/set functions. I want to know this only It is possible or not.

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

              manish rastogi wrote:

              I want to know this only It is possible or not.

              Yes, it is possible. :-D

              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]

              In testa che avete, signor di Ceprano?

              M 1 Reply Last reply
              0
              • CPalliniC CPallini

                manish rastogi wrote:

                I want to know this only It is possible or not.

                Yes, it is possible. :-D

                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]

                M Offline
                M Offline
                MANISH RASTOGI
                wrote on last edited by
                #7

                How can I do it Sir?

                CPalliniC 1 Reply Last reply
                0
                • M MANISH RASTOGI

                  How can I do it Sir?

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  For instance: (DLL header)

                  #ifdef __cplusplus
                  extern "C"
                  {
                  #endif
                  extern DLLTEST_API int iExported;
                  #ifdef __cplusplus
                  };
                  #endif

                  (DLL source)

                  #ifdef __cplusplus
                  extern "C"
                  {
                  #endif
                  DLLTEST_API int iExported;
                  #ifdef __cplusplus
                  };
                  #endif

                  (DLL client)

                  //...
                  int * pInt =(int *) GetProcAddress(hLib, "iExported");

                  :)

                  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]

                  In testa che avete, signor di Ceprano?

                  M 1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    For instance: (DLL header)

                    #ifdef __cplusplus
                    extern "C"
                    {
                    #endif
                    extern DLLTEST_API int iExported;
                    #ifdef __cplusplus
                    };
                    #endif

                    (DLL source)

                    #ifdef __cplusplus
                    extern "C"
                    {
                    #endif
                    DLLTEST_API int iExported;
                    #ifdef __cplusplus
                    };
                    #endif

                    (DLL client)

                    //...
                    int * pInt =(int *) GetProcAddress(hLib, "iExported");

                    :)

                    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]

                    M Offline
                    M Offline
                    MANISH RASTOGI
                    wrote on last edited by
                    #9

                    Thanks Sir, It worked.

                    CPalliniC 1 Reply Last reply
                    0
                    • M MANISH RASTOGI

                      Thanks Sir, It worked.

                      CPalliniC Offline
                      CPalliniC Offline
                      CPallini
                      wrote on last edited by
                      #10

                      You're welcome. :)

                      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]

                      In testa che avete, signor di Ceprano?

                      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