I tryed to run codeexamples in different Topic s about readShellLink but allways there is a Compiler Error: 'wrong ParameterType: string expected'
But in the Microsoft description is a Pointer to a String:
HRESULT Load(
[in] LPCOLESTR pszFileName, <====================
[in] DWORD dwMode
);
If I give a String to the Parameter no results cames back.
Does somebody has any idea whats wrong or what can I do?
Perhaps I can declare my own structure?
The Code:
Code: Select all
Procedure.s ShortcutTarget(ShortcutFile$)
Result$ = ""
CoInitialize_(0)
If CoCreateInstance_(?CLSID_ShellLink, 0, 1,?IID_IShellLink, @ShellLink.IShellLinkA) = #S_OK
If ShellLink\QueryInterface(?IID_IPersistFile, @LinkFile.IPersistFile) = #S_OK
*buffer = AllocateMemory(1000)
If *buffer
MultiByteToWideChar_(#CP_ACP, 0, @ShortcutFile$, -1, *buffer, 1000)
If LinkFile\Load(*buffer, 0) = #S_OK ; [color=#FF4000]<-------------- this Line CompilerError
[/color]
If ShellLink\Resolve(0, 1) = #S_OK
RtlZeroMemory_(*buffer, 1000)
ShellLink\GetPath(*buffer, 1000, 0, 0)
Result$ = PeekS(*buffer)
EndIf
EndIf
FreeMemory(*buffer)
EndIf
LinkFile\Release()
EndIf
ShellLink\Release()
EndIf
CoUninitialize_()
ProcedureReturn Result$
DataSection
CLSID_ShellLink:
; 00021401-0000-0000-C000-000000000046
Data.l $00021401
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
IID_IShellLink:
; DEFINE_SHLGUID(IID_IShellLinkA, 0x000214EEL, 0, 0);
; C000-000000000046
Data.l $000214EE
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
IID_IPersistFile:
; 0000010b-0000-0000-C000-000000000046
Data.l $0000010b
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
EndProcedure
ShortcutFile$ = 'BenMitBrille1.jpg.lnk'
Debug ShortcutTarget(ShortcutFile$)
; IDE Options = PureBasic 5.62 (Windows - x64)
; CursorPosition = 13
; FirstLine = 9
; Folding = -
; EnableThread
; EnableXP
; EnableAdmin
; EnableOnError
; HideErrorLog
; EnableCompileCount = 0
; EnableBuildCount = 0