Helper class for exception-safe scope-based CoInitialize/CoUninitialize calls.
| 165 | // CoInitialize/CoUninitialize calls. |
| 166 | // |
| 167 | class CComScopedInit |
| 168 | { |
| 169 | public: |
| 170 | |
| 171 | CComScopedInit() |
| 172 | { |
| 173 | HRESULT hr = ::CoInitialize(NULL); |
| 174 | if (FAILED(hr)) |
| 175 | AtlThrow(hr); |
| 176 | } |
| 177 | |
| 178 | ~CComScopedInit() |
| 179 | { |
| 180 | ::CoUninitialize(); |
| 181 | } |
| 182 | |
| 183 | |
| 184 | // Ban copy |
| 185 | private: |
| 186 | CComScopedInit(const CComScopedInit&); |
| 187 | CComScopedInit& operator=(const CComScopedInit&); |
| 188 | }; |
| 189 | |
| 190 | |
| 191 | // |
nothing calls this directly
no outgoing calls
no test coverage detected