最新消息:

从dll文件提取图标

nsis 永恒心锁 139浏览 0评论
!include nsDialogs.nsh

Page Custom MyIconPage

!define /IfNDef LOAD_LIBRARY_AS_DATAFILE 2
!define /IfNDef LR_DEFAULTSIZE 0x0040
!define /IfNDef SHGFI_ADDOVERLAYS 0x000000020
!define /IfNDef SHGFI_ICON 0x000000100
!define /IfNDef SHGFI_USEFILEATTRIBUTES 0x000000010
!if "${NSIS_CHAR_SIZE}" > 1
!define /redef /math SHFILEINFO_SIZE ${NSIS_PTR_SIZE} + 688
!else
!define /redef /math SHFILEINFO_SIZE ${NSIS_PTR_SIZE} + 348
!endif
!define /IfNDef SIID_DRIVEFIXED 8

Var hIcoByIndex
Var hIcoByResId
Var hIcoForSpecificDrive
Var hIcoForGenericDrive

Function MyIconPage
nsDialogs::Create 1018
Pop $0

${NSD_CreateIcon} 0 0u 20u 20u ''
Pop $1
System::Call 'SHELL32::ExtractIcon(p0, t "$SysDir\SHELL32.dll", i 8)p.s'
Pop $hIcoByIndex
SendMessage $1 ${STM_SETIMAGE} ${IMAGE_ICON} $hIcoByIndex

${NSD_CreateIcon} 50u 0u 20u 20u ''
Pop $1
System::Call 'KERNEL32::LoadLibraryEx(t "$SysDir\SHELL32.dll", p0, i${LOAD_LIBRARY_AS_DATAFILE})p.s'
System::Call 'USER32::LoadImage(pss, t "#9", i ${IMAGE_ICON}, i0, i0, i${LR_DEFAULTSIZE})p.s'
Pop $hIcoByResId
System::Call 'KERNEL32::FreeLibrary(ps)'
SendMessage $1 ${STM_SETIMAGE} ${IMAGE_ICON} $hIcoByResId
${NSD_CreateIcon} 200 20u 20u 20u ''
Pop $1
StrCpy $2 $SysDir 3 ; "c:\" probably
System::Call 'SHELL32::SHGetFileInfo(t"$2", i0, @r2, i ${SHFILEINFO_SIZE}, i${SHGFI_ICON}|${SHGFI_ADDOVERLAYS})p.r3'
${If} $3 P<> 0
System::Call '*$2(p.s)'
Pop $hIcoForSpecificDrive
${EndIf}
SendMessage $1 ${STM_SETIMAGE} ${IMAGE_ICON} $hIcoForSpecificDrive
${NSD_CreateIcon} 0 40u 20u 20u ''
Pop $1
System::Call 'USER32::GetClientRect(p0,@r2)'
System::Call '*$2(&l${NSIS_PTR_SIZE},p,i,i,&w260)'
System::Call 'SHELL32::SHGetStockIconInfo(i ${SIID_DRIVEFIXED}, i${SHGFI_ICON}, pr2)i.r3'
${If} $3 >= 0
${AndIf} $3 != "error"
System::Call '*$2(&i${NSIS_PTR_SIZE},p.s)'
Pop $hIcoForGenericDrive
${Else}
System::Call 'SHELL32::SHGetFileInfo(t"c:\", i0x10, @r2, i ${SHFILEINFO_SIZE}, i${SHGFI_ICON}|${SHGFI_USEFILEATTRIBUTES})p.r3'
${If} $3 P<> 0
System::Call '*$2(p.s)'
Pop $hIcoForGenericDrive
${EndIf}
${EndIf}
SendMessage $1 ${STM_SETIMAGE} ${IMAGE_ICON} $hIcoForGenericDrive
nsDialogs::Show
${NSD_FreeIcon} $hIcoByIndex
${NSD_FreeIcon} $hIcoByResId
${NSD_FreeIcon} $hIcoForSpecificDrive
${NSD_FreeIcon} $hIcoForGenericDrive
FunctionEnd

Section
nop
SectionEnd
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 从dll文件提取图标

您必须 登录 才能发表评论!