How to do Windows Console¡¡Application¡¡load Icon

jcc7 technocrat7 at gmail.com
Mon Apr 23 08:34:26 PDT 2007


== Quote from jinheking (caoqi at 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




More information about the Digitalmars-d mailing list