Hi guys
I am using MUI2 Interface.
${NSD_CreateIcon} 110u 35u 20u 20u ''
Pop $0
${NSD_SetIcon} $0 '$SYSDIR\shell32.dll,8' $0
But it's not show.
How to add icon from System Icon Resource shell32.dll ?.
Thanks.
nsDialogs - How to add icon from System Icon Resource shell32.dll
8 posts
That is shell icon syntax, it is not supported directly.
Do you want the shells disk icon or just a icon from shell32? And which size do you want?
Do you want the shells disk icon or just a icon from shell32? And which size do you want?
I need to display the icon available in $SYSDIR\Shell32.dll file (C:\Windows\System32\shell32.dll). And the size is 32 x 32 px.
I know you are asking for the image in shell32 but it would be better to tell us why you need it.
Do you want the icon for a specific drive or do you want a generic drive icon?
Do you want the icon for a specific drive or do you want a generic drive icon?
I need Icon which have index = 16
When open shell32.dll in IconsExtract-Nirsoft:

I want a generic drive icon.
When open shell32.dll in IconsExtract-Nirsoft:

I want a generic drive icon.
Of course you ask for the icon that is hardest to get 🙂 FYI, the generic image is not in shell32 and there is no real generic drive icon on < Vista.
On < Vista the generic icon might be wrong.
On < Vista the generic icon might be wrong.
!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} 22u 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} 0 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)' ; Just to get a buffer
System::Call '*$2(&l${NSIS_PTR_SIZE},p,i,i,&w260)'
System::Call 'SHELL32::SHGetStockIconInfo(i ${SIID_DRIVEFIXED}, i${SHGFI_ICON}, pr2)i.r3' ; Vista+
${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 I tested your code on Win 7 x64 SP1.
Result: installer process exit quickly.
Result: installer process exit quickly.
Start commenting out code blocks until you find which part is broken, I did not have much time to test this.Originally Posted by meoit View PostI tested your code on Win 7 x64 SP1.
Result: installer process exit quickly.
And please tell me your NSIS version and if you are generating a Unicode installer.