One simple question about file extensions and loadin' files!!!(I'm using VC++)

Started by
8 comments, last by Xeon_Boy 22 years, 8 months ago
Hi there! :-D Suppose I''ve this program(Program I) that allows the user to save files of type *.abc when he has finished working with it. Let''s assume that he saved it onto the Desktop. Now, I''ve another program(Program 2) that allows the user to open files of type *.abc. How do I load the *.abc files into Program 2? I know I can open and load the *.abc files by double-clicking on their icons, but in this case, I want the user to choose the *.abc file and open(and load) it in Program 2. Thanks a lot in advance!!!!!!!! :-D "The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone''s watching in awe......."
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
Advertisement
The same way you loaded them into Program I....
I don''t think I understand the question

Do you mean you want to load the program and file from clicking on the *.abc icon?
In that case you have to register type .abc with windows and tell it the application that loads that type..
I think this is normally done on program installation somehow
If you want to register Program 2 with files of that extension, you would have to add some things to the registry. Add a key with the name of the extension you want to HKEY_CLASSES_ROOT. Set the default value to the name of your file type or something. Then you need another key with the same name of the value you set before in HKEY_CLASSES_ROOT. Set the default value for this key to the actual file type name you want to have for this format. Add a ''shell'' key within that key and then an ''open'' key within that. Then add a ''command'' key within that and set the default value to the path and filename of the program you want to use to open the file with. I hope that makes sense. All you have to do is use the Windows registry functions.

If that is not what you wanted to do, please explain yourself better.

Hi there, pals! Allow me to make myself clearer! :-D

U see, suppose that I create a bitmap(.bmp) file using the Microsoft Paint program and save it to disk.(assume it''s
Bitmap1.bmp)

Using other programs like Adobe PhotoShop or other graphics program, I''m able to open files of type .bmp, so that means I can open and load the Bitmap1.bmp file using PhotoShop etc.

How do I do this with my own programs? Suppose I''ve control over my own file formats! :-D

That is, I''ve 2 programs that I created. Program 1 creates .abc files, and I want Program 2 to be able to open and load the .abc files created with Program 1. Thanks!!!!!! :-D

Do help and good luck! :-D
Xeon.


"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone''s watching in awe......."
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
You can''t associate two programs with simply double-clicking on a file. But you can add more programs to the right-click menu for a file. For example, you could have Program 1 load up when you double-click on a .abc file, or you could load it in Program 2 by right-clicking on the file and selecting "Open in Program 2".

To add an item to the right-click menu, you need to do some registry editing. You can do this from within your program with some calls to the Win API (I can''t remember the names of the functions you need right now...), or you can do it manually through regedit. Add or edit the values shown below:

/** Tell windows to look for entries under ''abcfile'' when you try to use a file with a .abc extension **/

\HKEY_CLASSES_ROOT\.abc (Default)=''abcfile''

/** Give the name for the file type that''s shown in My Computer **/

\HKEY_CLASSES_ROOT\abcfile (Default)=''My Game File''

/** Give the action that is run when you double-click on a file **/

\HKEY_CLASSES_ROOT\abcfile\shell (Default)=''prog1''

/** Give the name for the action ''prog1'' to be shown in the right-click menu **/

\HKEY_CLASSES_ROOT\abcfile\shell\prog1 (Default)=''Open in Program 1''

/** Give the command line to be run when the file is double-clicked (%1 is replaced with the name of the file that has been double-clicked) **/

\HKEY_CLASSES_ROOT\abcfile\shell\prog1\command (Default)=''c:\prog1.exe "%1"''

/** Give the name of the action ''prog2'' to be shown in the right-click menu **/

\HKEY_CLASSES_ROOT\abcfile\shell\prog2 (Default)=''Open in Program 2''

/** Give the command line to be run when this action is selected from the right-click menu **/

\HKEY_CLASSES_ROOT\abcfile\shell\prog2\command (Default)=''c:\prog2.exe "%1"''

Hope this helps!

Mark Carrington

Hi there! What if I want Program 2 to open files of type .abc when the user chooses Open under the File menu of the program? Is there anyway I can achieve this? Thanks!!!!!

"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone''s watching in awe......."
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
actually it is easy. Open windows explorer, click on ANY file, doesn''t even have to be of the same type. Go up to the menu and pick view, then folder options, then file types. Add a new type and associate it with a program. Now whenever you double click on a file of that type it will attempt to run your program with the filename as a command line parameter.
I think what he is trying to ask is how to create an open dialog box so that the user can select the file that he wants to open from within the program by using File->Open.

What language are you working with?

I know only that which I know, but I do not know what I know.
Real easy. Look up the ''GetOpenFilename()'' function from somewhere. That will do it.
Heh heh heh! Nah! What Open files dialog? I know that! :-D

Actually, I''ve already solved the problem, but thanks! :-D

"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone''s watching in awe......."
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."

This topic is closed to new replies.

Advertisement