epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 10 | #define WIN32_LEAN_AND_MEAN |
| 11 | #include <Windows.h> |
| 12 | #include <ole2.h> |
| 13 | #include "SkAutoCoInitialize.h" |
| 14 | |
bungeman@google.com | 2e2f3f5 | 2011-09-16 15:37:20 +0000 | [diff] [blame^] | 15 | SkAutoCoInitialize::SkAutoCoInitialize() : |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 16 | fHR( |
| 17 | CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE) |
| 18 | ) |
| 19 | { } |
| 20 | |
bungeman@google.com | 2e2f3f5 | 2011-09-16 15:37:20 +0000 | [diff] [blame^] | 21 | SkAutoCoInitialize::~SkAutoCoInitialize() { |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 22 | if (SUCCEEDED(this->fHR)) { |
| 23 | CoUninitialize(); |
| 24 | } |
| 25 | } |
| 26 | |
bungeman@google.com | 2e2f3f5 | 2011-09-16 15:37:20 +0000 | [diff] [blame^] | 27 | bool SkAutoCoInitialize::succeeded() { |
| 28 | return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR; |
| 29 | } |