Browse Source

OleInitialize checks already inited case and throws Win32Exception

pull/1583/head
zii-dmg 8 years ago
parent
commit
c2005c8702
  1. 8
      src/Windows/Avalonia.Win32/OleContext.cs

8
src/Windows/Avalonia.Win32/OleContext.cs

@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Threading;
using Avalonia.Platform;
using Avalonia.Threading;
@ -26,8 +27,11 @@ namespace Avalonia.Win32
private OleContext()
{
if (UnmanagedMethods.OleInitialize(IntPtr.Zero) != UnmanagedMethods.HRESULT.S_OK)
throw new SystemException("Failed to initialize OLE");
UnmanagedMethods.HRESULT res = UnmanagedMethods.OleInitialize(IntPtr.Zero);
if (res != UnmanagedMethods.HRESULT.S_OK &&
res != UnmanagedMethods.HRESULT.S_FALSE /*already initialized*/)
throw new Win32Exception((int)res, "Failed to initialize OLE");
}
private static bool IsValidOleThread()

Loading…
Cancel
Save