[Bug] Console application and default icon

Started by fixer, June 12, 2017, 05:16:39 PM

Previous topic - Next topic


If you tried to start a console application, you probably noticed that sometimes it has default icon in top left corner of console window and in taskbar even if the file has an icon. Ever wondered when and why? After some debugging conhost.exe was found guilty of this. This is a separate process, it's responsible for creation and management of console window. When console window is created, it gets full path to the application and current directory. And then for some unknown reason it extracts file name from full path and searches for it in current directory. As expected, it fails if current directory is different from the directory the executable file resides in. And if failed, it shows default icon.

So if you code a console application and use AllocConsole, make sure current directory is the same as the directory the executable file resides in. If you start some other console application, ensure the same.

This issue was found several months ago, it wasn't fixed then. I haven't checked it since.