[fpc-pascal] SysUtils.GetEnvironmentVariable

Marcos Douglas md at delfire.net
Thu Mar 29 13:41:09 CEST 2012


On Thu, Mar 29, 2012 at 8:17 AM,  <michael.vancanneyt at wisa.be> wrote:
>
>
> On Thu, 29 Mar 2012, Marcos Douglas wrote:
>
>> On Thu, Mar 29, 2012 at 5:42 AM, Mark Morgan Lloyd
>> <markMLl.fpc-pascal at telemetry.co.uk> wrote:
>>>
>>> Marcos Douglas wrote:
>>>
>>>> I know that I have to define the environment variable before or after
>>>> starting the application or IDE.
>>>> As I said, works in WinXP... but I had a little problem with a client
>>>> using Win7 so, I talked about this on lazarus-br list and asked to
>>>> somebody do the test on Win7 and they said the test did not work so, I
>>>> wrote here.
>>>
>>>
>>>
>>> I think the absolutely crucial thing here is to ask what the relationship
>>> between the session in which the shell/environment variable was defined,
>>> and
>>> the FPC program.
>>
>>
>> Nothing.
>>
>>> If the variable is set and the program is run from the same prompt,
>>> provided
>>> that it's not messed up by extra spaces or by e.g. an interposed
>>> command.com, then it should work.
>>
>>
>> No. The variable is set using a install program or Windows.
>>
>>> In any other case it might work, and it's entirely reasonable to assume
>>> that
>>> the extent to which variables are passed between running processes will
>>> vary
>>> wildly with OS version.
>>>
>>> I suggest the *first* thing to do is to confirm that the variable has
>>> stuck
>>> by using the  set  command. After that try running the Pascal program.
>>
>>
>> No command set is used.
>> The variable has been created in the Windows System Variables.
>
>
> He means that you must check using the SET command in a command window.
>
> So run - execute : CMD.exe
>
> In the command terminal that opens, type 'SET' (+enter)
>
> Your variable should show up in the list of environment variables.

I know I'm crazy because I develop to Win7 but I don't have the Win7
in all machines that I use... sorry about that... but again: I don't
have Win7 now and I can't send an application test to the user just to
confirm this.
The SET command can work but that means it work using the system variables too?

> Please note that under windows 7, there are system environment variables,
> and user variables.

Because this I always write System Variable and not User Variable.

> If the application is installed using user A, but user B runs your program,
> it is possible that the environment variable is not shown.
>
> It depends on how the variable was created by your installer. To check this,
> the command window can be used.

System Variable, for all users, and I checked the Win7.

> The RTL of Free Pascal just calls the Windows API to get the environment
> variable. No magic is performed.

Yes, I saw the sources, and because this I don't understand what is wrong.

Marcos Douglas



More information about the fpc-pascal mailing list