title: Inno Setup: access violation using IShellLink GetWorkingDirectory
body: <p>I am using Inno Setup. The installed application can have multiple installs so multiple Start Menu shortcuts are created. The trouble I am running into is that multiple icons are created to the same application location (duplicates). My solution is in the install process to check existing Start Menu shortcuts, read the Working or Target directory property of the shortcut, and check it against the current install directory. If one of the shortcuts has a match then don't install a shortcut.</p>
  
  <p>I am using the example file "CodeAutomation2.iss" as a starting point to read the Working Directory on the shortcut link. The IShellLink code in the example file is what I have been using but when I try to use "GetWorkingDirectory" I get the following error.</p>
  
  <p><img src="https://i.stack.imgur.com/bpfUw.png" alt="Access violation"></p>
  
  <p>Below is the code I am using. What am I doing wrong with "GetWorkingDirectory"?</p>
  
  <pre><code>var
    ShortcutFile: String;
  
    WorkingDir: String;
    Obj: IUnknown;
    SL: IShellLinkW;
    PF: IPersistFile;
  
  begin
    { Create the main ShellLink COM Automation object }
    Obj := CreateComObject(StringToGuid(CLSID_ShellLink));
  
    { Set the shortcut properties }
    SL := IShellLinkW(Obj);
    PF := IPersistFile(Obj);
  
    NumFiles := 1
    ShortcutFile := ExpandConstant('{#MyAppName}');
  
    Log('File is: ' + ExpandConstant('{group}') + '\' + ShortcutFile + '.lnk');
    OleCheck(PF.Load(ExpandConstant(ExpandConstant('{group}') + '\' + ShortcutFile + '.lnk'), 0));
    OleCheck(SL.GetWorkingDirectory(WorkingDir, 250));
    Log('WorkingDir: ' + WorkingDir);
  </code></pre>