Announcement

Collapse
No announcement yet.

Open LNK Failure

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Open LNK Failure

    This is a followon thread to an issue that came up in the EZFree thread, regarding LNK files.

    Rather than use the AFX function to get the TargetFile from a LNK file in the %AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar folder, I'd like open the shortcut
    programmatically directly from the LNK file. I assumed that ShellExecute would do the trick.

    As a test, I created an EXE called "test.exe", then created a shortcut LNK file to it. I can open the EXE with ShellExecute pointing to the LNK file like this (all files in the same folder):

    Code:
    i = ShellExecute(0,"Open",Exe.Path$ + "TEST.LNK", $Nul, $Nul, %SW_ShowNormal)
    But if I change the EXE code to open a LNK file for the app IrfanView from the ...\Taskbar folder like this ...

    Code:
    i = ShellExecute(0,"Open",Exe.Path$ + "irfanview 64.lnk", $Nul, $Nul, %SW_ShowNormal)
    ... it fails with this:

    SE_ERR_NOASSOC There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
    I can double-click on the IrfanView shortcut in the ...\Taskbar folder and it opens just fine, so I know the link works.

    Adding to the mystery, I see that using Jose's AFX function to get the target file returns c:\windows\system32\shell32.dll instead of c:\program files\irfanview\i_view64.exe. I see the i_view64.exe value in the Target: box when I right mouse click on the IrfanView LNK file and view properties, so I'm not sure why the AFX function returns the DLL file instead of the EXE file.

    Any explanation for what is happening?


  • #2
    I'g guess the first issue was to do with the space in the Irfanview link file name. Try quoting your
    Exe.Path$ + "irfanview 64.lnk"

    Comment


    • #3
      Howdy, Stuart!

      But, there are quotes used already. Maybe I misunderstand what you mean?

      Comment


      • #4
        Oh Gary!

        You should know after all this time that Windows always requires quotes around paths/filenames that contain spaces because it uses spaces to separate commands from parameters!

        You are passing a string something like:

        C:\mypath\Irfanview 64.lnk


        Which will be interpreted by Windows as a filename/command of C:\mypath\Irfanview with a parameter of 64.lnk

        Try
        ShellExecute(0,"Open",$DQ & Exe.Path$ + "irfanview 64.lnk" & $DQ, $Nul, $Nul, %SW_ShowNormal)
        which will be interpreted as the filename "C:\Mypath\Irfanview 64.lnk" (including the quotes)

        Comment


        • #5
          Howdy, Stuart!

          Indeed, I should have remembered that, especially since you pointed it out! Thanks for the second pointer/reminder!

          However, with that change, it still gives the same error SE_ERR_NOASSOC.

          Comment


          • #6
            Howdy, Stuart!

            And, I suppose it's because the AFX function applied to LNK returns SHELL32.DLL as its target file. No idea yet why it does that, but the NOASSOC would seem to fit a DLL extension.

            1 FileName: IrfanView 64.lnk
            2 FullPath: C:\Users\gbeen\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\IrfanView 64.lnk
            3 TargetFile: C:\WINDOWS\System32\SHELL32.dll
            4 IconLocation:
            5 IconIndex: 0
            6 hIcon: 3279793

            I'd have expected the AFX result for TargetFile to give back the IrfanView EXE.

            All of the other pinned apps I've tried so far return an EXE for the TargetFile.

            ... added ... SHELL32.DLL is more like an IconLocation, which AFX returns as blank. I'd accuse the LNK file of being written wrongly, but when I double click on it, it does open IrfanView. I'm missing something here ...

            Comment

            Working...
            X