>  >So the creator string could be handed off to
>>"ICLaunchURL($ICInstance, 0, $url)"   to do the business without the
>>user needing to know anything of the technicalities going on behind
>>the scenes.
>
>Alan, I'm not sure how to apply the creator string to ICLaunchURL.
>Would $ICInstance contain the creator string?

Sorry, I should have been clearer. What I had in mind was to set the
default browser with ICConfig using "ICSetPrefs()":

        #!perl
        use Mac::InternetConfig;
        use Mac::InternetConfig qw(:DEFAULT $ICInstance);

        ICGeneralFindConfigFile($ICInstance);
        ICSetPref($ICInstance, "Helper*http", $default_browser);

in which $default_browser is any one of:

        $msie = 'MSIEInternet Explorer 4.5';
        $moss = 'MOSSNetscape Communicator';
        $icab = 'iCABiCAB';

The changes made are automatically reflected in the 'Internet'
Control Panel window by MacOS.

You can make a "$default_browser" string from:

        $len = length($name)
        $browser = pack("a4ca$len", $creator, $len, $name);

Bear in mind the names under which users have filed away their
applications may vary from machine to machine. In a particular
instance MSIE might be "Internet Explorer", "Internet Explorer X.x"
or maybe "Internet Explorer" or just about anything. So the
'default_browser' strings really need to be manufactured on site to
be safe.

Names and creators could be found (if not known) by using
'MacPerl::Choose() and MacPerl::GetFileInfo() as we discussed
previously.

You can find out which browser is actually set as the default from:

        ICGetPref($ICInstance, "Helper*http");

Incidentally in this and the above "Helper*http" is one of the
%InternetConfig's 'keys'. The blob  in the middle "*" is "option-*".
Beware that the function can (and often does) return some garbage
after the name. It is necessary to 'prune' the return down to the
number of characters specified by the index preceding the name.

It is also possible, and this might just be relevant in your application
launch the 'Internet' ControlPanel with:

        ICEditPreferences($ICInstance, "HelperList*http");

However the 'pod' warns that this might do something radically
different in future releases, so it might be better to avoid it.

So a program sequence might be as follows;

        a) find full path to browser ($path) from MacPerl::Choose()
        b) get creator string 'ABCD' from MacPerl::GetFileInfo($path)
         c) get browser name from the last part of full-path name
         d) make '$default_browser', for the browser (a) above
         e) get current browser as return from ICGetPref()
         f) if (e) is different from (f)  then:
         g) change preference with ICSetPref(INST, KEY, $default_browser)
         h) ICLaunchURL($ICInstance, 0, $url);


In all this the only intervention by the user would be to find browser in (a).

HTH,

Alan



Reply via email to