如题~~~我的一个程序中是有用到搜索局域网中所有计算机的SQL数据库的,如果计算机上有连接网线,则可以实现该功能,但是如果没有网线时,不起作用了,要如何进行判断?

解决方案 »

  1.   

    //检查连网状态
    function TForm1.InternetConnected: boolean;
    const
      // local system uses a modem to connect to the internet.
      // internet_connection_modem      = 1;
      // local system uses a local area network to connect to the internet.
      internet_connection_lan        = 2;
      // local system uses a proxy server to connect to the internet.
      // internet_connection_proxy      = 4;
      // local system''s modem is busy with a non-internet connection.
      // internet_connection_modem_busy = 8;
    var
      dwconnectiontypes : dword;
    begin
      dwconnectiontypes := nternet_connection_lan; 
      result := internetgetconnectedstate(@dwconnectiontypes, 0);
    end;
      

  2.   

    看得不太明白~~~dword 这个是什么类型的呢?
     nternet_connection_lan 这个又表示什么意思??
    不好意思哦~~~我是新手~加菜鸟~!
      

  3.   

    DWORD 是32位的一个整型值,楼上的代码需要uses Wininet//检查连网状态
    function TForm1.InternetConnected: boolean;
    const
      // local system uses a modem to connect to the internet.
      // internet_connection_modem      = 1;
      // local system uses a local area network to connect to the internet.
      internet_connection_lan        = 2;
      // local system uses a proxy server to connect to the internet.
      // internet_connection_proxy      = 4;
      // local system''s modem is busy with a non-internet connection.
      // internet_connection_modem_busy = 8;
    var
      dwconnectiontypes : dword;
    begin
      dwconnectiontypes := internet_connection_lan; 
      result := internetgetconnectedstate(@dwconnectiontypes, 0);
    end;
      

  4.   

    function TE_databasef.InternetConnected: boolean;
    var
      dwconnectiontypes : integer;
    begin
      dwconnectiontypes:=INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN +
                          INTERNET_CONNECTION_PROXY;
     if InternetGetConnectedState(@dwconnectiontypes, 0) then
        Result := False
     else
        Result := True;
    end;
    在该窗体创建时进行判断 if not InternetConnected then 
                              showmessage('无网络状态')
                           else
                             begin
                             end;
    可不知道为什么第一次把网线拨掉时会运行正常,提示无网络状态,可将网线插上后还一直提示'无网络状态~!!
      

  5.   

    放到一个timer中,每隔几秒检测一下网络状态procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      if InternetConnected then
        Caption := '网络正常'
      else
        Caption := '无网络';
    end;
      

  6.   

    确定你要连接的网络
    ping 下交换机。。 或者其他 ip
      

  7.   

    晕哦~~~现在不都可以上网的~~~~可 
    dwconnectiontypes:=INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN +
                          INTERNET_CONNECTION_PROXY;
    它的值起先为17,(没有插网线)
    我插网线后一直为18,结果是为假的啊.
    试试  postren(小虫) 的方法看~
      

  8.   

    没得救了~~~各位帮帮忙啊!~!还是不行期 dwconnectiontypes 值有问题!
    还有问下有哪位有用过sqldmo_tlb这个文件???????
    要修改application类,可不懂在哪里修改,现在程序中一直不能用application.方法,与DELPHI自定义的application类有冲突!