[Lazarus] Finding out the Hostname of the Computer.
Graeme Geldenhuys
graemeg.lists at gmail.com
Thu Nov 27 22:24:35 CET 2008
On Thu, Nov 27, 2008 at 3:28 PM, Dave Coventry <dgcoventry at gmail.com> wrote:
>
> I'm trying to get the name of the computer my app is running on.
>
> I've tried this:
We use the following in tiOPF for Delphi and FPC.
------------------------------------------------------
function tiGetComputerName : string;
begin
{$IFDEF MSWINDOWS}
Result := tiWin32GetComputerName;
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
Result := tiUnixGetComputerName;
{$ENDIF UNIX}
end;
---------------------------------------------
uses
unix;
function tiUnixGetComputerName: string;
begin
Result := GetHostName;
end;
--------------------------------------------
uses
Windows;
function tiWin32GetComputerName: string;
var
computerNameBuffer: array[0..255] of char;
sizeBuffer: DWord;
begin
SizeBuffer := 256;
getComputerName(computerNameBuffer, sizeBuffer);
result := string(computerNameBuffer);
end;
------------------------------------------------------
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
More information about the Lazarus
mailing list