让程序的按钮显示UAC的小盾图标

本文介绍了一种在按钮上显示UAC盾牌图标的方法,通过调用特定宏及加入必要的代码片段,使得按钮能够正确展示UAC盾牌图标。

本文转自: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小盾就可以显示啦。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值