Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mapping and Unmapping
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00137678
Message ID:
00138316
Views:
10
>>>Mark,
>>>
>>>DOS search path? Isn't the VFP path sufficient? That, I know, you know how to modify on the fly. Or is this for a non-VFP application?
>>>
>>>BTW, I see it's gotten (at least recently) a bit cooler in your neck of the woods.
>>
>>The weather here is beautiful - cloudy, rainy and cooler (70s to low 80s). WE are literally singing in the rain.
>
>You aren't doing a Gene Kelley impersonation now are you?:-)
>
>>It is a VFP app, and I do need an actual DOS search path addition. The problem is the Oracle products insist on their directory being in the DOS Env path variable. Yeah, I tried doing a set path in VFP, but this does not work for the Oracle prods. This is most irritating to say the least.
>
>Is it already running? If so, I'm not sure that your resetting it will have any effect. It doesn't get its path from the registry? Bummer. If it did, you could modify that setting. I've played around with the idea of creating a batch file on the fly and executing that, but, on my machine it had no effect.

If it -isn't- already running, there is a solution, since CreateProcess() allows you to pass a specific DOS environment variable set to a child process at creation time. If you look at my LaunchAppAndWait example, you'll notice that the 7th parameter passed to the API call (lpEnvironment) is passed as a0 - a null pointer, which means that you want to inherit the current environment string. Alternatively, you could construct a string of environment variables as follows:
"PATH=C:\WINDOWS,C:\WINDOWS\COMMAND,\\MyServer\MyShare,Y:AndSoOn' + CHR(0) + ;
"SHELL=C:\COMMAND.COM" + CHR(0) + ;
"TEMP=C:\WINDOWS\TEMP" + CHR(0) + CHR(0)
It is important that the last environment string be terminated with two CHR(0) characters, so that the API call knows where the definition ends. It behaves somewhat like a REG_MULTI_SZ value in that respect.

Realize that if you create an environment block this way, you must create all values in the environment block - no environment variables from the parent environment will be passed along, just your constructed environment block.

Instead of passing the 0 as the seventh parameter, pass the constructed string BY REFERENCE (prefix with @) to the CreateProcess call. There are a number of caveats related to using the environment block passed to the new process involving the inherited properties of the child process; see the documentation for CreateProcess in the MSDN help for details. Specifically, you want to make absolutely certain to set an explicit lpCurrentDirectory (the 8th parameter for CreateProcess) or the worl can get very confused.

You'll be amazed at how easily you can hurt yourself making processes...
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform