public static void checkRC(HRESULT hr) {
   if (FAILED(hr)) {
     throw new COMException(hr.toString());
   }
 }