News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Create a shortcut

Started by jj2007, June 21, 2024, 07:49:08 AM

Previous topic - Next topic

jj2007

include \masm32\MasmBasic\MasmBasic.inc ; ## COM demo: create shortcut ##
include IShellLink.inc
; credits to Gerardo Friedrich (BiteRider), Jaymeson Trudgen (NaN) and Ernest Murphy (source)
.code
CreateSC proc pPathObj, pPathLink
LOCAL WebInterface, pIPersistFile
  lea edi, WebInterface
  pIShellLink equ dword ptr [edi]
  .if rv(CoCreateInstance, offset CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, offset IID_IShellLink, edi)==S_OK
CoInvoke pIShellLink, IShellLinkWVtbl.QueryInterface, addr IID_IPersistFile, addr pIPersistFile
.if eax==S_OK
CoInvoke pIShellLink, IShellLinkWVtbl.SetPath, pPathObj
CoInvoke pIShellLink, IShellLinkWVtbl.SetIconLocation, pPathObj, 0
.if eax==S_OK
CoInvoke pIPersistFile, IPersistFileVtbl.Save, pPathLink, TRUE
PrintLine Str$("Done, result=%i", eax)
.endif
.endif
  .endif
  ret
CreateSC endp
  SetGlobals src$, lnk$
  Init
  .if rv(OleInitialize, NULL)==S_OK
wLet src$=wRec$(MbExeFolder$)+"ShortCut.asc"
wLet lnk$=wRec$(MbExeFolder$)+"ScSource.lnk"
invoke CreateSC, src$, lnk$
invoke OleUninitialize
  .endif
EndOfCode