Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 24th April 2020, 06:02   #1
meoit
Senior Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 100
Post nsDialogs - How to add icon from System Icon Resource shell32.dll

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.
meoit is offline   Reply With Quote
Old 24th April 2020, 10:52   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,314
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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th April 2020, 11:44   #3
meoit
Senior Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 100
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.
meoit is offline   Reply With Quote
Old 24th April 2020, 12:27   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,314
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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th April 2020, 12:37   #5
meoit
Senior Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 100
I need Icon which have index = 16

When open shell32.dll in IconsExtract-Nirsoft:



I want a generic drive icon.
meoit is offline   Reply With Quote
Old 24th April 2020, 13:10   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,314
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.

PHP Code:
!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_CreateIcon0 0u 20u 20u ''
Pop $1
System
::Call 'SHELL32::ExtractIcon(p0, t "$SysDir\SHELL32.dll", i 8)p.s'
Pop $hIcoByIndex
SendMessage 
$${STM_SETIMAGE} ${IMAGE_ICON$hIcoByIndex


${NSD_CreateIcon22u 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 $${STM_SETIMAGE} ${IMAGE_ICON$hIcoByResId


${NSD_CreateIcon0 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 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th April 2020, 13:22   #7
meoit
Senior Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 100
I tested your code on Win 7 x64 SP1.

Result: installer process exit quickly.
meoit is offline   Reply With Quote
Old 24th April 2020, 13:25   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,314
Quote:
Originally Posted by meoit View Post
I tested your code on Win 7 x64 SP1.

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.

And please tell me your NSIS version and if you are generating a Unicode installer.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump