While working on a utility project today, I stumbled upon wanting to embed an executable inside another executable. Sounds fun doesn’t it? And what is even more fun is to be able to launch the embedded exe
!
Basically, here’s how it works. You embed Foo.exe
inside Bar.exe
. And by embed I mean, add Foo.exe
as a resource in Bar.exe
and then, from Bar.exe
’s code, you can launch Foo.exe
using CreateProcess()
.
So before answering the "Why?" lets answer the "How?"
Rename Foo.exe
to Foo.txt
. We do this just to be safe and to prevent the resource compiler (manager) from throwing unwanted errors. Now add Foo.txt
as a normal resource in Bar.exe
. Create an entry in Bar.exe
’s resource script as below: