Well, destroy it when your window is destroyed (WM_DESTROY handler). There can be no leak of memory associated with the icon this way UNLESS your application is terminated ungracefully, and even then most probably Windows will perform the necessary cleanup.
Not to say that a leak of several kilobytes isn't much of a problem compared to what gigabytes of software out there manage to leak...
When you are finished using a bitmap, cursor, or icon you loaded without specifying the LR_SHARED flag, you can release its associated memory by calling one of the functions in the following table.
Resource Release function
The system automatically deletes these resources when the process that created them terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.
Thanks everyone, I found the problem...I mispelled the directory during one variable initialization. Thanks again for your help.
Everytime I run the code below (Visual Studio .NET 2003), it tells me that a debug assertion has failed. Then when I go into the code to debug it...it goes to "filecore.cpp" and points out the error in the following filecore.cpp function....