本文转自:http://hi.baidu.com/c0dexploit/item/c1c55423a7e65f504799627d
目前一些程序对于UAC的支持还不是很好,还有的程序员说用PS的图标放程序里面去。其实山寨大可不必,又费时又费力,微软已经有文档说明了。可惜的是微软的文档的可操作性不是太好,因此我也实践了下才成功的。
参考:http://msdn.microsoft.com/en-us/library/bb756990.aspx
微软比较吝啬言语:
Add a Shield Icon to a Button
The standard button control (PUSHBUTTON, DEFPUSHBUTTON) has been enhanced to allow you to add an icon along with the displayed text, without requiring the BS_ICON or BS_BITMAP styles to be set.
To display the shield icon, call the following macro (defined in commctrl.h):
Button_SetElevationRequiredState(hwndButton, fRequired);
仅仅照上述说法操作,死活没把程序的图标搞出来,后来发现是要加入下面的代码:
#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
有了上述指示,按钮图标前的UAC小盾就可以显示啦。