DelphiFAQ Home Search:

Detect whether the network is installed


commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.


I need to programmatically find out if a computer has the network installed.


You can use the Windows function GetSystemMetrics(SM_NETWORK). This will tell you if the Windows installation includes network connection(s).

Sometimes it is claimed that this function will detect whether the machine is actually attached to a network. This is not true. The function will return the same resullts if the network connection is disabled and your computer is thus offline (not part of the network).

  Name:       TForm1.Button1Click
procedure TForm1.Button1Click(Sender: TObject);
begin { TForm1.Button1Click }
  if GetSystemMetrics(SM_NETWORK) and $01=$01 then
    ShowMessage('Computer is attached to a network!')
    ShowMessage('Computer is not attached to a network!')
end; { TForm1.Button1Click }

Content-type: text/html


2012-11-12, 05:31:40
coach001 from United States  



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: