Hi Ian,

Have a look at
http://stackoverflow.com/questions/2565885/net-read-binary-contents-of-lnk-file

Before method below would work, you need to import
c:\windows\system32\shell32.dll (add proj. reference which will generate
interop library).

public static string GetLnkTarget(string lnkPath) {
    var shl = new Shell32.Shell();         // Move this to class scope
    lnkPath = System.IO.Path.GetFullPath(lnkPath);
    var dir = shl.NameSpace(System.IO.Path.GetDirectoryName(lnkPath));
    var itm = dir.Items().Item(System.IO.Path.GetFileName(lnkPath));
    var lnk = (Shell32.ShellLinkObject)itm.GetLink;
    return lnk.Target.Path;
}



On 5 March 2012 08:33, Ian Thomas <[email protected]> wrote:

> ** ** **
>
> I have 100+ shortcuts to files, the targets of which were subsequently
> moved. For a reason I won’t explain, these files need to be moved back to
> the locations in the (intact) shortcuts. ****
>
> My quick research indicates I should use COM Interop with IShellLink as
> there is no direct class to create or read shortcut files. Is that right?
> How would I do this? (not using WSH)****
>
> ** **
>  ------------------------------
>
> **Ian Thomas**
> Victoria Park, ********Western Australia************
>
> ** **
>

Reply via email to