blob: dd6e9368d6354e3495f1bd74c59a372b1b28e9eb [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
bungeman@google.com9df621d2011-06-23 21:43:52 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.com9df621d2011-06-23 21:43:52 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
bungeman@google.com9df621d2011-06-23 21:43:52 +000010#define WIN32_LEAN_AND_MEAN
11#include <Windows.h>
12#include <ole2.h>
13#include "SkAutoCoInitialize.h"
14
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000015SkAutoCoInitialize::SkAutoCoInitialize() :
bungeman@google.com9df621d2011-06-23 21:43:52 +000016 fHR(
17 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
18 )
19{ }
20
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000021SkAutoCoInitialize::~SkAutoCoInitialize() {
bungeman@google.com9df621d2011-06-23 21:43:52 +000022 if (SUCCEEDED(this->fHR)) {
23 CoUninitialize();
24 }
25}
26
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000027bool SkAutoCoInitialize::succeeded() {
28 return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR;
29}