This handler will find the IP Address and other related information from the Windows registry. It should work on all versions of Windows from Win95 through XP. It requires the Buddy API xtra.
--This requires BudAPI
--Script written by Mike Blaustein 2003
--Just make this a #movie script in your cast
--If you call getIP(), you get a property list with 4 objects
--It will look something like this:
-- [#Address: "192.168.0.111", #DHCP: "Yes", #Subnet: "255.255.255.0", #Gateway: "192.168.0.100"]
--If you call getIP().Address, you will get a string containing the IP
--If you call getIP().DHCP, you will get an integer -> 1 for true, 0 for false
--If you call getIP().Subnet,you will get a string containing the Subnet Mask
--If you call getIP().Gateway,you will get a string containing the Default Gateway
repeat with m=1 to bb.count --find the keys that start with {
if getat(bb,m) contains "{" then
secretCode= getat(bb,m)
-- put "sc="&secretcode
--make sure we have the right one that starts with {
cc=baRegKeyList( "SYSTEMControlSet001Services"&secretCode&"Parameters", "HKEY_LOCAL_MACHINE" )
if cc<>[] then --if it is not blank, then it must be the right one
realCode=secretCode
-- put "rc="&RealCode
end if
AdapterList=baRegKeyList( "SystemCurrentControlSetServicesClassNetTrans", "HKEY_LOCAL_MACHINE" )
repeat with x=1 to AdapterList.count --whichever adapter is PPP is 0.0.0.0 can be safely ignored
if baReadRegString( "SystemCurrentControlSetServicesClassNetTrans"&getAt(AdapterList,x), "IPAddress", "Error", "HKEY_LOCAL_MACHINE" )="0.0.0.0" then
--do nothing
else
NetAdapter=getAt(AdapterList,x)
end if
end repeat
IP=baReadRegString( "SystemCurrentControlSetServicesClassNetTrans"&NetAdapter, "IPAddress", "Error", "HKEY_LOCAL_MACHINE" )
Subnet=baReadRegString( "SystemCurrentControlSetServicesClassNetTrans"&NetAdapter, "IPMask", "Error", "HKEY_LOCAL_MACHINE" )
Gateway=baReadRegString( "SystemCurrentControlSetServicesClassNetTrans"&NetAdapter, "DefaultGateway", "Error", "HKEY_LOCAL_MACHINE" )
--if it isnt static, then we just wasted a bunch of time
if IP="Error" then -- it must be DHCP
--DHCP
enableDHCP=1
--Egads! It is in hex in the registry!
testIP = baReadRegBinary( "SystemCurrentControlSetServicesVxDDHCPDhcpInfo00", "DhcpIPAddress", "error", "HKEY_LOCAL_MACHINE" )
IP=getAt(testIP,1)&"."&getAt(testIP,2)&"."&getAt(testIP,3)&"."&getAt(testIP,4)
testGateway=baReadRegBinary( "SystemCurrentControlSetServicesVxDDHCPDhcpInfo00", "DhcpServer", "error", "HKEY_LOCAL_MACHINE" )
Gateway=getAt(testGateway,1)&"."&getAt(testGateway,2)&"."&getAt(testGateway,3)&"."&getAt(testGateway,4)
end if --/DHCP
end if --/OS