DWT Windows Load Icon from File/Program/Resource
Jacob Carlborg via Digitalmars-d-dwt
digitalmars-d-dwt at puremagic.com
Sat Feb 25 11:58:17 PST 2017
On 2017-02-25 09:45, JamesD wrote:
> I'm a hobbyist and new to the D language. With a lot of help from
> various online resources, I finally figured out how to load an icon from:
> 1. A file "icon.ico" (this was easy)
> 2. A Program extension from the Windows registry, e.g. "*.inf" (harder)
> 3. A linked resource from the exe itsself (very hard)
> I learned how to add an icon to the exe with a compiled Resource file.
> Now I can load this embedded icon as the shell icon.
> And I don't have to distribute a separate ico file with my exe.
> I added a couple of simple bat files to compile with either dmd or dub.
> This work can be found at:
> I hope this helps another newbie like me.
> Constructive feedback is welcome.
In D it's very simple to embed resources in the executable at compile
time using string imports:
immutable data = cast(immutable(uyte) import("foo.ico");
Compile by adding the -J flag to point to the directory where the icon
files are located:
dmd main.d -J./resources
Then I'm pretty sure there's a an API that takes a byte array and
returns an image of some sort.
More information about the Digitalmars-d-dwt