enhance lnk program exception handling

This commit is contained in:
bao-qian
2016-11-29 01:55:25 +00:00
parent 6b640ea55e
commit c56e4557f9
2 changed files with 37 additions and 17 deletions

View File

@@ -61,9 +61,9 @@ namespace Wox.Plugin.Program.Programs
IStream stream;
const uint noAttribute = 0x80;
const Stgm exclusiveRead = Stgm.Read | Stgm.ShareExclusive;
var result = SHCreateStreamOnFileEx(path, exclusiveRead, noAttribute, false, null, out stream);
var hResult = SHCreateStreamOnFileEx(path, exclusiveRead, noAttribute, false, null, out stream);
if (result == Hresult.Ok)
if (hResult == Hresult.Ok)
{
var reader = appxFactory.CreateManifestReader(stream);
var manifestApps = reader.GetApplications();
@@ -81,6 +81,12 @@ namespace Wox.Plugin.Program.Programs
}
Apps = apps.Where(a => a.AppListEntry != "none").ToArray();
}
else
{
Log.Error($"SHCreateStreamOnFileEx on path: <{path}> failed, HResult error code: {hResult}. Package location: <{Location}>.");
var exception = Marshal.GetExceptionForHR((int)hResult);
Log.Exception(exception);
}
}