The icon configured in the IDE is inserted in the RES file for your project with the name MAINICON. If you have the {$R *.RES}
line in your DPR file, then the project resource file gets linked to your application by the compiler.
The icon displayed by Explorer for your EXE file is whatever the first icon in your application is. The icons or sorted alphabetically. If Explorer is showing the wrong icon, then it's likely that you have linked additional icons to your application, and one of them has a name that comes before MAINICON. It might have a numerical name. (I have no idea how Windows Commander decides what icon to display.)
If some component or other unit used by your project has a resource file linked to it with the $R
directive, then it will be included in your project. You don't have to make any specific reference to the icon, or even mention the component's class name anywhere in the code. The mere presence of a $R
directive in a used unit is sufficient to have the entire resource file linked in. The compiler doesn't do any "smart linking" to remove unused resources because it has no way of detecting resource usage at compile time.
The common problem is that Explorer shows the wrong icon, but the program itself uses the right one. That's fixed by renaming the "wrong" icons to come after MAINICON. But you say your program is behaving the opposite way: Explorer (the desktop) shows the right icon and your program uses the wrong one, right?
One possibility is that the $R
directive in your DPR file is missing or wrong. Delphi might be linking an old version of the file. Try deleting the RES file of your project. The IDE will re-create it when it sees that it's missing. At that point, reconfigure the icon in the project options. You might also have to reset the project's version number.
You should also check the layout of the resources in your compiled program. I don't recall whether Delphi comes with a resource viewer suitable for the task. You can try PE Resource Explorer. Things to consider: What are the names of all the icons in your project? What icon appears with the name MAINICON? What RES file do the other icons come from, and what unit links it in?
Finally, a note on terminology: VCL is the Visual Component Library, the set of components that comes with Delphi. You can't have "a" VCL. The things you install to the Tool Palette (nee Component Palette) and put on forms and data modules are components, not VCLs.