Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 11th October 2004, 16:19   #1
KenA
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
Attached Files
File Type: nsi connectcheck2.nsi (838 Bytes, 147 views)
KenA is offline   Reply With Quote
Old 11th October 2004, 16:21   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
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
kichik is offline   Reply With Quote
Old 11th October 2004, 16:32   #3
KenA
Junior Member
 
Join Date: Jul 2004
Posts: 36
Quote:
Originally posted by kichik
What's wrong with the Dialer plug-in?
D'oh ! Nothing at all. It's just me making a fool of myself by re-inventing the wheel.

KenA
KenA is offline   Reply With Quote
Old 12th October 2004, 08:30   #4
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,220
Quote:
Originally posted by kichik
What's wrong with the Dialer plug-in?
Dialer plug-in size is 4 kB.

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
Takhir is offline   Reply With Quote
Old 13th October 2004, 23:46   #5
grahama
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:estroy
MessageBox 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:estroy
MessageBox 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:estroy

FunctionEnd
grahama is offline   Reply With Quote
Old 14th October 2004, 12:07   #6
Takhir
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.
Takhir is offline   Reply With Quote
Old 14th October 2004, 21:27   #7
grahama
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
grahama is offline   Reply With Quote
Old 28th June 2005, 12:10   #8
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
InternetCheckConnection crashed installer on Win98. Is there another way to ping server?
glory_man is offline   Reply With Quote
Old 28th June 2005, 12:37   #9
onad
Senior Member
 
onad's Avatar
 
Join Date: Dec 2004
Location: Turkey
Posts: 447
Yep, because wininet.dll is not always available on all os's
onad is offline   Reply With Quote
Old 28th June 2005, 13:42   #10
glory_man
Senior Member
 
Join Date: Sep 2004
Location: Mogilev (Belarus)
Posts: 372
From MSDN (about InternetCheckConnection):
Quote:
Function Information

Windows NT Use version 4.0. Implemented as ANSI and Unicode functions.
Windows Use Windows 95 and later. Implemented as ANSI and Unicode functions.
Header Wininet.h
Import library Wininet.lib
Minimum availability Internet Explorer 3.0 (ANSI only), 5 (ANSI and Unicode)
The same problem: link.
glory_man is offline   Reply With Quote
Old 28th June 2005, 14:28   #11
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,220
Quote:
onad
Yep, because wininet.dll is not always available on all os's
This dll came with IE in old Windows versions Minimum availability Internet Explorer 3.0, the only OS without wininet I remember is Win95 Gold
Takhir is offline   Reply With Quote
Old 12th July 2005, 15:42   #12
glory_man
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?
glory_man is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump