Thread View: borland.public.jbuilder.java.language
4 messages
4 total messages
Started by Oliver
Thu, 02 Mar 2006 13:43
System.getenv() problem
Author: Oliver
Date: Thu, 02 Mar 2006 13:43
Date: Thu, 02 Mar 2006 13:43
13 lines
1463 bytes
1463 bytes
Hi, i have a little problem in retrieving system environment variables. Windows 2000 SP4. I use JDK 1.5 and - under normal circumstances - my Java app retrieves the System.getenv() map correctly. But: if i start my Java app from another Delphi app (i use ShellExecute there), i dont get the map. Interestingly this behavior is also system dependent: on my desktop it doesnt matter how i start my Java app, on my laptop i get the environment only when i start my Java app manually (not when i start it via the Delphi app). I guess this is connected to parent/child processes but im unsure what is the best way to solve this... regards Oliver
Re: System.getenv() problem
Author: Lori M Olson [TeamB]
Date: Thu, 02 Mar 2006 14:53
Date: Thu, 02 Mar 2006 14:53
47 lines
2524 bytes
2524 bytes
Oliver wrote:
> Hi,
>
> i have a little problem in retrieving system environment variables.
> Windows 2000 SP4. I use JDK 1.5 and - under normal circumstances - my
> Java app retrieves the System.getenv() map correctly. But: if i start
> my Java app from another Delphi app (i use ShellExecute there), i
> dont get the map.
>
> Interestingly this behavior is also system dependent: on my desktop
> it doesnt matter how i start my Java app, on my laptop i get the
> environment only when i start my Java app manually (not when i start
> it via the Delphi app).
>
> I guess this is connected to parent/child processes but im unsure
> what is the best way to solve this...
>
> regards
>
> Oliver
>
Because this works manually, but not from the Delphi ShellExecute, I'm
going to point directly at Delphi as source of the issue. You'll need
to find out more about ShellExecute, and how to ensure that the
environment is passed to child processes.
Is there documentation for ShellExecute? What does it say?
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Re: System.getenv() problem
Author: Oliver
Date: Thu, 02 Mar 2006 14:57
Date: Thu, 02 Mar 2006 14:57
25 lines
1603 bytes
1603 bytes
Hi
the doc says
HINSTANCE ShellExecute(
HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
);
at the moment im using
NewInstance := ShellExecute(Application.Handle,'open',
pchar(CfgInfo.RemotePath),'',NIL, SW_SHOWNORMAL);
Do i need the defaut directory perhaps?!
pchar(CfgInfo.RemotePath) is the path to my Java executable.
regards
Oliver
Re: System.getenv() problem - probably solved :)
Author: Oliver
Date: Thu, 02 Mar 2006 15:31
Date: Thu, 02 Mar 2006 15:31
23 lines
1578 bytes
1578 bytes
Hi,
i think ive solved the issue. I dont use ShellExecute, but instead
Result:= Windows.CreateProcess(
nil, //AppName
PChar(anAppName+' '+aCmdLine), //CmdLine
nil, //ProcessSecurity
nil, //ThreadSecurity
False, //Handle Inheritance
NORMAL_PRIORITY_CLASS, //Creation Flags
nil, //Environment
PChar(ExtractFilePath(anAppName)), //Dir
lStartupInfo,
lProcessInfo
);
if Environment is passed as nil then the environment of the parent process is being passed (i suspect that ShellExecute uses an "empty environment"?!).
thanks for the hints (as you said Java was innocent here :) )
Oliver
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads