|
|
#1 |
|
Junior Member
Join Date: Jul 2004
Posts: 36
|
Is the computer connected
Hi,
I didn't find anything like this in the archives, so this is my humble contribution to the NSIS community, a code snippet to determine if the computer is connected through a LAN, by modem or by proxy. Unfortunately, if the computer is connected to a router, it will still count as a valid connection, even if the router itself isn't connected to the internet. Some may still find it useful.Comments are of course welcome. ![]() KenA |
|
|
|
|
|
#2 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,337
|
What's wrong with the Dialer plug-in?
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#3 | |
|
Junior Member
Join Date: Jul 2004
Posts: 36
|
Quote:
KenA |
|
|
|
|
|
|
#4 | |
|
Major Dude
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,220
|
Quote:
If installer already uses System plug-in, 'pure' script variant decreases package size. BTW my MSDN says that first parameter is "OUT LPDWORD lpdwFlags", so you can skip it's initialization. Simply: System::Call 'wininet.dll::InternetGetConnectedState(*i .r11, i 0) .r10' StrCmp $R0 "0" 0 +2 MessageBox ... Quit |
|
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Sep 2004
Location: Los Angeles
Posts: 223
|
I use this function:
pardon the text formatting..... Function InternetConnection ;Check Internet Connection by calling Explorer with the System Plugin Banner::show /NOUNLOAD /set 76 "Checking for an Internet connection." "Please Wait" System::Call "wininet::InternetCheckConnection( \ t 'http://www.google.com/', \ i ${FLAG_ICC_FORCE_CONNECTION}, i 0) i .r0" StrCmp $0 "error" noie3 +1 StrCmp $0 "0" noconnection success noie3: Banner: estroyMessageBox MB_OK|MB_ICONSTOP "Please Connect the Internet to see the Fonovisa Player." abort ;Quit ;This will quit the installer. You might want to add your own error handling. noconnection: Banner: estroyMessageBox MB_OK|MB_ICONSTOP "Please Connect the Internet to see the Fonovisa Player." abort ;Quit ;This will quit the installer. You might want to add your own error handling. success: Banner: estroyFunctionEnd |
|
|
|
|
|
#6 |
|
Major Dude
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,220
|
MSDN, InternetCheckConnection: "If lpszUrl is non-NULL, the host value is extracted from it and used to ping that specific host." Some sysadmins just close ICMP (ping) traffic on firewall, so this may not work for a big part of users. And you must be sure that host will answer - this is not constant value too, google may be down or they can turn off ICMP after DOS atack.
So better use your real destination host URL, but this still not gives 100% guarantee. |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Sep 2004
Location: Los Angeles
Posts: 223
|
so what would you recommend?
System::Call 'wininet.dll::InternetGetConnectedState(*i .r11, i 0) .r10' StrCmp $R0 "0" 0 +2 MessageBox ... Quit or using NSISDL::download with a timeout ? many thanks |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
|
InternetCheckConnection crashed installer on Win98. Is there another way to ping server?
|
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Dec 2004
Location: Turkey
Posts: 447
|
Yep, because wininet.dll is not always available on all os's
|
|
|
|
|
|
#10 | |
|
Senior Member
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
|
From MSDN (about InternetCheckConnection):
Quote:
|
|
|
|
|
|
|
#11 | |
|
Major Dude
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,220
|
Quote:
|
|
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
|
What about Windows ME? Can somebody check work of this function on this platform?
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|