180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2011 Google Inc.
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define WIN32_LEAN_AND_MEAN
11910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger#include <windows.h>
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include <ole2.h>
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkAutoCoInitialize.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkAutoCoInitialize::SkAutoCoInitialize() :
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fHR(
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    )
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru{ }
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkAutoCoInitialize::~SkAutoCoInitialize() {
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    if (SUCCEEDED(this->fHR)) {
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        CoUninitialize();
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querubool SkAutoCoInitialize::succeeded() {
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR;
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
30