⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queryint.cpp

📁 VC++串口通信设。本书详细说明讲解了在VC++环境下编写串口通信得过程。值得一看
💻 CPP
字号:
//... IUnknown interface pointer is in variable pIUnknown ...

HRESULT hResult = E_FAIL;
IChihuahua *pIChihuahua = NULL;

// Query the component抯 IChihuahua interface
hResult = pIUnknown->QueryInterface(IID_IChihuahua,
                                    (void**) &pIChihuahua);

// Were we successful?
if (FAILED(hResult)) 
{

   // Determine what went wrong
   switch (hResult) 
   {

      // Does the component even support this interface?
      case E_NOINTERFACE:
         cout << "Component does not expose IChihuahua.\n";
         break;

      // Has COM been initialized for this thread
      case CO_E_NOTINITIALIZED:
         cout << "COM not initialized.\n";
         break;

      // Has the component run out of memory?
      case E_OUTOFMEMORY:
         cout << "Out of memory!\n";
         break;

      // Some other error
      default:
         cout << "Unrecognized error.\n";
   }

   return hResult;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -