Thursday, December 04, 2008

Getting the computer's network name

Source : http://www.latiumsoftware.com/en/delphi/00039.php

 

GetComputerName

If we want to know the name that identifies in a network the machine that is running our program, we can use the API Windows function GetComputerName that gives us the NetBIOS name of the local computer. The following function excapsulates the call to this API to return the machine name as a string:

uses Windows;  function GetComputerNetName: string; var   buffer: array[0..255] of char;   size: dword; begin   size := 256;   if GetComputerName(buffer, size) then     Result := buffer   else     Result := '' end;

Windows 2000 users can use the API GetComputerNameEx that appart from the NetBIOS name allows the retrieval of diverse DNS names.

Sample call

procedure TForm1.Button1Click(Sender: TObject); begin   ShowMessage(GetComputerNetName); end;
JfControls Library - for Delphi and C++ Builder


Dapatkan alamat Email baru Anda!
Dapatkan nama yang selalu Anda inginkan sebelum diambil orang lain!

0 Comments: