參考:http://www.cnblogs.com/pkill/archive/2010/07/09/1774527.htmlhttp://wutiam.net/2009/08/manifest-dependencies-in-visual-studio-2005/總結(jié)如下:1、自動(dòng)生成XXX.exe.manifest文件1)編寫內(nèi)容。程序使用unicode字符集,stdafx.h 中加入
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'"")
#else
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"")
#endif
#endif
若要取消unicode限定,只需修改為:
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'"")
#else
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"")
#endif
注:這些語句也可不寫在stdafx.h中,直接在 “工程屬性頁-》清單工具-》輸入輸出 -》附加清單文件”中添加內(nèi)容。
對應(yīng)X86就添加:
type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'
不過可能靈活性可能不夠。
2)然后就是一些設(shè)置:
☆ 工程屬性頁-》清單工具-》輸入輸出
嵌入清單: 是
輸出清單文件: $(IntDir)$(TargetName)$(TargetExt).embed.manifest
清單資源文件: $(IntDir)$(TargetName)$(TargetExt).embed.manifest.res
☆ 鏈接-》清單文件-》生成清單文件 設(shè)為“是”
這樣清單文件就會(huì)嵌入到exe文件中,單獨(dú)執(zhí)行exe就可以實(shí)現(xiàn)xp風(fēng)格。
或者,也可以設(shè)置“嵌入清單”為“否”
這樣就會(huì)單獨(dú)生成個(gè)“程序名.exe.manifest"文件,只有與exe文件放在同一目錄下,
才能實(shí)現(xiàn)xp風(fēng)格。發(fā)布時(shí)需要同時(shí)帶上.manifest文件。
2、自己創(chuàng)建并引入一個(gè).manifest文件資源
1) 創(chuàng)建一個(gè).manifest文件的資源.
在res/文件夾下創(chuàng)建一個(gè)跟以程序名加.manifest的文件, 如果程序?yàn)閠est.exe, 則創(chuàng)建test.exe.manifest
文件內(nèi)容同上面生成的.manifest文件:
<?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' />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*' />
</dependentAssembly>
</dependency>
</assembly>
注意要使用utf-8編碼保存。
2) 將新定義的資源加入到.rc2文件中, 類型設(shè)為24.
打開res/文件夾下的.rc2文件, 在其中加入如下定義:
1 24 MOVEABLE PURE "res/test.exe.manifest"
其中的文件地址按1)步中修改的設(shè)置即可.注意資源ID值一定要為1,當(dāng)然可用定義為1的宏表示。
之后編譯即可, 為了使程序界面可能充分利用系統(tǒng)的界面特性, 可以將界面字體設(shè)置為TrueType類型的, 利用Windows XP等系統(tǒng)的屏幕字體平滑特性.