Browse Source
Merge pull request #1583 from zii-dmg/better-oleinitialize
OleInitialize checks already inited case and throws Win32Exception
pull/1519/merge
Jeremy Koritzinsky
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
2 deletions
-
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() |
|
|
|
|