Page 1 of 1
Shortcuts (.lnk)
Posted: Fri Apr 16, 2004 3:50 am
by Phant0m``
I looked all over the place and I couldn’t find anything that retrieves Target Info from Shortcuts (.lnk)….
Are there any posts that I could be referred to?
Thanks in Advanced...
Posted: Fri Apr 16, 2004 4:01 am
by Phant0m``
N/M, i figured it out

Posted: Fri Apr 16, 2004 4:38 am
by Phant0m``
OK this is stupid, i spoke to soon...
I thought i had it because using
Code: Select all
Debug OpenFileRequester("Choose file","","",0)
It returns with Target rather then the .lnk but when i use OpenFile() it returns with .lnk.... I'm stumped

Posted: Fri Apr 16, 2004 12:39 pm
by Kris_a
I found this document that explains how the LNK file format works, perhaps you could have a read then make some sort of interpreter in PB?
http://www.the7soft.com/file-formats/fi ... /lnk_c.zip
Posted: Fri Apr 16, 2004 1:48 pm
by Phant0m``
To some sort of interpreter in PB is well out of my lead at this time, I only began programming in general the other week.
I know one thing, shouldn’t be this hard just to retrieve Shortcut Target Informatics. :/
Posted: Fri Apr 16, 2004 1:49 pm
by freak
Try this:
Target$ = ShortcutTarget(Shortcut$)
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
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
Timo
Posted: Fri Apr 16, 2004 1:53 pm
by Phant0m``
Now you just simply a programming G0d, thanks freak....
Posted: Fri Apr 16, 2004 4:04 pm
by Phant0m``
How about Windows Tasks files (.job) ?
Posted: Fri Apr 16, 2004 5:46 pm
by freak
Never heard of that, sorry

Posted: Fri Apr 16, 2004 6:57 pm
by Phant0m``
.job files are files stored in Windows Tasks folder (\WINDOWS\Tasks), it is pretty much a shortcut. If you actually copy the file over to another place, and open up with notepad you can actually see Target Information in ASCII.