Another way to obtain the local IP address in Pb
Generally, run ("regsvr32/s mswinsck. ocx") is used for registration to obtain information about the local machine, including IP addresses.
This section describes how to obtain the IP address of the Local Machine by accessing the registry. Because other people's controls are not used, the program is "independent.
Getenvironment (ge_env)
Choose case ge_env.ostype
// AIX !, HPUX !, Macintosh !, Osf1 !, Sol2 !, Windows !, Wondowsnt!
Case windows!
Gs_ostype = "Windows"
Case WindowsNT!
Gs_ostype = "WindowsNT"
Case else
Gs_ostype = "other"
End choose
// Use the registry to retrieve the local IP Address
String ls_value = ""
String subkeys []
Choose case gs_ostype
Case 'windows'
String skey = 'HKEY _ LOCAL_MACHINE/system/CurrentControlSet/services/class/nettrans'
String sname = 'ipaddress'
Int I
String skey1
Ls_value =''
Registrykeys (skey, subkeys)
If upperbound (subkeys)> 0 then
For I = 1 to upperbound (subkeys)
Skey1 = skey + '/' + subkeys [I]
If registryget (skey1, sname, ls_value) = 1 then
If ls_value <> '0. 0.0.0 'then
Exit
End if
End if
Next
End if
Case "WindowsNT"
String ls_keynt1 = 'HKEY _ LOCAL_MACHINE/software/Microsoft/Windows NT/CurrentVersion/networkcards'
If registrykeys (ls_keynt1, subkeys) = 1 then
If upperbound (subkeys)> 0 then
Ls_keynt1 = ls_keynt1 + '/' + subkeys [1]
End if
End if
// Bill TCPIP may need to query all the sub-items in the ls_keynt1 field, which mainly means that the last item 6 is different on different machines.
String ls_keynt2 = 'HKEY _ LOCAL_MACHINE/system/CurrentControlSet/services /'
String ls_keynt3 = '/parameters/tcpip'
String ls_name_nt1 = 'servicename'
String ls_name_nt2 = 'ipaddress'
String ls_name_nt3 =''
String ls_value2 []
If registryget (ls_keynt1, ls_name_nt1, ls_value) = 1 then
Ls_name_nt3 = ls_keynt2 + ls_value + ls_keynt3
If registryget (ls_name_nt3, ls_name_nt2, regmultistring !, Ls_value2) = 1 then
Ls_value = ls_value2 [1]
Else
// Multiple IP addresses may exist. ls_value = ls_value2 [1] + ";" + ls_value2 [2]
Ls_value = ls_value2 [1]
End if
Else
Ls_value =''
End if
Case else
Ls_value =''
Return
End choose
Gs_ipaddress = ls_value