Paul Sobey [PS], on Monday, April 11, 2005 at 15:19 (+0100) wrote
about:

PS> There will be an API call, but why not put it in a logon script and
PS> avoid the necessity for this? If you're doing one-off work use
PS> Win32::Internet and work that way...

ok, thanks for all replies, after some hour with playing that I come
with the working solution:

use strict;
use warnings;
use Win32::TieRegistry( Delimiter=>"/", ArrayValues=>0 );
use Win32::API;

my %proxy_cfg = (
                   proxy_enable => 1,
                   proxy_host   => '10.10.10.10:80',
                );

my $regpath  = 
'HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Internet 
Settings/';
my $p_enable = $regpath . 'ProxyEnable';
my $p_server = $regpath . 'ProxyServer';

$Registry->{$p_enable} = [ pack("L",$proxy_cfg{proxy_enable}), "REG_DWORD" ];
$Registry->{$p_server} = $proxy_cfg{proxy_host} if $proxy_cfg{proxy_enable};

my $InternetSetOption = Win32::API->new("wininet", "InternetSetOption", [qw(N N 
N N)], 'N');
$InternetSetOption->Call(0, 39, 0, 0) || die "$!\n";
$InternetSetOption->Call(0, 37, 0, 0) || die "$!\n";

print $proxy_cfg{proxy_enable} ? "Proxy enabled to $proxy_cfg{proxy_host}\n" : 
"Proxy disabled\n";

hope this help to someone :)

-- 

 ...m8s, cu l8r, Brano.

["It is possible that Blondes also prefer gentlemen." - Mamie Van
Doren.]




_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to