Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

File extention icon

File extention icon

File extention icon

I have a program that has several of it's own file extentions. Each is different, but they are all set to have the same icon as the executable, and this gets very confusing. I have several icons for the extentions, but I don't know how to associate them with the given extention. For some reason the code I have doesn't work, though it says it's supposed to. Does anyone know how to change the icon of a file extention to a designated icon through code?


RE: File extention icon


Hope that helps you.


RE: File extention icon

actually, no. I'm sorry, I did not make my problem entirely clear.
I created a file extention (*.xxx) for my program. I stuck it in the registry and told it to take the icon from my executable and use that for the icon for any file with my .xxx extention. My problem is that I have multiple extentions, (*.xxx, *.xyz, *.abc) and all have the same icon... and so does my executable. I want *.xxx to have icon2, *.xyz to have icon3 and *.abc to have icon4. My program has icon1.
It gets confusing clicking on a file extention and finding out its not the program, I have to go through and try several files before I hit the executable. Now I want to make the extentions have different icons (through code) when i register them so nothings confusing.
hopefully ive made this a little more clear.


RE: File extention icon

It is still not clear to me...are all the programs exe files? They must not be or it would not be hard to give each their own icon. I do not know how to use the register to tell a program what icon to use.


RE: File extention icon

No, they are not all Executables. One program launches the code below to create a file extention, (like *.txt, except this extention is *.xxx) When the program creates the extention, then any file with *.xxx will be associated with my program. The problem is that the icon for the new file extention is the same as the executable.
the files with extentions of *.xxx are simple flat files, used as scripts within the executable itself. I want them to have their own icon.
When a user sees the flat file, he thinks that it is the executable, because the icon for *.xxx and *.exe are the same. He opens the flat file and gets frusterated because it's not the executable. I'm not trying to change the icon for the executable, just the files with the *.xxx extention. I know I need to add a key in the registry to make the icon different, but for some reason what I'm doing is just not right.

Here is my code. I've removed some unimportant parts, but the part Im having a problem with is highlighted. Maybe this will make my motives more clear.

#include <registry.hpp>

void ExtMak()

/* Register the file extension */
/* Create a new instance of the Registry class */

TRegistry* thisReg = new TRegistry();

/* Set the root key to HKEY_CLASSES_ROOT, which is where file associations are stored */

thisReg->RootKey = HKEY_CLASSES_ROOT;

/* Create the key for the file extension you want to register */
/* this is where the file extention is defined */

thisReg->OpenKey("*.xxx", true);

/* Set the default value to the program you want to associate the extension with */

thisReg->WriteString("", "FormLoader");

/* Close Key */


-unimportant code removed here-

/* Set default icon */
/* This is the icon that will be given each object/file that has user defined extension */

        thisReg->OpenKey("FormLoader", true);
        thisReg->OpenKey("DefaultIcon", true);

/* sets icon of the extention to the same icon as the executable */

thisReg->WriteString("", ParamStr(0)+",0");

/* Clean up */
delete thisReg;


the way I see it, if I put the location of the desired icon in place of DefaultIcon (located within the highlighted code,) then it the icon should be stuck to the extention, but it doesn't seem to work.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close