如何在WIN98下用DELPHI快速检测网路是否连接(50分)

  • 主题发起人 主题发起人 hezhilong
  • 开始时间 开始时间
H

hezhilong

Unregistered / Unconfirmed
GUEST, unregistred user!
我在WINDOWS 2000下C打开lintDataSet时,若断网则马上报错,可在WINDOWS98下则要
等待很长时间才报错,我希望在WINDOWS98下能象WINDOWS 2000一样,应如何解决?
另外,在WINDOWS 98下如何快速检测网络是否连接?
 
没人回答?
 
利用以下程序检测计算机有没有连网,如果有,状态栏显示正常,没有刚显示失败提示!
我试过,没问题。
以下为源代码:
unit newdial;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
KsHooks, KsForms, EpIIForms, OleCtrls, SHDocVw, ComCtrls, StdCtrls,
ExtCtrls, KsControls, KsButtons, EpIIButtons, KsItems, EpIIItems,
KsMenus, EpIIMenus,Winsock, SkinEngine, SkinCtrls, SkinButton; //此处要增加引用winsock;

type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
Panel1: TPanel;
WebBrowser1: TWebBrowser;
scSkinStore1: TscSkinStore;
scSkinEngine1: TscSkinEngine;
EpButton1: TEpButton;
EpButton2: TEpButton;
EpButton3: TEpButton;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
procedure CustomItem5Click(Sender: TObject);
procedure CustomItem6Click(Sender: TObject);
procedure scButton1Click(Sender: TObject);
procedure EpButton1Click(Sender: TObject);
procedure EpButton3Click(Sender: TObject);
procedure EpButton2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
function FindComputer(ComputerName: string):Boolean;//此处要增加这些声明;
implementation

uses Unit2, Unit3;

{$R *.DFM}

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; //此处要定义这个动作;

procedure TForm1.FormCreate(Sender: TObject);
begin
if FindComputer('ntserver')=True then
statusbar1.Panels[0].text:=' 计算机ntserver已找到!'
else
statusbar1.Panels[0].text:='计算机ntserver未找到!';
end;

end.
 
接受答案了.
 
后退
顶部