本文整理汇总了C++中atl::CRegKey::QueryValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CRegKey::QueryValue方法的具体用法?C++ CRegKey::QueryValue怎么用?C++ CRegKey::QueryValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atl::CRegKey
的用法示例。
在下文中一共展示了CRegKey::QueryValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: GenerateErrorReport
void CCrashHandler::GenerateErrorReport(PEXCEPTION_POINTERS pExInfo)
{
CExceptionReport rpt(pExInfo);
CMainDlg mainDlg;
CZLib zlib;
CString sTempFileName = CUtility::getTempFileName();
unsigned int i;
// let client add application specific files to report
if (m_lpfnCallback && !m_lpfnCallback(this))
return;
//Определеяем, что делать с отчетом
DumpType dumpType = Referenced;//По умолчанию сбрасываем только ту память, на которую идут ссылки в стеке
ActionType actionType = GUI;//По умолчанию - выводим пользователю диалог
CString action, storeFolder, dump;
ATL::CRegKey rk;
//Читаем из ключа с именем приложения
int32_t lRet = rk.Open(HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\Cognitive Technologies Ltd.\\CuneiForm\\PumaCrashRpt\\")
+ CUtility::getAppName(), KEY_QUERY_VALUE);
if(lRet != ERROR_SUCCESS)
{
//Читаем из дефолтного ключа
lRet = rk.Open(HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\Cognitive Technologies Ltd.\\CuneiForm\\PumaCrashRpt\\Default"),
KEY_QUERY_VALUE);
}
if(lRet == ERROR_SUCCESS)
{
//Читаем дейтсвие
uint32_t dwBufLen = 1000;
rk.QueryValue(action.GetBuffer(1000), "Action", &dwBufLen);
action.ReleaseBuffer(MAX(dwBufLen - 1, 0));
//Читаем папку для автосохранения
dwBufLen = 1000;
rk.QueryValue(storeFolder.GetBuffer(1000), "StoreFolder", &dwBufLen);
storeFolder.ReleaseBuffer(MAX(dwBufLen - 1, 0));
//Читаем тип дампа
dwBufLen = 1000;
rk.QueryValue(dump.GetBuffer(1000), "DumpType", &dwBufLen);
dump.ReleaseBuffer(MAX(dwBufLen - 1, 0));
rk.Close();
if (!action.IsEmpty())
{
if (action.CompareNoCase("GUI") == 0)
actionType = GUI;
else if (action.CompareNoCase("QuietStore") == 0)
actionType = QuietStore;
else if (action.CompareNoCase("NoAction") == 0)
actionType = NoAction;
}
if (!dump.IsEmpty())
{
if (dump.CompareNoCase("Mini") == 0)
dumpType = Mini;
else if (dump.CompareNoCase("Referenced") == 0)
dumpType = Referenced;
else if (dump.CompareNoCase("Full") == 0)
dumpType = Full;
}
if (storeFolder.CompareNoCase("Temp folder") == 0)
storeFolder = getenv("TEMP");
}
if (actionType == NoAction)
return;
// add crash files to report
m_files[rpt.getCrashFile(dumpType)] = CString((const char *)IDS_CRASH_DUMP);
m_files[rpt.getCrashLog()] = CString((const char *)IDS_CRASH_LOG);
// add symbol files to report
for (i = 0; i < (uint)rpt.getNumSymbolFiles(); i++)
m_files[(const char *)rpt.getSymbolFile(i)] =
CString((const char *)IDS_SYMBOL_FILE);
// zip the report
if (!zlib.Open(sTempFileName))
return;
// add report files to zip
TStrStrMap::iterator cur = m_files.begin();
for (i = 0; i < m_files.size(); i++, cur++)
zlib.AddFile((*cur).first);
zlib.Close();
if (actionType == GUI)
{
// display main dialog
mainDlg.m_pUDFiles = &m_files;
//.........这里部分代码省略.........