gorac has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
The following code results in a Perl Command Line Interpreter error message at this line
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
. Error Message: Perl Command Line Interpreter has encountered a problem and needs to close. We are sorry for the inconvenience.
use Win32::Registry; use Win32::API::Prototype; my $infile = "c:\\proxies.txt"; open (PFILE, $infile) || die "cannot Open $infile: $!"; my @proxies = (<PFILE>); my $proxy; foreach $proxy (@proxies){ my $Register = "Software\\Microsoft\\Windows\\CurrentVersion\\In +ternet Settings"; my $hkey; $HKEY_CURRENT_USER->Open($Register,$hkey)|| die $!; undef $garbage; $hkey->SetValueEx("ProxyServer",$garbage,REG_SZ,$proxy); $hkey->Close(); print "Current: $proxy\n"; ApiLink( "wininet", "BOOL InternetSetOption( HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength )" ) || die; InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0); sleep(30); }

Replies are listed 'Best First'.
Re: Win32::API::Prototype error
by ikegami (Patriarch) on Sep 22, 2004 at 17:55 UTC
    The MSDN library indicates the first argument cannot be NULL for INTERNET_OPTION_REFRESH (if ever). It also says InternetOpen returns a handle you can use.