Skip to content

Commit

Permalink
Handle case when TaskBarList could not be created (AvaloniaUI#15852)
Browse files Browse the repository at this point in the history
* Handle case when TaskBarList could not be created

* Use HRESULT.S_OK for better clarity
  • Loading branch information
mojoe-playground authored May 30, 2024
1 parent 861c0e4 commit 0063a5e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Windows/Avalonia.Win32/Interop/TaskBarList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ private static unsafe IntPtr Init()
{
int result = CoCreateInstance(in ShellIds.TaskBarList, IntPtr.Zero, 1, in ShellIds.ITaskBarList2, out IntPtr instance);

if (result != (int)HRESULT.S_OK)
{
return IntPtr.Zero;
}

var ptr = (ITaskBarList3VTable**)instance.ToPointer();

s_hrInitDelegate ??= Marshal.GetDelegateForFunctionPointer<HrInit>((*ptr)->HrInit);
Expand Down

0 comments on commit 0063a5e

Please sign in to comment.