Results 1 to 6 of 6

Thread: Exporting or importing global variables from a DLL to an EXE

  1. #1
    Join Date
    May 2012
    Posts
    42

    Exporting or importing global variables from a DLL to an EXE

    hey guys, i have a very short question. As the title says, i wanted to know about exporting or importing global variables from a DLL to an EXE. Is it possible to share global variable between dll and exe? Any comments to meet my requirement will be appreciated. Thanks a lot in advance.

  2. #2
    Join Date
    Mar 2011
    Posts
    160

    Re: Exporting or importing global variables from a DLL to an EXE

    Yes it is possible to share global variable between DLLs and exe fil. We know that, one can implement global variables by using programming languages such as C and C++. Hence you need write a code to achieve it. normally global variable is declared and implemented outside of the functions. However this particular variable exist inside the same scope into the single program. I let you know that

  3. #3
    Join Date
    May 2011
    Posts
    105

    Re: Exporting or importing global variables from a DLL to an EXE

    Quote Originally Posted by Fred Fruax View Post
    Yes it is possible to share global variable between DLLs and exe fil. We know that, one can implement global variables by using programming languages such as C and C++. Hence you need write a code to achieve it. normally global variable is declared and implemented outside of the functions. However this particular variable exist inside the same scope into the single program. I let you know that
    Well I think you are correct. It is normal practice, to create a function and passing appropriate value so that function which you had declared and defined could give , proper results. If you are not so familiar then I recommend to create a Com object. Once you had done the same, simply defined properties and functions for it.

  4. #4
    Join Date
    May 2011
    Posts
    102

    Re: Exporting or importing global variables from a DLL to an EXE

    Even you can do the same thing with class as well. you can use dllexport to export class to dll or function. To get better results you should take care of the thing that exe and dll are running into single process. However if needed you can simply place class to other dll file as well. if you are using C language then I recommend to do following steps.

    First of C wrapper API. After that use following Win32 API functions.
    • GetModuleHandle()
    • GetProcAddress()


    Now you should create proxy class into DLL which will call variable from exe to dll.

  5. #5
    Join Date
    Jun 2011
    Posts
    45

    Re: Exporting or importing global variables from a DLL to an EXE

    There are huge differences between external and exported variables. External variables are available in programming era from the days of C programming language. In simple terms we can say exported variables are extensions of Windows OS.

    I would recommend that one should make use of thread local storage. In my opinion file paths would not work particularly I am saying about global variables. API should be used to pass data to the function. To avoid issues, you should not use directly from memory. Why I am saying, the thing global variable can be accessed by any part of the program. So global variable and programming language like VB might be using same DLL, hence some sync should be done between the same.

  6. #6
    Join Date
    May 2009
    Posts
    527

    Re: Exporting or importing global variables from a DLL to an EXE

    As far as I know global variable should be set to single process. Normally it is initialized to every single module of the program. If you are using C++, then you will get the requirement of yours by using __declspec and __declspec. After that you will be able to export or import file through dll and exe.

Similar Threads

  1. Need settings for importing/exporting from imovie
    By Character in forum Windows Software
    Replies: 6
    Last Post: 31-05-2010, 02:45 PM
  2. How To Store Global Variables?
    By ramsun in forum Software Development
    Replies: 5
    Last Post: 03-03-2010, 12:54 PM
  3. Global Variables in C sharp
    By Harper 21 in forum Software Development
    Replies: 5
    Last Post: 20-01-2010, 08:43 AM
  4. Java bans Global Variables
    By KALLIYAN in forum Software Development
    Replies: 4
    Last Post: 10-11-2009, 04:17 AM
  5. Exporting and importing data
    By Humberto in forum Tips & Tweaks
    Replies: 2
    Last Post: 13-10-2008, 06:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,667,581.23805 seconds with 17 queries