|
|
#1 |
|
launch html file from web browser in carbon
the title says it all. i'm trying to launch html-based help files in the same directory as my app.
i've tried both LSOpenCFURLRef, as well as LSOpenFSRef, but can only get them to work with www urls but NOT local files like "file:///Developer/help.html". all i get is an OSStatus of -43, which doesn't seem to be in the range of the documented Launch Services result codes. anyone ever get this to work? |
|
|
|
0
|
|
|
#2 | |
|
Quote:
http://developer.apple.com/documenta...elp/index.html
__________________
Learn AppleScript, 3rd edition, Sanderson & Rosenthal: http://apress.com/book/view/9781430223610 Control AppleScriptable applications from Python, Ruby and ObjC: http://appscript.sourceforge.net |
||
|
|
0
|
|
|
#3 |
|
hhas, thanks for your response and that link.
i'd love to adopt that system, and probably will somehow in the future, but for the sake of time, and because this is the same system used in my win32 app, i need to just pop open the html files using the aforementioned technique. any idea how? |
|
|
|
0
|
|
|
#4 |
|
-43 = file not found. Probably your URL is wrong. Post the relevant code if you want specifics.
__________________
Learn AppleScript, 3rd edition, Sanderson & Rosenthal: http://apress.com/book/view/9781430223610 Control AppleScriptable applications from Python, Ruby and ObjC: http://appscript.sourceforge.net |
|
|
|
0
|
|
|
#5 |
|
You need to get a CFURL reference to the html file to open, most likely in the app bundle. So first you get a reference to the main app's bundle, which you can then use to get the embedded HTML file.
so do: Code:
CFBundle bundle = CFGetMainBundle(); CFURL = CFBundleCopyResourceURL( bundle, "Help", "html", "HelpContentFolder" ); App Bundle > Contents > Resources > HelpContentFolder Then its just a matter of: Pass that CFURL to LSOpenCFURLRef.
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me Last edited by Sayer; Nov 30, 2008 at 12:20 PM. |
|
|
|
0
|
|
|
#6 | |
|
Quote:
Code:
//attempt 1
CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("file:///Developer/Projects/help.html"), kCFURLPOSIXPathStyle, false);
OSStatus result = LSOpenCFURLRef(url,NULL);
//attempt 2
FSRef ref = {0};
Boolean isDir = false;
OSStatus result = FSPathMakeRef((UInt8 *)"file:///Developer/Projects/help.html", &ref, &isDir);
LSOpenFSRef(&ref,NULL);
|
||
|
|
0
|
|
|
#7 |
|
In your examples you are passing the absolute string of a file URL instead of the absolute path.
|
|
|
|
0
|
|
|
#8 | |
|
Quote:
note to self: read EVERY line of the api documentation! |
||
|
|
0
|
|
|
#9 |
|
for posterity:
Code:
CFURLRef fURL = CFURLCreateWithFileSystemPath(NULL, CFSTR("Help/help.html"), kCFURLPOSIXPathStyle, false); //Help resides in folder relative to app
LSOpenCFURLRef(fURL, NULL);
|
|
|
|
0
|
|
|
#10 |
|
Hm I could be wrong, but I don't think that code will work all the time. Did you test it by running your app outside of Xcode (e.g. via the Finder)? Xcode sets the current working directory usually to the Debug/Release directory, but the Finder doesn't.
|
|
|
|
0
|
|
|
#11 |
|
awww crap, you're right - it doesn't work when launched from finder! how do i get around that then?
|
|
|
|
0
|
|
|
#12 |
|
Well if the Help folder is in the same folder as your .app you can use CFBundleCopyBundleURL() and manipulate it from there (as a URL, or convert to C-string, etc). But since we're dealing with a Mac app, the Help folder *should* be located inside the .app's Resources folder, and if that's the case you can use Sayer's recommendation of CFBundleCopyResourceURL.
|
|
|
|
0
|
|
|
#13 |
|
kainjow, does this theory apply to dylib files as well? i just noticed dlopen is failing if i pass in a relative path and run my app from finder - but it works when i run it in xcode..
if so, that would seem contradictory to the point of a 'dynamically' linked lib, methinks |
|
|
|
0
|
|
|
#14 |
|
i was able to fix the dlopen issue using CFBundleCopyBundleURL(CFBundleGetMainBundle()), however my question still stands.
is the mac standard to package dylib's with the .app's bundle? if this is the case, i would greatly appreciate a link to documentation on this, so i can follow these best practices! |
|
|
|
0
|
|
|
#15 |
|
Yes, you can link to a dylib inside your application bundle. You have to copy it to a certain folder (probably Contents/Frameworks), and then write a run script to use install_name_tool to set the path to relative based on the directory. I used to do this with a project but I don't have the script anymore.
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Question regarding WebView component in Mac Web Browser | gwelmarten | Mac Programming | 4 | Feb 21, 2011 05:05 PM |
| Question regarding WebView component in Mac Web Browser | gwelmarten | Mac Programming | 0 | Feb 15, 2011 11:59 AM |
| weird problem on web browser for Macbook Pro | jianadmu | Mac Applications and Mac App Store | 0 | Feb 10, 2011 05:07 AM |
| Looking for a piece of web software for creating HTML links from Webloc Browser Pages | macsrules | Web Design and Development | 2 | Mar 17, 2009 10:04 PM |
| Launching a mp3 from a browser into iTunes | mikemodena | Mac Applications and Mac App Store | 3 | Aug 10, 2005 07:43 PM |
All times are GMT -5. The time now is 08:44 PM.







Linear Mode

