Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding manifest to exe file

Tags:

c++

manifest

exe

I have a .manifest file which is linked with a .exe program file so that it asks for admin privileges when opened. Now it is a separate file called program_name.exe.manifest which is is the same folder as program_name.exe. Is there any way by which we can embed the manifest file into the .exe file so that it can be one single file instead of two.

BTW the program is created using C++


1 Answers

Yes. Declare the manifest as a resource and then just build the resource object file and link it to your exe.

In your resource.rc file, define your manifest resource like so:

IDR_RT_MANIFEST1        RT_MANIFEST            "program_name.exe.manifest"

In your resource.h file declare it with the value 1

#define IDR_RT_MANIFEST1    1

Build the resource file with windres: windres resource.rc -o resource.o

Link the resource when building your project: -l resource.o

.........................................................................

If your're using Visual Studio you don't need to build it explicitly, but there are 2 options which should be set beforehand:

1) Project > Project_Name Properties > Configuration Properties > Linker > Manifest File -> Generate Manifest set to No

2) Project > Project_Name Properties > Configuration Properties > Manifest Tool > Embed Manifest set to Yes

Also add your manifest file to your project as existing item.

like image 66
kundrata Avatar answered Oct 31 '25 00:10

kundrata



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!