HRESULT hr = m_pKeyDevice->SetCooperativeLevel(...);
if (hr == DI_OK) {
...
}
else if (hrr == ...) { ... }