{"id":394,"date":"2016-05-28T22:41:01","date_gmt":"2016-05-29T04:41:01","guid":{"rendered":"index.php?p=394"},"modified":"2021-07-30T08:25:05","modified_gmt":"2021-07-30T14:25:05","slug":"solution-the-icon-of-an-exe-compiled-with-microsoft-visual-c-wont-show-up-in-windows-95","status":"publish","type":"post","link":"https:\/\/www.ysutopia.net\/blog\/?p=394","title":{"rendered":"Solution: The icon of an EXE compiled with Microsoft Visual C++ won&#8217;t show up in Windows 95."},"content":{"rendered":"<p>The early versions of Windows 95, that is, the very first release, and subsequent &#8216;A&#8217; and &#8216;B&#8217; releases (but NOT the &#8216;C&#8217; with IE 4.0 bundled!) have a peculiar behavior when it comes to an executable. The operating system refuses to detect an executable&#8217;s icon in explorer if you compiled it for \/console mode, that is, as a command-line app. In order to work around this, you must compile the executable in \/windows GUI mode, define a WinMain() [and not main()] and use AllocConsole() to immediately arrange a console window for the process.<\/p>\n<p>Such is the workaround in case someone else was having trouble with this issue and thought it was a bug. It appears to be intentional behavior that was changed after Windows 95C. The rule is basically this: If the EXE is compiled for \/windows GUI mode, then it will be scanned for icon resources and the first one will be used, as is normal&#8230; However, if it was compiled for \/console mode, then it won&#8217;t bother, in fact, it will state the EXE has no icon resources if you try, for example, to create a shortcut and ask it to check for icons in said EXE. It simply defaults to fetching a generic command-line console icon from the system for every EXE that&#8217;s compiled as a console\/command-line EXE regardless of what icons are or are not contained within&#8230;<\/p>\n<p>I spent a few days trying to figure this out actually, I blamed the compiler, the linker, Microsoft VC++ 2005, other settings in the PE header of the executable&#8230; I tried PE editors to see if I could get different results&#8230; It really frustrated me not being able to figure it out&#8230; Finally, I compiled a blank project with VC++ 2005 which I had set to \/windows GUI mode and after all my other tests failed, the EXE actually had its icon show up in Windows 95&#8230; Yeah, took quite a while&#8230;<\/p>\n<p>Anyway, since I googled several times to see if somebody else encountered this problem with no luck, I made this entry in case this info might be useful to somebody else. I will in fact use the work around I mentioned. My EXE will be compiled with subsystem set to \/windows GUI mode, a WinMainCRTStartup() function will be defined (the pre-WinMain function), with a subsequent call to AllocConsole() instead of creating a window. This shouldn&#8217;t be much of a big deal to all Windows operating systems thereafter, but I&#8217;ll have to test how this change behaves elsewhere.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The early versions of Windows 95, that is, the very first release, and subsequent &#8216;A&#8217; and &#8216;B&#8217; releases (but NOT the &#8216;C&#8217; with IE 4.0 bundled!) have a peculiar behavior when it comes to an executable. The operating system refuses to detect an executable&#8217;s icon in explorer if you compiled it for \/console mode, that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-394","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=394"}],"version-history":[{"count":0,"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/394\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ysutopia.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}