Thread overview
How to do Windows Console¡¡Application¡¡load Icon
Apr 23, 2007
jinheking
Apr 23, 2007
jcc7
Apr 23, 2007
Dan
April 23, 2007
 Hi all,

Is there anybody who knows how to load an Icon in the Windows Console
applications.
I work with the dmd, and it concerns 32 bit Windows Console
applications.


April 23, 2007
== Quote from jinheking (caoqi@bgi.net.cn)'s article
>  Hi all,
> Is there anybody who knows how to load an Icon in the Windows Console
> applications.
> I work with the dmd, and it concerns 32 bit Windows Console
> applications.

Do you want to have a custom icon to show up with the executable in Windows Explorer?

I'm not sure what you want to do, but you might need to use a resource script and resource compiler:

rcc resource.rc -v -32
dmd pgm.d resource.res


Below is a sample resource script (resource.rc) and the C header file that it
depends upon.

I hope this might help.

jcc7


=== resource.rc ===

#include "resource.h"

1000 ICON MOVEABLE PURE LOADONCALL DISCARDABLE pgmIcon
1 VERSIONINFO
FILEVERSION    pgmMajVer, pgmMinVer, pgmBuild, 0
PRODUCTVERSION pgmMajVer, pgmMajVer, pgmBuild, 0
FILEOS 0x4
FILETYPE 0x1
BEGIN
BLOCK "StringFileInfo"
BEGIN
	BLOCK "040904B0"
	BEGIN
        VALUE "LegalCopyright", pgmCopyright
        VALUE "FileDescription",  pgmFileDescription
		VALUE "Author", "J C Calvarese"
		VALUE "CompanyName", pgmCompanyName
		VALUE "ProductName", pgmTitle
		VALUE "FileVersion", pgmVersion
		VALUE "ProductVersion", pgmVersion
		VALUE "InternalName", pgmInternalName
		VALUE "OriginalFilename", pgmOriginalFilename
	END
END

BLOCK "VarFileInfo"
BEGIN
	VALUE "Translation", 0x0409,  0x04B0 //0x0409 0x04B0
END
END


=== resource.h ===

#define pgmTitle            "pgm"
#define pgmInternalName     "pgm"
#define pgmOriginalFilename "pgm.exe"

#define pgmFileDescription  "Does Something"

#define pgmVersion "0.0.1"
#define pgmMajVer  0
#define pgmMinVer  0
#define pgmBuild   1

#define pgmCopyright "(c) 2002 Some One"
#define pgmCompanyName "My Software Company"

#define pgmIcon "pgm.ico"

#define ID_ICON 1000

April 23, 2007
I have a custom icon for Walnut, but I used a weird RC - use one that comes with dmd for brownie points:

Check icon.rc and icon.ico, as well as the makefile:

http://dsource.org/projects/walnut/browser/1.9/source/