Exemplo n.º 1
0
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
    LPCTSTR valueName, bool value) const
{
  NRegistry::CKey regKey;
  CreateRegKey(parentKey, keyName, regKey);
  regKey.SetValue(valueName, value);
}
Exemplo n.º 2
0
static BOOL RegisterServer(CLSID clsid, LPCWSTR title)
{
  TCHAR clsidString[MAX_PATH];
  if (!GetStringFromIID(clsid, clsidString, MAX_PATH))
    return FALSE;
  
  UString modulePath;
  if (!NDLL::MyGetModuleFileName(g_hInstance, modulePath))
    return FALSE;
  
  CRegItem clsidEntries[] =
  {
    HKEY_CLASSES_ROOT, kClsidMask,        NULL,              title,
    HKEY_CLASSES_ROOT, kClsidInprocMask,  NULL,              modulePath,
    HKEY_CLASSES_ROOT, kClsidInprocMask,  L"ThreadingModel", L"Apartment",
    NULL,              NULL,              NULL,              NULL
  };
  
  //register the CLSID entries
  for(int i = 0; clsidEntries[i].hRootKey; i++)
  {
    TCHAR subKey[MAX_PATH];
    wsprintf(subKey, clsidEntries[i].SubKey, clsidString);
    NRegistry::CKey key;
    if (key.Create(clsidEntries[i].hRootKey, subKey, NULL,
        REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
      return FALSE;
    key.SetValue(clsidEntries[i].ValueName, clsidEntries[i].Data);
  }
 
  if(IsItWindowsNT())
  {
    NRegistry::CKey key;
    if (key.Create(HKEY_LOCAL_MACHINE, kApprovedKeyPath, NULL,
        REG_OPTION_NON_VOLATILE, KEY_WRITE) == NOERROR)
      key.SetValue(GetUnicodeString(clsidString), title);
  }
  return TRUE;
}