Declare Function SetEnvironmentVariable lib "kernel32" Alias "SetEnvironmentVariableA" (ByVal lpName as string, ByVal lpValue as String)
lpName is the name of the environment variable to set. If it does not exist, this function will create it.
lpValue is the value to set. NULL value clears an existing value
Writing to the environment is pointless. Even with the API.
The environment is just a scratch pad for the current process. Once your VB App ends, it's environment goes too. Anything you put there is lost. Since the data is only available to your application, variables work much better. If you are looking for an inter process communication pathway, the environment of the current process is not the answer.
The Registry and old INI API provides the easiest way to pass values. Using them is much easier than finding and using your parent processes environment. MUCH EASIER.
Thanks,
that works fine. (Needed to add the "as Boolean" at the end of the function declaration, but otherwise perfect!)
The VB program is a wrapper for an old DOS program that uses environment variables. The VB program remains active during the DOS program so all works fine. Gives me the possibility to use the VB wrapper to find the variables I want in the regisrty if they aren't sent in the environment. Seems to work hte way I want it. Better would be to re-write the DOS application........
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.