Very much appreciated but....does anyone know how to do this via a Win32
call? I'd rather not read the registry.
Thanks,
Ron
>From: Timothy Johnson <[EMAIL PROTECTED]>
>To: "'Guess Who'" <[EMAIL PROTECTED]>,
>[EMAIL PROTECTED]
>Subject: RE: Gateway Address?
>Date: Fri, 19 Apr 2002 16:08:08 -0700
>
>
>Here's a snippet from a program I wrote a while back. It should give you
>an
>idea of where to get the info if you have access to the registry.
>
>sub getIPInfo{
> #### WINDOWS 2000 ####
>
>if($Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows
>NT/CurrentVersion/CurrentVersion"} eq "5.0"){
> $adapterRoot =
>$Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows
>NT/CurrentVersion/NetworkCards/"};
> $ipRoot =
>$Registry->{"//$client/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/
>Tcpip/Parameters/Interfaces/"};
> @adapterKeys = keys %{$adapterRoot};
> foreach $key(@adapterKeys){
> $name = $adapterRoot->{$key}->{'ServiceName'};
> $service = $adapterRoot->{$key}->{'ServiceName'};
> $nics->{$name}{'Description'} =
>$adapterRoot->{$key}->{'Description'};
> $nics->{$name}{'ServiceName'} =
>$adapterRoot->{$key}->{'ServiceName'};
> $nics->{$name}{'Domain'} =
>$ipRoot->{"$servicename/Domain"};
> $nics->{$name}{'DNS'} =
>$ipRoot->{"$servicename/NameServer"};
> if($ipRoot->{"$service/EnableDHCP"} eq
>"0x00000000"){
> $nics->{$name}{'IPAddress'} =
>$ipRoot->{"$service/IPAddress"};
> $nics->{$name}{'Subnet'} =
>$ipRoot->{"$service/SubnetMask"};
> $nics->{$name}{'DHCPEnabled'} = "No";
> $nics->{$name}{'Gateway'} =
>$ipRoot->{"$service/DefaultGateway"};
> }elsif($ipRoot->{"$service/EnableDHCP"} eq
>"0x00000001"){
> $nics->{$name}{'DHCPServer'} =
>$ipRoot->{"$service/DhcpServer"};
> $nics->{$name}{'Subnet'} =
>$ipRoot->{"$service/DhcpSubnetMask"};
> $nics->{$name}{'IPAddress'} =
>$ipRoot->{"$service/DhcpIPAddress"};
> $nics->{$name}{'DHCPEnabled'} = "Yes";
> $nics->{$name}{'Gateway'} =
>$ipRoot->{"$service/DhcpDefaultGateway"};
> }
> }
> #### WINDOWS NT ####
>
>}elsif($Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows
>NT/CurrentVersion/CurrentVersion"} eq "4.0"){
> $adapterRoot =
>$Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows
>NT/CurrentVersion/NetworkCards/"};
> foreach $key(keys %{$adapterRoot}){
> $name = $adapterRoot->{$key}->{'ServiceName'};
> $service = $adapterRoot->{$key}->{'ServiceName'};
> $nics->{$name}{'Description'} =
>$adapterRoot->{$key}->{'Description'};
> $nics->{$name}{'ServiceName'} =
>$adapterRoot->{$key}->{'ServiceName'};
> $ipRoot =
>$Registry->{"//$client/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/
>$service/Parameters/Tcpip/"};
> if($ipRoot->{"EnableDHCP"} eq "0x00000000"){
> $nics->{$name}{'IPAddress'} =
>$ipRoot->{"IPAddress"};
> $nics->{$name}{'Subnet'} =
>$ipRoot->{"SubnetMask"};
> $nics->{$name}{'DHCPEnabled'} = "No";
> $nics->{$name}{'Gateway'} =
>$ipRoot->{"DefaultGateway"};
> }elsif($ipRoot->{"EnableDHCP"} eq "0x00000001"){
> $nics->{$name}{'DHCPServer'} =
>$ipRoot->{"DhcpServer"};
> $nics->{$name}{'Subnet'} =
>$ipRoot->{"DhcpSubnetMask"};
> $nics->{$name}{'IPAddress'} =
>$ipRoot->{"DhcpIPAddress"};
> $nics->{$name}{'DHCPEnabled'} = "Yes";
> $nics->{$name}{'Gateway'} =
>$ipRoot->{"DhcpDefaultGateway"};
> }else{
> print " DHCP status unknown on
>$name!\n";
> }
> }
> }
>}
>
>
>P.S. I know, it's ugly, but it works, and I just haven't had the heart to
>sit down and fix it.
>
>-----Original Message-----
>From: Guess Who [mailto:[EMAIL PROTECTED]]
>Sent: Friday, April 19, 2002 4:09 PM
>To: [EMAIL PROTECTED]
>Subject: Gateway Address?
>
>
>Hello!
>
>Does anyone have code to extract the gateway from a Win32 host? I use the
>following to get the IP info:
>
> $machine = Win32::NodeName;
> $addr = (gethostbyname($machine))[4];
> $ip = join(".",unpack("C4", $addr));
>
>Thanks mucho!
>
>Pablo Suave
>
>
>_________________________________________________________________
>Send and receive Hotmail on your mobile device: http://mobile.msn.com
>
>_______________________________________________
>Perl-Win32-Admin mailing list
>[EMAIL PROTECTED]
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs