Sign in to follow this  

[C++] Open DMG or mpkg on Mac

This topic is 3572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a program that displays images for different devices to install drivers for. What I want it to do is you click on your OS (10.4 or 10.5) and have it automatically open the DMG or mpkg (DMG is preferred) like it does as if I opened it from a folder or the desktop. Does anyone know how to do this? (I've looked at execl and it doesn't do anything currently, I assume I need to pass the dmg is an argument to some program so it automatically mounts, and opens and Mac does its fun stuff). Thanks.

Share this post


Link to post
Share on other sites
Okay, I figured out how to open a file, using /usr/bin/open, but it seems that everytime I try to use execl it simply doesn't work. It always returns "Operation not Supported" - 45 error. I've tried using simply ls, and such, and it still doesn't work.

execl("ls", 0);

I am not sure what is going on.

Share this post


Link to post
Share on other sites
Well, I figured out that Macs are not POSIX compliant, so execl and such do not work. Instead, I have to use the ApplicationServices framework, and use these functions found here : http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/Reference/reference.html

The one of main concern is LSOpenApplication. Still haven't been successful, but getting closer.

Share this post


Link to post
Share on other sites
Why not use "system"?
Like, system("open blahblah.dmg");
You don't even have to use "open", use "hdiutil" instead.

The reason you're getting an error is probably because the first argument is NULL, I think it should be the path and name of the file you're executing. Mac OS is fully POSIX-compatible.
Just enter the binary's name as first argument, then the real argument list starts after that.
If you want to list /Users/, this code should work:
execl("/bin/ls", "/bin/ls", "/Users", NULL);

And a tip: if the user only wants to install 10.4-stuff on 10.4 installations and 10.5-stuff on 10.5 installations, don't let the user choose. The app should select the correct base.

[Edited by - patrrr on March 7, 2008 2:56:05 PM]

Share this post


Link to post
Share on other sites

This topic is 3572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this