简体   繁体   中英

Embedding manifest to exe file

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++

If you are using windows CL, like powershell, try

program_name.exe –manifest program_name.exe.manifest -outputresource:program_name.exe;1

That should do the trick.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM