Code: Select all
;
; ANSI version (supposed to work in Windows 9X and later)
;
#CLSCTX_INPROC_SERVER = 1
#SLGP_UNCPRIORITY = 2
#QueryInterface = 0
#Release = 8
#GetArguments = 12
#GetPath = 32
#Load = 20
Procedure.s GetShortcutTarget(LinkFileName.s)
Temp.s = LCase(LinkFileName)
Info.s
If FindString(Temp, ".lnk", 0)
Link.s = LinkFileName
Shared psl ; IShellLink*
hres = CoCreateInstance_(?CLSID_ShellLink, #NULL, #CLSCTX_INPROC_SERVER, ?IID_IShellLink, @psl)
If hres=#S_OK
Shared ppf ; IPersistFile*
hres = CallCOM(#QueryInterface, psl, ?IID_IPersistFile, @ppf)
If hres=#S_OK
Dim wsz.w(#MAX_PATH)
MultiByteToWideChar_(#CP_ACP, #MB_PRECOMPOSED, Link, -1, wsz(), #MAX_PATH)
hres = CallCOM(#Load, ppf, wsz(), 0)
If hres=#S_OK
TempBuffer = AllocateMemory(0, 1024)
CallCOM(#GetPath, psl, TempBuffer, 1024, #NULL, #SLGP_UNCPRIORITY)
TempBuffer = MemoryID() ; TempBuffer variable trashed for some reason (weird!)
Info.s = PeekS(TempBuffer)
CallCOM(#GetArguments, psl, TempBuffer, 1024)
Info+" "+PeekS(TempBuffer)
FreeMemory(0)
EndIf
EndIf
CallCOM(#Release, psl)
EndIf
Else
Info = LinkFileName
EndIf
ProcedureReturn Info
EndProcedure
CoInitialize_(0)
File$ = OpenFileRequester("Select link", "", "Link files (*.lnk)|*.lnk|All files (*.*)|*.*", 0)
If File$
MessageRequester("Links to", GetShortcutTarget(File$), 0)
EndIf
CoUnInitialize_()
End
!section '.data' Data readable writeable
IID_IShellLink:
!dd $000214EE
!dw 0, 0
!db $0C0, 0, 0, 0, 0, 0, 0, $046
CLSID_ShellLink:
!dd $21401
!dw 0, 0
!db $0C0, 0, 0, 0, 0, 0, 0, $046
IID_IPersistFile:
!dd $0000010B
!dw 0, 0
!db $0C0, 0, 0, 0, 0, 0, 0, $046
El_Choni