本文整理汇总了C++中atl::CRegKey::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ CRegKey::Attach方法的具体用法?C++ CRegKey::Attach怎么用?C++ CRegKey::Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atl::CRegKey
的用法示例。
在下文中一共展示了CRegKey::Attach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AfxGetApp
CMainWizard::CMainWizard(CWnd* pOwnerWnd):
CCustomPropSheet(AFX_IDS_APP_TITLE, pOwnerWnd)
{
CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
ASSERT_VALID(pApp);
// assign CRT locale
static const TCHAR szDefLocale[] = _T("English_USA.1252");
_tsetlocale(LC_ALL, pApp->GetProfileString(SZ_REGK_LOCALE, SZ_REGV_LOCALE_LC_ALL, szDefLocale));
// load dialog's icons
m_hIcon = pApp->LoadIcon(IDI_APP_ICON);
m_hSmIcon = pApp->LoadSmIcon(MAKEINTRESOURCE(IDI_APP_ICON));
static HYPERLINKCOLORS linkColors =
{
RGB(0, 0, 255), // default
RGB(0, 0, 255), // active
RGB(0, 0, 255), // visited
RGB(255, 0, 0) // hover
};
CHyperLink::SetColors(linkColors);
ATL::CRegKey regKeyLangs;
regKeyLangs.Attach(pApp->GetSectionKey(SZ_REGK_LANGUAGES));
int nError = ERROR_SUCCESS;
if (static_cast<HKEY>(regKeyLangs) != NULL)
{
TCHAR szLangNames[128] = { 0 };
ULONG cchNamesMax = _countof(szLangNames);
nError = regKeyLangs.QueryStringValue(NULL, szLangNames, &cchNamesMax);
if (nError == ERROR_SUCCESS)
{
LPCTSTR pszSeps = _T(",;\x20");
LPTSTR pszCurLex = _tcstok(szLangNames, pszSeps);
while (pszCurLex != NULL)
{
m_arrLangNames.Add(pszCurLex);
pszCurLex = _tcstok(NULL, pszSeps);
}
}
::RegCloseKey(regKeyLangs.Detach());
}
g_fRestartInterface = false;
AddPage(&m_pageAbout);
AddPage(&m_pageFirstLaunch);
AddPage(&m_pageOptions);
AddPage(&m_pageFiles);
AddPage(&m_pageAction);
AddPage(&m_pageProgress);
SetWizardMode();
}
示例2: OnLanguageChange
void CMainWizard::OnLanguageChange(UINT uMenuID)
{
CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
ASSERT_VALID(pApp);
ATL::CRegKey regKeyLangs;
regKeyLangs.Attach(pApp->GetSectionKey(SZ_REGK_LANGUAGES));
int nError = ERROR_SUCCESS;
if (static_cast<HKEY>(regKeyLangs) != NULL)
{
UINT iLangName = uMenuID - ((ID_LANGUAGE_ENGLISH & 0x00F0) >> 4);
nError = regKeyLangs.SetStringValue(SZ_REGV_LANGUAGES_CURRENT, m_arrLangNames[iLangName]);
if (nError == ERROR_SUCCESS)
{
CheckLangMenuItem(iLangName);
regKeyLangs.Flush();
g_fRestartInterface = true;
PostMessage(PSM_PRESSBUTTON, PSBTN_CANCEL, 0);
}
::RegCloseKey(regKeyLangs.Detach());
}
示例3: QueryUsingSetupAPI
BOOL ComPortDiscovery::QueryUsingSetupAPI(const GUID& guid, WORD dwFlags, CPortsArray& ports, CNamesArray& friendlyNames)
{
//Set our output parameters to sane defaults
ports.clear();
friendlyNames.clear();
//Create a "device information set" for the specified GUID
HDEVINFO hDevInfoSet = SetupDiGetClassDevs(&guid, NULL, NULL, dwFlags);
if (hDevInfoSet == INVALID_HANDLE_VALUE)
return FALSE;
//Finally do the enumeration
BOOL bMoreItems = TRUE;
int nIndex = 0;
SP_DEVINFO_DATA devInfo;
while (bMoreItems)
{
//Enumerate the current device
devInfo.cbSize = sizeof(SP_DEVINFO_DATA);
bMoreItems = SetupDiEnumDeviceInfo(hDevInfoSet, nIndex, &devInfo);
if (bMoreItems)
{
//Did we find a serial port for this device
BOOL bAdded = FALSE;
//Get the registry key which stores the ports settings
ATL::CRegKey deviceKey;
deviceKey.Attach(SetupDiOpenDevRegKey(hDevInfoSet, &devInfo, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE));
if (deviceKey != INVALID_HANDLE_VALUE)
{
int nPort = 0;
if (QueryRegistryPortName(deviceKey, nPort))
{
ports.push_back(nPort);
bAdded = TRUE;
}
}
//If the port was a serial port, then also try to get its friendly name
if (bAdded)
{
ATL::CHeapPtr<BYTE> byFriendlyName;
if (QueryDeviceDescription(hDevInfoSet, devInfo, byFriendlyName))
{
friendlyNames.push_back(reinterpret_cast<LPCTSTR>(byFriendlyName.m_pData));
}
else
{
friendlyNames.push_back(_T(""));
}
}
}
++nIndex;
}
//Free up the "device information set" now that we are finished with it
SetupDiDestroyDeviceInfoList(hDevInfoSet);
//Return the success indicator
return TRUE;
}