更新时间:2016-06-01 20:56:22浏览次数:1+次
第一张:使用Unicode字符集的控件样子
第二张:使用多字节字符集的控件的样子
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings" xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</ms_windowsSettings:dpiAware>
</windowsSettings>
</application>
</assembly>
VS自动生成manifest文件内容只有一行,我打成很多行了,便于阅读。你在这个manifest文件中找不到任何控件版本的信息。<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false">
</requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings" xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</ms_windowsSettings:dpiAware>
</windowsSettings>
</application>
</assembly>
同样,VS自动生成的manifest文件只有一行,我打成很多行了,便于阅读。此时看到的manifest文件多了一些内容。很明显,你可以看到Microsoft.Windows.Common-Controls字样,然后看到version="6.0.0.0"的字样,这已经表明了这个配置文件确定使用的控件版本为win7风格的控件。假如你将下面这一段包含控件版本信息的删掉,然后保存编译。你会发现,控件又恢复了老版本控件风格,删除的内容如下:<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*">
</assemblyIdentity>
</dependentAssembly>
</dependency>
很明显,这一段配置也就是决定控件风格的东西。实际上与项目使用的字符集没有直接关系,只是说,默认情况下,设置了Unicode字符集,VS会自动加上这一段配置信息。但是也有情况加不上,也就导致了即使是Unicode字符集,也老版本控件。问题就出在manifest配置文件没有控件版本的信息。如果有,还得确保版本是6.0.0.0哦。看看VS项目属性的一个配置文件清单设置,如下图所示:
清单工具其实就是设置manifest配置文件的相关信息的。默认情况下,生成的manifest配置文件会嵌入到exe文件内部。这样在运行的时候,不用随着exe带着一个manifest配置文件。当然,如果像图中一样取消嵌入清单选项,那么VS会将manifest配置文件生成在exe同一目录下,而且名字就是exe文件名称.exe.manifest。exe运行时就会读取manifest配置文件,然后决定使用什么版本的控件。如果缺少manifest配置文件,那么exe将无法启动。
相关资讯