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.
Printable View
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.
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?
anyone?
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?
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.
What you want to use is the Process class, and there is an example of how to use it here
You can see an example of the parameters in that link:
You would need something like this:Code:startInfo.Arguments = "www.northwindtraders.com"
Then in your other app, you can read the arguments using the example shown hereCode:startInfo.Arguments = "/MyInfo=" & MyDataString