Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GetComputerNameEX

623 views
Skip to first unread message

Serge Myrand

unread,
Jan 10, 2005, 2:31:11 PM1/10/05
to
Hi everyones,

How to call GetComputerNameEX from Delphi 7?

thanks
serge

Jon E. Scott

unread,
Jan 10, 2005, 4:42:40 PM1/10/05
to
You mean GetComputerName()?

procedure TForm1.Button1Click(Sender: TObject);
var
ABuf: array[0..MAX_COMPUTERNAME_LENGTH] of Char;
ASize: Cardinal;
begin
ASize := SizeOf(ABuf);
FillChar(ABuf, ASize, #0);
if GetComputerName(ABuf, ASize) then
Label1.Caption := ABuf;
end;

--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com


"Serge Myrand" <in...@softdelirium.qc.ca> wrote in message
news:41E2D7FF...@softdelirium.qc.ca...

Jon E. Scott

unread,
Jan 10, 2005, 5:14:01 PM1/10/05
to
No, I don't. I use GExperts to search units for a specific function name.

--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com


"Serge Myrand" <in...@softdelirium.qc.ca> wrote in message

news:41E2EFDF...@softdelirium.qc.ca...
> Thank you very much. Do you know a listing to know which methods are in
> which .pas?
>
> serge
>


Jon E. Scott

unread,
Jan 10, 2005, 4:54:36 PM1/10/05
to
JEDI has GetComputerNameEx() header translation in the Win32API.zip file
(specifically JwaWinBase.pas):

ftp://delphi-jedi.org/api/win32api.zip

--
Thanks,
Jon E. Scott
Blue Orb Software
http://www.blueorbsoft.com


"Serge Myrand" <in...@softdelirium.qc.ca> wrote in message

news:41E2D7FF...@softdelirium.qc.ca...

Serge Myrand

unread,
Jan 10, 2005, 4:13:03 PM1/10/05
to
Thank you very much. Do you know a listing to know which methods are in
which .pas?

serge

Serge Myrand

unread,
Jan 10, 2005, 4:02:51 PM1/10/05
to
Hi,

No I mean GetComputerNamEx, I need to retrived the fully qualified path
including the domain name. This method is not defined in Windows.pas
neither in ShellAPI.pas

thanks
serge

dennispassmore

unread,
Jan 11, 2005, 8:27:49 AM1/11/05
to
as follows:

type
COMPUTER_NAME_FORMAT = (
ComputerNameNetBIOS,
ComputerNameDnsHostname,
ComputerNameDnsDomain,
ComputerNameDnsFullyQualified,
ComputerNamePhysicalNetBIOS,
ComputerNamePhysicalDnsHostname,
ComputerNamePhysicalDnsDomain,
ComputerNamePhysicalDnsFullyQualified,
ComputerNameMax);

implementation

// Client: Requires Windows XP or Windows 2000 Professional.
// Server: Requires Windows Server 2003 or Windows 2000 Server.

function GetComputerNameEx(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPSTR;
var nSize: DWORD): BOOL; stdcall; external kernel32 name 'GetComputerNameExA';

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
dSize: dword;
sResult: string;
c: COMPUTER_NAME_FORMAT;
begin
Memo1.lines.clear;
SetLength(sResult, 255);
for c := low(COMPUTER_NAME_FORMAT) to high(COMPUTER_NAME_FORMAT) do
begin
dSize := 255;
GetComputerNameEx(c,pchar(sResult), dSize);
if dSize > 1 then
Memo1.Lines.add(sResult)
else
Memo1.Lines.add('(nil)');
end;
end;

Dennis Passmore
Ultimate Software, Inc.

Serge Myrand

unread,
Jan 11, 2005, 12:40:51 PM1/11/05
to
Thank's for your time Dennis.

serge

0 new messages