... uses Winsock ... function findcomputer(computerName:String):Boolean; ... function findcomputer(computername:String):Boolean; var WSAData:TWSAData; HostEnt:PHostEnt; begin result:=True; WSAStartup(2,WSAData); HostEnt:=GetHostByName(PChar(ComputerName)); if HostEnt=Nil then Result:=False; WSACleanup end;你调用就可以了,下面是根据计算机名来进行查看的. if FindComputer(Edit1.text)=True then messagebox('edit1.text+在网上') else messagebox('edit1.text+不在网上');不知道你要的是不是这个,这个是取局域网内的计算机~
网络是否连接 procedure TForm1.Button1Click(Sender: TObject); var Types : Integer; begin { CopyRight (C) Bowman } { [email protected] } Types := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN + INTERNET_CONNECTION_PROXY; //check 3 conditions together if InternetGetConnectedState(@types, 0) then Edit1.Text := 'your pc is Online now' else Edit1.Text := 'your pc is offline now'; end;
uses Winsock
...
function findcomputer(computerName:String):Boolean;
...
function findcomputer(computername:String):Boolean;
var
WSAData:TWSAData;
HostEnt:PHostEnt;
begin
result:=True;
WSAStartup(2,WSAData);
HostEnt:=GetHostByName(PChar(ComputerName));
if HostEnt=Nil then Result:=False;
WSACleanup
end;你调用就可以了,下面是根据计算机名来进行查看的.
if FindComputer(Edit1.text)=True then
messagebox('edit1.text+在网上')
else
messagebox('edit1.text+不在网上');不知道你要的是不是这个,这个是取局域网内的计算机~
procedure TForm1.Button1Click(Sender: TObject);
var
Types : Integer;
begin
{ CopyRight (C) Bowman }
{ [email protected] }
Types := INTERNET_CONNECTION_MODEM +
INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
//check 3 conditions together
if InternetGetConnectedState(@types, 0) then
Edit1.Text := 'your pc is Online now'
else
Edit1.Text := 'your pc is offline now';
end;