Trying to read a shortcut
Archives Forums/Win32 Discussion/Trying to read a shortcut
| ||
I'm trying to get the contents of a dropped shortcut (-got the dropped bit working). Unfortunately this causes a MAV, and I don't understand the code well enough. Can anybody help? Graphics 800,600 pszLinkto$ = "C:\Documents and Settings\John\Desktop\Lifestory.doc.lnk" ; test shortcut pszDir$ = Chr$(0) ;= String$(" ",512) ; neither of these make any difference pszName$ = String$(" ",512) ; \/ This causes a MAV api_SHGetNewLinkInfo% (pszLinkto$, pszDir$, pszName$, pfMustCopy%, uFlags%) ; Shell32 "SHGetNewLinkInfoA" Print pszLinkto$ Print pszDir$ Print pszName$ WaitKey() End |
| ||
You'll most likely have to create a bank to hold each string (I would recommend minimum size of Windows constant MAX_PATH, which is 264 from memory), poke in the relevant strings, and pass the bank handles to the Win32 call. If you need to read any of the strings afterwards, you'll have to peek the bytes from the relevant bank. The docs will tell you what hex values to pass for uFlags. Looks like you'll need to pass an int-sized bank for pfMustCopy too, then read from it afterwards if you need to know its result. |
| ||
James, as always, thanks for your support. What you say makes sense, but I have no idea how to do it. Fancy having a go? |
| ||
I've spent 3 days trying to understand DLLs. I got fed up and handcoded it in an hour:- http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=3104 Don't you just love Blitz! |
| ||
Just had a go at this, but it turns out that not only does SHGetNewLinkInfo not do what you want, M$ decided to make it ridiculously complex to just retrieve the target path from a shortcut, and it can't be easily done via Blitz -- there's no simple API call for it. If your manual parsing of the shortcut file works, then... well done! |
| ||
Hi John BlackLedge , I tried your nice code (3 days on), so far I'm getting this error :![]() ![]() ![]() It sort of works. ![]() |