static void SetKey(char* Key, int len) { memset(deskey, 0, 16); memcpy(deskey, Key, len>16?16:len); SetSubKey(&SubKey[0], &deskey[0]); if (len>8) { SetSubKey(&SubKey[1], &deskey[8]); Is3DES = TRUE; } else Is3DES = FALSE; }
BOOL CRegMgr::Init(const char* sCompany, const char* sApp, const char* sVersion, const char* sSubKey, HANDLE hRootKey, char* sRoot2) { strcpy(m_sApp,sApp); if (sSubKey != NULL) strcpy(m_sSubKey,sSubKey); else m_sSubKey[0] = '\0'; m_hRootKey = (HKEY)hRootKey; char sSoftware[] = "Software"; char* pSoftware; if (sRoot2 == NULL) pSoftware = sSoftware; else pSoftware = sRoot2; if (CreateKey(m_hRootKey, pSoftware, m_hSoftwareKey)) { if (CreateKey(m_hSoftwareKey, sCompany, m_hCompanyKey)) { if (CreateKey(m_hCompanyKey, sApp, m_hAppKey)) { if (CreateKey(m_hAppKey, sVersion, m_hVersionKey)) { m_bInitialized = TRUE; if (SetSubKey(sSubKey)) { return TRUE; } else { m_bInitialized = FALSE; return FALSE; } } else return FALSE; } else return FALSE; } else return FALSE; } else return FALSE; }