Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File extention icon

Status
Not open for further replies.

decripit

Programmer
Jan 16, 2002
3
US
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?
Decripit-
 
Application->Icon->LoadFromFile("C:\\myapp.ico");

Hope that helps you.

Bob
 
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. Cyprus
 
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.

Sorry,
Bob
 
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(&quot;*.xxx&quot;, true);


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

thisReg->WriteString(&quot;&quot;, &quot;FormLoader&quot;);


/* Close Key */

thisReg->CloseKey();


-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(&quot;FormLoader&quot;, true);
thisReg->OpenKey(&quot;DefaultIcon&quot;, true);


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

thisReg->WriteString(&quot;&quot;, ParamStr(0)+&quot;,0&quot;);


/* Clean up */
delete thisReg;

return;
}
//----------------------------------------------------------


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. Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top