[PTRun]Fix locking link files for MSI installers. Warning 1946 (#37654)

* [Runner] fix MSI installer issue. Warning 1946

* Fix catching exceptions

* Better error handling

* Revert "Better error handling"

This reverts commit 0f3ec2a3ef.
This commit is contained in:
Laszlo Nemeth
2025-02-27 20:17:43 +01:00
committed by GitHub
parent bf2685757a
commit 8a2d4745fa

View File

@@ -136,13 +136,25 @@ namespace Wox.Infrastructure
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;
}