当前位置: 首页>>代码示例>>C++>>正文


C++ CRegKey::QueryMultiStringValue方法代码示例

本文整理汇总了C++中atl::CRegKey::QueryMultiStringValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CRegKey::QueryMultiStringValue方法的具体用法?C++ CRegKey::QueryMultiStringValue怎么用?C++ CRegKey::QueryMultiStringValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在atl::CRegKey的用法示例。


在下文中一共展示了CRegKey::QueryMultiStringValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetStringArrayFromRegistry

BOOL CNTEventLogSource::GetStringArrayFromRegistry(ATL::CRegKey& key, LPCTSTR lpszEntry, CNTServiceStringArray& array, DWORD* pLastError)
{
  //Validate our parameters
  ATLASSERT(lpszEntry != NULL);

  //What will be the return value from this function, assume the worst
  BOOL bSuccess = FALSE;

  //Empty the array before we go any further
#ifdef CNTSERVICE_MFC_EXTENSIONS
  array.RemoveAll();
#else
  array.clear();
#endif

  DWORD dwType = 0;
  ULONG nBytes = 0;
  LONG lResult = key.QueryValue(lpszEntry, &dwType, NULL, &nBytes);
  if (lResult == ERROR_SUCCESS)
  {
    //Allocate some memory for the API
    ATL::CHeapPtr<TCHAR> lpBuffer;
    ULONG nChars = nBytes / sizeof(TCHAR);
    if (nChars < 2) //Ensure we can handle an empty MULTI_SZ string
      nChars = 2;
    if (!lpBuffer.Allocate(nChars))
    {
      SetLastError(ERROR_OUTOFMEMORY);
      if (pLastError)
        *pLastError = ERROR_OUTOFMEMORY;
      return FALSE;
    }

    lResult = key.QueryMultiStringValue(lpszEntry, lpBuffer, &nChars);      
    if (lResult == ERROR_SUCCESS)
    {
      LPTSTR lpszStrings = lpBuffer.m_pData;
      while (lpszStrings[0] != 0)
      {
      #ifdef CNTSERVICE_MFC_EXTENSIONS
        array.Add(lpszStrings);
      #else
        array.push_back(lpszStrings);
      #endif
        lpszStrings += (_tcslen(lpszStrings) + 1);
      }

      bSuccess = TRUE;
    }
    else
    {
      if (pLastError)
        *pLastError = lResult;
    }
  }
  else
  {
    if (pLastError)
      *pLastError = lResult;
  }

  return bSuccess;
}
开发者ID:CruiseYoung,项目名称:CNTService_NoMFC,代码行数:63,代码来源:ntservEventLogSource.cpp


注:本文中的atl::CRegKey::QueryMultiStringValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。