mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Catch exceptions and release com objects
This commit is contained in:
parent
3e32fca356
commit
b062fc056f
1 changed files with 17 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
|
||||
|
|
@ -25,12 +26,22 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
PWSTR displayName;
|
||||
shellItem.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_NORMALDISPLAY, &displayName);
|
||||
string filename = displayName.ToString();
|
||||
PInvoke.CoTaskMemFree(displayName);
|
||||
|
||||
return filename;
|
||||
try
|
||||
{
|
||||
PWSTR displayName;
|
||||
shellItem.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_NORMALDISPLAY, &displayName);
|
||||
string filename = displayName.ToString();
|
||||
PInvoke.CoTaskMemFree(displayName);
|
||||
return filename;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ReleaseComObject(shellItem);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue