> -----Original Message----- > From: Morbus Iff [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 28, 2001 17:38 > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > perl-win32-gui-users@lists.sourceforge.net > Subject: [perl-win32-gui-users] RE: Opera and "Open Default Browser", > Hard Crash? > > > This is eventually the code I went with, which has > been tested with IE 5/6, Mozilla/Netscape, and Opera. > > ############################################################## > ################ > open_url() - open a url in the system's default > browser > ############################################################## > ################ > USAGE: > # &open_url( "http://127.0.0.1:8888/" ); > # > # OS SPECIFIC > NOTES: > # This > routine loads the Win32::Shell module to execute the > "open" # command which will open the browser and > load the URL. > However, if the # user has defined a local path to a > browser, we try > to open that instead. # > # > RETURNS: > # 1; we instruct the user to open their browser if we > can't. > ############################################################## > ############### > sub open_url { > > my ($url) = @_; > > # we spit out our suggestion just to catch all instances. > ¬e("If your browser doesn't load, go to <$url>", 1); > > # find out what browser we're using. > use Win32::TieRegistry; > my $browser = > $Registry->{"Classes\\http\\shell\\open\\command"}->{'\\'}; > ¬e("Your registry states that $browser is your default > program."); > > # if a browser_path hasn't been set, try > # to open the default browser using the native API. > # note, that if the $browser is Opera, we skip > # this part, because Opera uses a Multiple > # Document Interface that crashes us every time. > # instead, we use the "path to browser" code below. > if ( $SETTINGS->{user}->{browser_path} eq "default" > or $browser =~ /opera/i ) { > use Win32::API; > my $ShellExecute = new Win32::API("shell32", "ShellExecuteA", > ['N','P', 'P', 'P', 'P', 'I'], 'N'); > $ShellExecute->Call(0, "open", $url, 0, 0, 1); > } > > # if a browser_path has been defined, try passing > # the $url to the .exe and hope it understands. > else { > > # if we see "program files" or "internet explorer", we take > # a chance and try to change them to their common eight char > # equivalents. this won't work for all users but covers > # a good large portion of them. yup yup. fun. chicks on speed. > $SETTINGS->{user}->{browser_path} =~ s/program > files/progra~1/ig; > $SETTINGS->{user}->{browser_path} =~ s/internet > explorer/intern~1/ig; > > ¬e("Trying to load $SETTINGS->{user}->{browser_path}."); > unless ( fork ) { > system("$SETTINGS->{user}->{browser_path} $url"); } > }
Note sure if this will work, but you may not have to change your $SETTINGS->{user}->{browser_path} with the regex above. You should be able to system(qq|"$SETTINGS->{user}->{browser_path} ", $url|); Basically, you want something on the command line like c:\some path with spaces\exe.exe argument1 to be "c:\some path with spaces\exe.exe" argument1 This way you dont have to munge the data. Also, if they installed to a path with spaces instead of defaults, if you can get this working, it takes care of all instances.... Just a thought. > > return 1; > } > > 1; > > -- > Morbus Iff ( .sig on other machine. ) > http://www.disobey.com/ && http://www.gamegrene.com/ > "where's there's a will, there's a morbus ready to collect!" > > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >