PDA

View Full Version : KB: Determining if a Network (LAN) is Present


Desmond
10-03-2003, 11:46 AM
<HTML> <HEAD> <TITLE>AutoPlay Media Studio 5.0 Knowledge Base</TITLE> </HEAD> <BODY> <h3>Determining if a Network (LAN) is Present </h3> <b>Document ID: IR10071</b> <hr> The information in this article applies to: <ul> <li>AutoPlay Media Studio 5.0 Professional Edition</li> </ul> <hr> <h3>SUMMARY</h3> <p>This article describes how to determine if a network connection is present on the user's computer.</p> <h3>DISCUSSION</h3> <p>In AutoPlay Media Studio 5.0, to determine if a user is connected to a LAN, insert the following code into any event in your application:<pre><code>lan = System.GetLANInfo();
<br />lan_exist = true;
<br />for j in lan do
<br /> if lan[j] == "Unknown" then
<br /> lan_exist = false;
<br /> end
<br />end
<br />
<br />if lan_exist then
<br /> Dialog.Message("", "You are connected to a LAN");
<br />else
<br /> Dialog.Message("", "You are not connected to a LAN");
<br />end</code></pre> <br> Please note that this example works in Windows 98 First Edition, Windows 98 Second Edition, Windows 2000, and Windows XP. Windows 95 and Windows NT do not fit this model. To detect a LAN connection in all operating systems, first detect the user's OS, and the launch an appropriate detection script. <h3>MORE INFORMATION</h3> <p>For more information please see the following topics in the AutoPlay Media Studio 5.0 help file:</p> <ul> <li><b>Program Reference | Actions | System | System.GetLANInfo</b></li> </ul> <p>KEYWORDS: AutoPlay Media Studio 5.0, System, Network, LAN, Detect </p> <hr> <FONT SIZE=1> Last reviewed: October 3, 2003<br> Copyright © 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.<br> </FONT> </BODY> </HTML> :confused:

SUF6NEWBIE
08-07-2004, 11:39 PM
I would like to add to Desmonds script to cover more (not connected)

lan = System.GetLANInfo();
lan_exist = true;
for j in lan do
if (lan[j] == "Unknown") or (lan[j] == "127.0.0.1") then
lan_exist = false;
end
end

if lan_exist then
Dialog.Message("", "You are connected to a LAN");
else
Dialog.Message("", "You are not connected to a LAN");
end

NOTE: 127.0.0.1 is often returned instead of "Unknown"
above is a common return value for networks using
MSHOME as network type and currnetly not connected