Skip to content

Commit

Permalink
[PTRun]Fix locking link files for MSI installers. Warning 1946 (#37654)
Browse files Browse the repository at this point in the history
* [Runner] fix MSI installer issue. Warning 1946

* Fix catching exceptions

* Better error handling

* Revert "Better error handling"

This reverts commit 0f3ec2a.
  • Loading branch information
donlaci authored Feb 27, 2025
1 parent bf26857 commit 8a2d474
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/modules/launcher/Wox.Infrastructure/ShellLinkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,25 @@ public string RetrieveTargetPath(string path)
var link = new ShellLink();
const int STGM_READ = 0;

// Make sure not to open exclusive handles.
// See: https://github.com/microsoft/WSL/issues/11276
const int STGM_SHARE_DENY_NONE = 0x00000040;
const int STGM_TRANSACTED = 0x00010000;

try
{
((IPersistFile)link).Load(path, STGM_READ);
((IPersistFile)link).Load(path, STGM_READ | STGM_SHARE_DENY_NONE | STGM_TRANSACTED);
}
catch (System.IO.FileNotFoundException ex)
{
Log.Exception("Path could not be retrieved", ex, GetType(), path);
Log.Exception("Path could not be retrieved " + path, ex, GetType(), path);
Marshal.ReleaseComObject(link);
return string.Empty;
}
catch (System.Exception ex)
{
Log.Exception("Exception loading path " + path, ex, GetType(), path);
Marshal.ReleaseComObject(link);
return string.Empty;
}

Expand Down

0 comments on commit 8a2d474

Please sign in to comment.