本文整理汇总了C++中atl::CRegKey::EnumKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CRegKey::EnumKey方法的具体用法?C++ CRegKey::EnumKey怎么用?C++ CRegKey::EnumKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atl::CRegKey
的用法示例。
在下文中一共展示了CRegKey::EnumKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadMessageFilter
/// Loads a list of message IDs that should be passed on to the AOIA application
void LoadMessageFilter(HKEY hKeyParent, LPCTSTR lpszKeyName)
{
g_messageFilter.empty();
ATL::CRegKey reg;
if (reg.Open(hKeyParent, lpszKeyName, KEY_READ) == ERROR_SUCCESS)
{
TCHAR subkey[256];
DWORD skLength = 256;
DWORD dw;
int index = 0;
while (true)
{
if (reg.EnumKey(index, subkey, &skLength) == ERROR_SUCCESS)
{
index++;
if (reg.QueryDWORDValue(subkey, dw) == ERROR_SUCCESS)
{
g_messageFilter.insert(dw);
}
}
else
{
break;
}
}
}
else
{
LOG("Unable to open key: " << lpszKeyName)
}
}
示例2: OnBnClickedButtonReload
void CFileTypesForm::OnBnClickedButtonReload()
{
for (DWORD i=0; i<pageCount; i++)
{
if (pages[i])
{
pages[i]->info.Clear();
pages[i]->UpdateTree();
}
}
DSUtil::FilterTemplates filters;
filters.EnumerateAllRegisteredFilters();
// search for registered protocols
if (page_protocols)
{
ATL::CRegKey rkRoot(HKEY_CLASSES_ROOT);
// only real protocols => not something like "WMP11.AssocProtocol.MMS"
// faster, because i don't need to search in every entry for "Source Filter"
TCHAR szName[10] = {0};
DWORD szNameLength = 10;
DWORD i = 0;
long ret = 0;
while (ERROR_NO_MORE_ITEMS != (ret = rkRoot.EnumKey(i++, szName, &szNameLength)))
{
if (ret != ERROR_SUCCESS)
continue;
CRegKey rkKey;
if(ERROR_SUCCESS == rkKey.Open(HKEY_CLASSES_ROOT, szName, KEY_READ))
{
TCHAR szSourceFilterGuid[40] = {0};
DWORD szLength = 40;
if (ERROR_SUCCESS == rkKey.QueryStringValue(_T("Source Filter"), szSourceFilterGuid, &szLength))
{
GraphStudio::PropItem* group = new GraphStudio::PropItem(CString(szName));
CString strClsid = szSourceFilterGuid;
GUID clsid = {0};
CLSIDFromString((LPOLESTR)strClsid.GetBuffer(), &clsid);
group->AddItem(new GraphStudio::PropItem(_T("CLSID"), CString(szSourceFilterGuid), false));
DSUtil::FilterTemplate ft;
if (filters.FindTemplateByCLSID(clsid, &ft))
{
group->AddItem(new GraphStudio::PropItem(_T("Name"), CString(ft.name), false));
group->AddItem(new GraphStudio::PropItem(_T("File"), CString(ft.file), false));
}
// last Change of this key
FILETIME timeMod = {0};
if (ERROR_SUCCESS == RegQueryInfoKey(rkKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &timeMod))
group->AddItem(new GraphStudio::PropItem(_T("Modified"), CTime(timeMod)));
page_protocols->info.AddItem(group);
}
}
rkKey.Close();
szNameLength = 10;
}
page_protocols->UpdateTree();
rkRoot.Close();
}
// search for registered extensions
if (page_extensions)
{
ATL::CRegKey rkRoot;
CString strRoot = _T("Media Type\\Extensions");
if (ERROR_SUCCESS == rkRoot.Open(HKEY_CLASSES_ROOT, strRoot, KEY_READ))
{
// {7DF62B50-6843-11D2-9EEB-006008039E37}
static const GUID CLSID_StillVideo = {0x7DF62B50, 0x6843, 0x11D2, { 0x9E, 0xEB, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37} };
TCHAR szName[50] = {0};
DWORD szNameLength = 50;
DWORD i = 0;
while (ERROR_NO_MORE_ITEMS != rkRoot.EnumKey(i++, szName, &szNameLength))
{
CString strKey = strRoot;
strKey.Append(_T("\\"));
strKey.Append(szName);
CRegKey rkKey;
if(ERROR_SUCCESS == rkKey.Open(HKEY_CLASSES_ROOT, strKey, KEY_READ))
{
GraphStudio::PropItem* group = new GraphStudio::PropItem(CString(szName));
TCHAR szGuid[40] = {0};
DWORD szLength = 40;
if (ERROR_SUCCESS == rkKey.QueryStringValue(_T("Source Filter"), szGuid, &szLength))
{
CString strClsid = szGuid;
GUID clsid = {0};
CLSIDFromString((LPOLESTR)strClsid.GetBuffer(), &clsid);
group->AddItem(new GraphStudio::PropItem(_T("CLSID"), CString(szGuid), false));
DSUtil::FilterTemplate ft;
if (filters.FindTemplateByCLSID(clsid, &ft))
//.........这里部分代码省略.........