本文整理汇总了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;
}