mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user