StringBuilder sbProductCode = new StringBuilder(39), Internal static string TryGetRealShortcutTarget(string lnkPath) Private static extern uint MsiGetComponentPathW( string productCode, Private static extern uint MsiGetShortcutTargetW( string shortcutPath, So far I assume that component id and component code are the same GUIDs, or could these both have different content? The documentation about MsiGetComponentPathW() says that a product code and a component id are needed as arguments. The documentation about MsiGetShortcutTargetW() says that GUIDs for product code and component code will be returned. But in case of 'Adobe Reader XI.lnk' I get the GUIDs for product code and component code from MsiGetShortcutTargetW(), but MsiGetComponentPathW() returns -1 (INSTALLSTATE_UNKNOWN). MsiGetShortcutTargetW() and MsiGetComponentPathW() work for some lnk files. Use finalTarget as the resolved target for the shortcut ShellLinkObject linkedLnk = (ShellLinkObject)shell.NameSpace(targetPath).Items().Item().GetLink While (targetPath.EndsWith(".lnk") & !string.IsNullOrEmpty(arguments)) ShellLinkObject lnk = (ShellLinkObject)item.GetLink using Shell32 įolder folder = (FolderItem item in folder.Items()) In this case, you can resolve targets recursively by getting the ShellLinkObject referencing the shortcut and retrieving its TargetPath and Arguments properties. If TargetPath ends in ".lnk" and the Arguments property is not empty, another shortcut is referenced. To determine if there is a different target behind the shortcut, you can check the ShellLinkObject properties TargetPath and Arguments. In some cases, the Target.Path property may not provide the desired result, as it may return an icon file instead of an executable. If not solved, you caould try the following code to see if it helps you. It's helpful for community members with related questions. Is there any update to the question? Did the answer below solve your problem? If so, you could accept it as the answer. Is there any way to find out if there is a target other than behind the Heiko.Welcome Microsoft Q&A. Target.Path contains the ico file, although AcroRd32.exe is started. String path = target.Path // path: C:\Windows\Installer\\SC_Reader.ico Shell32.ShellLinkObject lnk = item.GetLink Shell32.Folder folder = (Shell32.FolderItem item in folder.Items()) Shell32.Shell shell = new Shell32.Shell() Add Reference to 'Microsoft Shell Controls And Automation' from COM area. However, if I start the lnk file with Process.Start(), a process is started with C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe. When I look at the properties of the shortcut on the desktop, the target field is locked and the name of the app is shown in it. However, with Adobe Reader XI, I only get an ico file as a target. In my app, I am trying to get the destinations of various shortcuts. I have a shortcut on the desktop, that opens Adobe Reader XI, in the following path:Ĭ:\Users\Heiko\Desktop\Adobe Reader XI.lnk
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |