[Lazarus] Finding out the Hostname of the Computer.

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Sat Nov 29 12:39:28 CET 2008


Malcolm Poole wrote:
> AleŇ° Katona wrote:
>> If you want the value of $HOSTNAME, use unit SysUtils and GetEnvironmentVariable('HOSTNAME');
>>   
> Hmm. This was the first thing that I tried. For some reason I get an 
> empty string on my system (Ubuntu Gutsy). That's why I dug around and 
> found the GetHostName function.
> 
> Any idea why GetEnvironmentVariable('HOSTNAME') doesn't work for me? 
> 'echo $HOSTNAME' on the commandline works as expected.

Check it's been exported, i.e. processes forked by the shell simply 
might not be getting a copy.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the Lazarus mailing list