|
-
Sep 20th, 2010, 03:22 PM
#1
Thread Starter
Hyperactive Member
Pass a global variable from a dll to a exe??
HI everyone!
How can i pass a global variable from dll project to a exe file, after this i want to run the exe also from the dll.
How can i do this?
thanks.
-
Sep 20th, 2010, 04:42 PM
#2
Re: Pass a global variable from a dll to a exe??
You're going to have to explain that a bit better. If a variable is truly global, then you don't need to pass it anywhere. Therefore, I would assume that you mean that the variable is global to the dll, which I would expect means that you have it declared as Public in a module. If that is not the case, then this answer doesn't apply:
You can access a public variable in a public module of a dll with something like
<dll name><module name><variable name>
In fact, you probably don't need the module name. However, you could also make the variable private and provide a method in the dll that returns the variable.
As for the bit about running the exe from the dll: What does that even mean?
My usual boring signature: Nothing
 
-
Sep 20th, 2010, 05:07 PM
#3
Thread Starter
Hyperactive Member
Re: Pass a global variable from a dll to a exe??
Hi!
The dll and exe are individual seprated and compiled application's .
i need to pass a variable from a dll application to a exe application, hope you understand what i want here.
thanks
 Originally Posted by Shaggy Hiker
You're going to have to explain that a bit better. If a variable is truly global, then you don't need to pass it anywhere. Therefore, I would assume that you mean that the variable is global to the dll, which I would expect means that you have it declared as Public in a module. If that is not the case, then this answer doesn't apply:
You can access a public variable in a public module of a dll with something like
<dll name><module name><variable name>
In fact, you probably don't need the module name. However, you could also make the variable private and provide a method in the dll that returns the variable.
As for the bit about running the exe from the dll: What does that even mean?
-
Sep 21st, 2010, 03:40 PM
#4
Thread Starter
Hyperactive Member
Re: Pass a global variable from a dll to a exe??
-
Sep 21st, 2010, 04:40 PM
#5
Junior Member
Re: Pass a global variable from a dll to a exe??
How secure does this need to be? Does the dll actually execute the executable, or is that a seperate process? If it doesn't need to be very secure, and if the dll exec's the executable, can you pass it as a command line parameter?
Using VB 2010/2008/2005 (Windows and ASP)
-
Sep 21st, 2010, 04:55 PM
#6
Re: Pass a global variable from a dll to a exe??
There is no such thing as a dll application. A dll is loaded by a .exe
Your post still does not make sense. They are seperate files on disk yes, but how do you want them to communicate. Does the .exe load the .dll ? Is the .dll loaded by another .exe and you want to pass info to a running .exe or start a new copy of the .exe?
If you want to pass data to an existing .exe, it needs to know how to accept it. You can't just pass data into something else that is running and expect it to deal with it.
If you are starting a new .exe then go for passing in command parameters.
-
Sep 22nd, 2010, 06:16 PM
#7
Thread Starter
Hyperactive Member
Re: Pass a global variable from a dll to a exe??
HI!
Yes the dll executes the exe.
How do i pass it as a command line parameter?
what is the code to execute the exe from the dll?
 Originally Posted by ckennedy79
How secure does this need to be? Does the dll actually execute the executable, or is that a seperate process? If it doesn't need to be very secure, and if the dll exec's the executable, can you pass it as a command line parameter?
-
Sep 23rd, 2010, 03:32 AM
#8
Re: Pass a global variable from a dll to a exe??
What you want to use is the Process class, and there is an example of how to use it here
-
Sep 23rd, 2010, 05:42 AM
#9
Thread Starter
Hyperactive Member
Re: Pass a global variable from a dll to a exe??
about command line parameter? what do i have to do?
can someone give-me a example code?
 Originally Posted by Grimfort
What you want to use is the Process class, and there is an example of how to use it here
-
Sep 23rd, 2010, 06:23 AM
#10
Re: Pass a global variable from a dll to a exe??
You can see an example of the parameters in that link:
Code:
startInfo.Arguments = "www.northwindtraders.com"
You would need something like this:
Code:
startInfo.Arguments = "/MyInfo=" & MyDataString
Then in your other app, you can read the arguments using the example shown here
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|