Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Update .lnk icon
#1
i have a shortcut on desktop where i change the icon on result of a function.
currently i use CreateShortcutEx for updating the icon, but i would prefer to update the .lnk
without overwriting it.
i use stardock fences to organize my desktop icons in areas, unfortunately it tries to handle
my shortcut because it has been created again.

i would like to change only the icon info and send some kind of refresh to desktop.

thanks
pi
#2
Function ChangeShortcutIcon
Code:
Copy      Help
;/
function $lnkFile $iconFile [iconIndex]

;Changes shortcut icon.
;Error if lnkFile or iconFile does not exist or lnkFile is read-only.

;EXAMPLE
;ChangeShortcutIcon "$desktop$\Macro1284.lnk" "shell32.dll" 9


str slnk sico
slnk.expandpath(lnkFile)
if(!dir(slnk) or !sico.searchpath(iconFile)) end "file not found"

IShellLinkW psl
IPersistFile ppf
psl._create(CLSID_ShellLink)
ppf=+psl
ppf.Load(@slnk STGM_WRITE)
psl.SetIconLocation(@sico iconIndex)
ppf.Save(0 1)

err+ end _error
#3
thanks for your help.
it seems that using desktop shortcuts is the wrong approach.
i need to build something like stardock fences later on with qm, because shortcut change is wrong interpreted by fences.
my desktop icon arrangement is disturbed when using qm.
such mis-functionality drives me mad. :oops:

it makes more sense to create an own desktop icon area toolbar with qm.

so sorry to bother again,
what is the best way to change a button icon on a qm toolbar?

like on click and drop.
pi
#4
Easiest - getmacro/replace/setmacro.
Another way - replace icon in toolbar's imagelist. Not sure it is possible, but can try to create such function tomorrow.
#5
does setmacro update a toolbar on the fly?
pi
#6
yes
but this way is quite slow
#7
I found it very useful. However I found that "ppf.Save" looses shortcut content. Please advise.
#8
now fixed


Forum Jump:


Users browsing this thread: 4 Guest(s)