Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ManaStone

How do I make my program open a file by default?

This topic is 5459 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 just created a program that can view ppm files and I''d like to know how to make my program open it automatically when a ppm file is clicked on. How can I do this?

Share this post


Link to post
Share on other sites
Advertisement
Do you want to know how to make the program modify the registry so it can do it? Or do you simply want to manually configure windows to do that?

Share this post


Link to post
Share on other sites
quote:

No, I want to know how to call my opener function with the string of the filename when I click on the ppm file.


Yeah, you have to modify a key in the registry that associates extensions with programs. I''m not sure where it''s located, but I''m sure you can find it by just looking through the registry (or search for ppm). To edit the key search msdn for registry. Btw, to open the registry editor go to start->run and type in "regedit".

Share this post


Link to post
Share on other sites
quote:
Original post by ManaStone
No, I want to know how to call my opener function with the string of the filename when I click on the ppm file.


You still aren''t quite clear. That ability is done via a modified key in the registry. Windows does that, not your program. You can either manually configure windows so that it will do that, or you can modify your program so that it will edit registry and configure Windows to do that. To do it manually, hold shift down and right click on a ppm file. Then select Open With->Choose Program and select your program. You then have to modify your program to read the command line arguments and load the picture as needed.

Share this post


Link to post
Share on other sites
Quite easy.

Open up any folder.
Go to Tools -> Folder Options.

Click the File Types tab.
Click on the New button.
Add your extension intop the box and click OK.
Then the file types list box with highlight your new file extension.
Click the change button and make the OpenWith point to the file path of your program.

Presto.

Share this post


Link to post
Share on other sites
I don''t know if I''m not understanding you or you''re not understsanding me. I''ve already got it so I can open up my program when I click on a ppm file, but it I can''t get the ppm file to load autimatically when it opens.

Share this post


Link to post
Share on other sites
oh, so you want to know how to get the command-line arguments for a program?

um, for a console app, main should have two parameters (int argc & char** argv), argc is the number of parameters (including the program name itself) and argv is an array or char arrays containing the values.

for a windows app, there is an lpCommandLine parameter which has the command line in it.

Share this post


Link to post
Share on other sites
quote:
Original post by ManaStone
I don''t know if I''m not understanding you or you''re not understsanding me. I''ve already got it so I can open up my program when I click on a ppm file, but it I can''t get the ppm file to load autimatically when it opens.

The filename should be passed in automatically and end up in your command line args. Second argument if i remember right..

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!