讓程序的按鈕顯示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小盾就可以顯示啦。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章