Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , ,

Sponsored Links


Exporting or importing global variables from a DLL to an EXE

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 28-05-2012
Member
 
Join Date: May 2012
Posts: 41
Exporting or importing global variables from a DLL to an EXE

Sponsored Links
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.

Reply With Quote
  #2  
Old 28-05-2012
Member
 
Join Date: Mar 2011
Posts: 152
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
Reply With Quote
  #3  
Old 28-05-2012
Member
 
Join Date: May 2011
Posts: 101
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.
Reply With Quote
  #4  
Old 28-05-2012
Member
 
Join Date: May 2011
Posts: 94
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.
Reply With Quote
  #5  
Old 28-05-2012
Member
 
Join Date: Jun 2011
Posts: 40
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.
Reply With Quote
  #6  
Old 28-05-2012
Shreevats's Avatar
Member
 
Join Date: May 2009
Posts: 514
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Exporting or importing global variables from a DLL to an EXE"
Thread Thread Starter Forum Replies Last Post
Need settings for importing/exporting from imovie Character Windows Software 6 31-05-2010 02:45 PM
How To Store Global Variables? ramsun Software Development 5 03-03-2010 11:54 AM
Global Variables in C sharp Harper 21 Software Development 5 20-01-2010 07:43 AM
Java bans Global Variables KALLIYAN Software Development 4 10-11-2009 03:17 AM
Exporting and importing data Humberto Tips & Tweaks 2 13-10-2008 06:07 PM


All times are GMT +5.5. The time now is 05:38 AM.