How to call GetComputerNameEX from Delphi 7?
thanks
serge
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...
--
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
>
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
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
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