Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: InternetConfig.h
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: InternetConfig.h



on 5/24/01 7:24 PM, Andrew Krakowski at email@hidden wrote:

> Has anyone had some succes in writing a function to call the default web
> browser to launch a specified web site?

Sure, works like a charm....


OSStatus OpenURL(const char *url)
{
OSStatus error = -1;

if (HasInternetConfig())
{
ICInstance instance;
bool gotInstance = false;
FourCharCode signature;

GetCurrentSignature(&signature);

error = ICStart(&instance, signature);

gotInstance = (error == noErr);

//if (error == noErr)
// error = ICFindConfigFile(instance, 0, NULL);

if (error == noErr)
{
SInt32 selStart = 0;
SInt32 selEnd = strlen(url);
error = ICLaunchURL(instance, NULL, (Ptr) url, strlen(url),
&selStart, &selEnd);
}

if (gotInstance)
ICStop(instance);
}

return error;
}


bool HasInternetConfig(void)
{
//!- probably should do some real Gestalt check?
return ((long) ICStart != kUnresolvedCFragSymbolAddress);
}


OSStatus GetCurrentSignature(FourCharCode *signature)
{
ProcessInfoRec info;
OSErr error = noErr;

info.processInfoLength = sizeof(ProcessInfoRec);
info.processName = nil;
info.processAppSpec = nil;

error = GetProcessInformation(&fgPSN, &info);
if (error == noErr)
*signature = info.processSignature;

return error;
}


References: 
 >InternetConfig.h (From: Andrew Krakowski <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.