请问在DELPHI中如何检测计算机连接上网与否???(50分)

  • 主题发起人 主题发起人 乐子
  • 开始时间 开始时间

乐子

Unregistered / Unconfirmed
GUEST, unregistred user!
如题
如未,则如何在程序中进行连接(或调出拔号窗口)??

又如何调用IE并打开指定网址呢??

请恕本人是新手,无知了~~~~~
谢谢
 
1、调出拨号窗口
procedure TSendDataForm.btnDailClick(Sender: TObject);
var
registryValue:TRegistry;
getconnect:string;
Text:array[0..255] of char;
begin
registryValue := TRegistry.Create;
with registryValue do
begin
RootKey := HKEY_CURRENT_USER;
if OpenKey('RemoteAccess',false) then
getconnect:=ReadString('default');
CloseKey;
end;
RegistryValue.Free;
strPCopy(Text,'rundll32.exe rnaui.dll,RnaDial '+GetConnect);
winexec(Text,SW_SHOWNORMAL);
end;

2、打开网页
RzURLLabel1.URL:='www.sin.com.cn';
RzURLLabel1.Click;

需要安装Raize的控件,绝对可以。
 
兄台的方法我试过了,但好像只能在WIN98成功,2000就不行了~~~~

还有就是Raize控件在哪儿??要下载吗??

谢谢
 
//uses Wininet
//返回true则上网,否则false
function NetInternetConnected: 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+INTERNET_CONNECTION_MODEM
+INTERNET_CONNECTION_PROXY;
//Result := InternetGetConnectedState(@dwConnectionTypes, 1);
Result := InternetGetConnectedState(@dwConnectionTypes, 0);
end;
 
//检查是否连上internet 需要use Registry
function isoninternet:boolean;
var
b: array[0..4] of Byte;
begin
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
OpenKey('System/CurrentControlSet/Services/RemoteAccess',False);
ReadBinaryData('Remote Connection',b,4);
finally
Free;
end;
if b[0]=1 then result:=true else result:=false;
end;
 
给分吧,我测试过,在windows2000下,呵呵
uses
WinInet;

procedure TForm1.Timer1Timer(Sender: TObject);
function 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_MODEM + INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
Result := InternetGetConnectedState(@dwConnectionTypes,0);
END;

begin
if InternetConnected then
caption:=' Connected'
else caption:=' not Connected';
end;
 
这么多,认真看看,学习学习
 
其实很简单的

if GetSystemMetrics(SM_NETWORK) And $01=$01 then
showmessage('连上网络')

 
后退
顶部