在我们需要在代码中内嵌图标时就需要把base64转为图标。
下面是示例代码
Persistent
Base64PNG := ' ;
(
iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAYAAAD0xERiAAAAAXNSR0IArs4c6QAAAS1JREFUOE+Vk11OwzAQhGf
diwSFF0Q4Q8NJaG8BFRKNhAK3aDlJwhnaihcC5iDxonXcqHF+3PrFsuT9PDuzJlywDvFqwcBcSoihmRABSAHZuaQQ
a3f9nBLXLwBJ0eQahH1Fj5FR6sG9vPAIW3d2ipoTk7rvwRolpuhL4JKYSiZO+yq5TKq3LmwMRIw1CH8MbEb63CZVvmy
VSWv1TP16lzWTWgY800mVX9lQjsX7eCWvnvjTSN/HT8W4+c2dI8PC+qrCIGn99ifPTjuxMDc/zo8wSJK7+34tff98mO1
/ujW0Hg3CXIqbBuR71ykZBXUCEKAyZs6E9VT8U1+gTXNkxuy0z2qT3eh3fdZ3cmkWBGSqNtbYc4oHPROfmNTHUEIhNZ3RcI
bL9H76haLyEoX/9+CcYzvLE9oAAAAASUVORK5CYII=/Xoj1P96I9T/eiPU/3kj1Pd5ItR8eiPTAgAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAB6I9SDeiPTWHki1Id6I9T/eiPU/3oj1P96I9T/eiPU/3oj06F6ItQCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeSLU
oXkj1PN6I9MyeSLUw3oj1P96I9T/eiPU/3oj1P96I9T/eiLUcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHki1JN6I9T/eSPT23kj1Cx5ItTleiP
U/3oj1P96I9T/eiPU/3ki1KsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB5ItRgeiPU/3oj1P95I9TBeSPUPHkj1PV6I9T/eiPU/3oj1P95I9T
/eSPUpXoj0wwAAAAAAAAAAAAAAAAAAAAAeSLUEnki1PV6I9T/eiPU/3oj06l5ItROeSLU+3oj1P96I9T/eiPU/3oj1P95ItTPeSLUFAAAAA
AAAAAAAAAAAAAAAAB5ItSJeiPU/3oj1P96I9T/eSPUn3ki1FZ6ItT5eiPU/3oj1P96I9T/eiPU/3ki1MN5ItQEAAAAAAAAAAAAAAAAeSLUDHki
1Nt6I9T/eiPU/3oj1P95ItSreSLUUnki1PN6I9T/eiPU/3oj1P96I9T/eiLUaAAA7AAAAAAAAAAAHoi1CR6I9SDeSLUp3oj1IF6ItTZeSLU+3ki1
OF5ItRY//8AAP//AAC//wAAw/8AAOD/AACgPwAAkD8AAIgfAADEDwAAwgcAAMEDAADggwAA8EEAAPwBAAD+AAAA/4EAAA==
)'
;设置图标,注意base64字符串是png格式转化而来,一般尺寸在32x32或者16x16
TraySetIcon('HICON: ' . Base64PNG_to_HICON(Base64PNG))
Base64PNG_to_HICON(Base64PNG, height := 16) {
size := StrLen( RTrim(Base64PNG, '=') )*3//4
if DllCall('Crypt32\CryptStringToBinary', 'Str', Base64PNG, 'UInt', StrLen(Base64PNG), 'UInt', 1,
'Ptr', buf := Buffer(size), 'UIntP', &size, 'Ptr', 0, 'Ptr', 0)
return DllCall('CreateIconFromResourceEx', 'Ptr', buf, 'UInt', size, 'UInt', true,
'UInt', 0x30000, 'Int', height, 'Int', height, 'UInt', 0)
return 0
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
学习了!感谢作者分享!
刚好需要!感谢分享!😁