我正在Ubuntu下使用i586-mingw32msvc进行交叉编译应用。
我不太清楚如何在mingw32中嵌入一个需要管理员权限的manifest文件。
这是我使用的示例hello.c
:
int main() {
return 0;
}
这个资源文件 hello.rc
:
1 Manifest "hello.exe.manifest"
这个清单文件 hello.exe.manifest
:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="hello" type="win32"/>
<description>Hello World</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
我使用以下命令编译资源文件:
i586-mingw32msvc-windres hello.rc hello.o
我使用以下内容编译我的最终应用程序:
i586-mingw32msvc-gcc -O3 -Os -s -o hello.exe hello.c hello.o
SigCheck不能显示运行sigcheck -m hello.exe
的清单文件。
现在当我在Windows下运行我的应用程序时,它不会触发UAC(=不以管理员身份运行),而当我在同一个文件夹中附加了hello.exe.manifest
文件时,它会触发UAC(如预期)。
我错过了什么?
EDIT1: 使用Resource Hacker尝试修改由NSIS创建的Setup.exe
文件后,唯一敏感的区别是在我的hello.exe
中写成MANIFEST
,而在Setup.exe
中则是Manifest
。尽管在hello.rc
中它被写为Manifest. O_o
EDIT2: 我使用Resource Hacker手动更改了Manifest
组:
现在hello.exe
正常工作,触发UAC警报并以管理员身份运行。看起来像是i586-mingw32msvc-windres
中的一个“错误”。 :-)
hello.rc
文件更新为1 Manifest "hello.exe.manifest"
。使用 Resource Hacker,我打开了一个需要管理员权限的 NSIS 安装程序(我使用 makensis 编译),一切都基本相同;唯一不同的是,在Setup.exe
文件中,清单字段写作“Manifest”,而在我的hello.exe
文件中写作“MANIFEST”!(请参见此处 http://i.imgur.com/WzHtXnw.png) - pr.nizar.rc
文件生成.res
文件,而不是.o
文件。 - M.M