BOOL CRegKey::DeleteKey(HKEY hKey,LPCWSTR szKey)
{
	if (!IsUnicodeSystem())
		return DeleteKey(hKey,W2A(szKey));

	HKEY hSubKey;
	FILETIME ft;
	DWORD cb;
	WCHAR szSubKey[200];
	if (RegOpenKeyExW(hKey,szKey,0,
		KEY_ENUMERATE_SUB_KEYS|KEY_SET_VALUE,&hSubKey)!=ERROR_SUCCESS)
		return TRUE;	
	DebugOpenHandle(dhtRegKey,hSubKey,szKey);
	
	for(;;)
	{
		cb=400;
		if (RegEnumKeyExW(hSubKey,0,szSubKey,&cb,NULL,
			NULL,NULL,&ft)==ERROR_NO_MORE_ITEMS)
			break;
		DeleteKey(hSubKey,szSubKey);
	}
	RegCloseKey(hSubKey);
	DebugCloseHandle(dhtRegKey,hSubKey,szKey);
	RegDeleteKeyW(hKey,szKey);
	return TRUE;
}
Exemple #2
0
/* static public */
HRESULT REGUTIL::UnregisterCOMClass( REFCLSID rclsid,		   
									 const char *szProgIDPrefix,
									 int iVersion,			  
									 const char *szClassProgID )
{
	char szID[64];		   // the class ID to unregister.
	char rcCLSID[64];	   // CLSID\\szID.
	OLECHAR	szWID[64];	   // helper for the class ID to unregister.
	char rcProgID[128];	   // szProgIDPrefix.szClassProgID
	char rcIndProgID[128]; // rcProgID.iVersion


	// format the prog ID values.
	sprintf( rcProgID, "%s.%s", szProgIDPrefix, szClassProgID );
	sprintf( rcIndProgID, "%s.%d", rcProgID, iVersion );

	REGUTIL::_UnregisterClassBase( rclsid, rcProgID, rcIndProgID, rcCLSID );
	DeleteKey( rcCLSID, "InprocServer32" );

    StringFromGUID2(rclsid, szWID, NumItems( szWID ) );
	WideCharToMultiByte( CP_ACP, 
						 0, 
						 szWID, 
						 -1, 
						 szID, 
						 sizeof( szID ), 
						 NULL, 
						 NULL );

	DeleteKey( "CLSID", rcCLSID );
	
	
	return S_OK;

} // REGUTIL::UnregisterCOMClass
Exemple #3
0
//
// Remove the component from the registry.
//
HRESULT UnregisterServer(const CLSID& clsid,      // Class ID
                      const char* szProgID,       //   IDs
                      const char* szVerIndProgID) // Programmatic
{
	// Convert the CLSID into a char.
	char szCLSID[CLSID_STRING_SIZE] ;
	CLSIDtoString(clsid, szCLSID, sizeof(szCLSID)) ;

	// Build the key CLSID\\{...}
	char szKey[64] ;
	strcpy(szKey, "CLSID\\") ;
	strcat(szKey, szCLSID) ;

	// Delete the CLSID Key - CLSID\{...}
	LONG lResult = DeleteKey(HKEY_CLASSES_ROOT, szKey) ;

	// Delete the version-independent ProgID Key.
	if (szVerIndProgID != NULL)
		lResult = DeleteKey(HKEY_CLASSES_ROOT, szVerIndProgID) ;

	// Delete the ProgID key.
	if (szProgID != NULL)
		lResult = DeleteKey(HKEY_CLASSES_ROOT, szProgID) ;

	return S_OK ;
}
Exemple #4
0
void IniFile::DeleteSection ( wchar_t *section)
{
	// deletes a whole INI section in the dictionary

	int length;
	int i;
	wchar_t key[256];

	if (section == NULL)
		section = INIFile_default_section; // if no section was provided, use empty section name

	swprintf (key, 256, L"%s%c", section, INI_SECTION_SEPARATOR); // compose the key
	length = (int) wcslen (key); // get the key string length

	// for each entry in the dictionary...
	for (i = 0; i < Dictionary->entry_count; i++)
	{
		if (Dictionary->entries[i].key[0] == 0)
			continue; // skip empty slots

		// does this entry belong to the section we want ?
		if (wcsncmp (Dictionary->entries[i].key, key, length) == 0)
			DeleteKey ( Dictionary->entries[i].key); // yes, delete it
	}

	DeleteKey ( section); // and finally delete the section name itself
	return;
}
/*
===============
DelProp

===============
*/
void DelProp(void)
{
	char	sz[4096];

	if (edit_entity == NULL)
		return;

	// Get current selection text

	SendMessage(hwndEnt[EntKeyField], WM_GETTEXT, sizeof(sz)-1, (LPARAM)sz);	

	if (multiple_entities)
	{
		brush_t	*b;

		for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
			DeleteKey(b->owner, sz);
	}
	else
		DeleteKey(edit_entity, sz);

	// refresh the prop listbox

	SetKeyValuePairs();	
}
/*
	subKey を指定した場合は subkey を含むキー以下を削除
	subkey が NULL の場合、カレント の配下を削除
*/
BOOL TRegistry::DeleteChildTree(LPSTR subKey)
{
	char	buf[100];
	BOOL	ret = TRUE;

	if (subKey != NULL && OpenKey(subKey) != TRUE)
		return	FALSE;

	while (EnumKey(0, buf, sizeof(buf)))
	{
		if ((ret = DeleteChildTree(buf)) != TRUE)
			break;
	}
	if (subKey != NULL)
	{
		CloseKey();
		ret = DeleteKey(subKey) ? ret : FALSE;
	}
	else {
		while (EnumValue(0, buf, sizeof(buf)))
		{
			if (DeleteValue(buf) != TRUE)
			{
				ret = FALSE;
				break;
			}
		}
	}
	return	ret;
}
Exemple #7
0
void Select_ClearAllRecursionProtection(void)
{
	for (entity_t* pEnt=entities.next ; pEnt != &entities ; pEnt=pEnt->next)
	{
		DeleteKey(pEnt, sKEY_WAYPOINTHIDE_RECURSION_PROTECT);		
	}
}
Exemple #8
0
void CRegistry::DeleteKey(HKEY hParent, LPCTSTR pszKey)
{
	HKEY hKey;
	if ( RegOpenKeyEx( hParent, pszKey, 0, KEY_ALL_ACCESS, &hKey ) ) return;

	CArray< CString > pList;

	for ( DWORD nIndex = 0 ; ; nIndex++ )
	{
		DWORD dwName = 64;	// Input parameter in TCHARs
		TCHAR szName[64];

		LRESULT lResult = RegEnumKeyEx( hKey, nIndex, szName, &dwName, NULL, NULL, 0, NULL );
		if ( lResult != ERROR_SUCCESS ) break;

		szName[ dwName ] = 0;
		pList.Add( szName );
		DeleteKey( hKey, szName );
	}

	for ( int nItem = pList.GetSize() - 1 ; nItem >= 0 ; nItem-- )
	{
		RegDeleteKey( hKey, pList.GetAt( nItem ) );
	}

	if ( lstrlen( pszKey ) > 25 )	// Handle likely initial non-recursive value
		RegDeleteKey( HKEY_CURRENT_USER, pszKey );

	RegCloseKey( hKey );
}
Exemple #9
0
void IniFile::DeleteEntry ( wchar_t *section, wchar_t *entry)
{
	// deletes an entry in the dictionary

	int length;
	int i;
	wchar_t key[256];

	if (section == NULL)
		section = INIFile_default_section; // if no section was provided, use empty section name

	// if we were given an entry, build a key as section#entry
	if (entry != NULL)
	{
		swprintf (key, 256, L"%s%c%s", section, INI_SECTION_SEPARATOR, entry); // compose the key

		i = (int) wcslen (key); // get the key string length
		if (i < sizeof (key))
			length = i;
		else
			length = sizeof (key) - 1; // clamp it to a max value

		// for each character in the string after the section separator...
		for (i = (int) wcslen (section) + 1; i < length; i++)
			key[i] = towlower (key[i]); // convert it to lowercase
		key[i] = 0; // terminate the string
	}

	// else it must be a section name
	else
		wcscpy_s (key, 256, section); // copy the name into the key

	DeleteKey ( key);
	return;
}
Exemple #10
0
void KeyedArchive::SetMatrix4(const String & key, const Matrix4 &value)
{
    DeleteKey(key);
	VariantType *variantValue = new VariantType();
	variantValue->SetMatrix4(value);
	objectMap[key] = variantValue;
}
Exemple #11
0
void KeyedArchive::SetByteArray(const String & key, const uint8 * value, int32 arraySize)
{
    DeleteKey(key);
	VariantType *variantValue = new VariantType();
	variantValue->SetByteArray(value, arraySize);
	objectMap[key] = variantValue;
}
Exemple #12
0
void KeyedArchive::SetFloat(const String & key, float32 value)
{
    DeleteKey(key);
	VariantType *variantValue = new VariantType();
	variantValue->SetFloat(value);
	objectMap[key] = variantValue;
}
Exemple #13
0
void KeyedArchive::SetArchive(const String & key, KeyedArchive * archive)
{
    DeleteKey(key);
	VariantType *variantValue = new VariantType();
	variantValue->SetKeyedArchive(archive);
	objectMap[key] = variantValue;
}
Exemple #14
0
int main (void)
{
	printf ("Hello World\n");
	OpenIniFile ("Test.Ini");
#ifdef INIFILE_TEST_READ_AND_WRITE
	WriteString  ("Test", "Name", "Value");
	WriteString  ("Test", "Name", "OverWrittenValue");
	WriteString  ("Test", "Port", "COM1");
	WriteString  ("Test", "User", "James Brown jr.");
	WriteString  ("Configuration", "eDriver", "MBM2.VXD");
	WriteString  ("Configuration", "Wrap", "LPT.VXD");
	WriteInt 	 ("IO-Port", "Com", 2);
	WriteBool 	 ("IO-Port", "IsValid", 0);
	WriteDouble  ("TheMoney", "TheMoney", 67892.00241);
	WriteInt     ("Test"    , "ToDelete", 1234);
	WriteIniFile ("Test.Ini");
	printf ("Key ToDelete created. Check ini file. Any key to continue");
	while (!kbhit());
	OpenIniFile  ("Test.Ini");
	DeleteKey    ("Test"	  , "ToDelete");
	WriteIniFile ("Test.Ini");
#endif
	printf ("[Test] Name = %s\n", ReadString ("Test", "Name", "NotFound"));
	printf ("[Test] Port = %s\n", ReadString ("Test", "Port", "NotFound"));
	printf ("[Test] User = %s\n", ReadString ("Test", "User", "NotFound"));
	printf ("[Configuration] eDriver = %s\n", ReadString ("Configuration", "eDriver", "NotFound"));
	printf ("[Configuration] Wrap = %s\n", ReadString ("Configuration", "Wrap", "NotFound"));
	printf ("[IO-Port] Com = %d\n", ReadInt ("IO-Port", "Com", 0));
	printf ("[IO-Port] IsValid = %d\n", ReadBool ("IO-Port", "IsValid", 0));
	printf ("[TheMoney] TheMoney = %1.10lf\n", ReadDouble ("TheMoney", "TheMoney", 111));
	CloseIniFile ();
	return 0;
}
Exemple #15
0
int main ()
{
	DictHndl testHash;
	ListHndl testLookUp;

	testHash = NewDictionary (10);

	InsertKey (testHash, "cat", 123);

	InsertKey (testHash, "dog", 234);

	InsertKey (testHash, "fog", 2345);

	InsertKey (testHash, "fog", 245);

	testLookUp = LookUp (testHash, "fog");

	MoveFirst (testLookUp);
	while (!OffEnd (testLookUp))
	{
		int temp = *(int*) GetCurrent (testLookUp);
		printf ("%d ", temp);
		MoveNext (testLookUp);
	}

	printf ("\n");

	if (IsIn (testHash, "dog"))
	{
		printf ("dog is in the table\n");
	}

	DeleteKey (testHash, "cat");

	DeleteKey (testHash, "dog");

	if (IsIn (testHash, "dog"))
	{
		printf ("dog is still in the table\n");
	}

	testLookUp = LookUp (testHash, "dog");

	FreeDictionary (testHash);

	return (0);
}
Exemple #16
0
void Select_UnHideAllWaypoints(void)
{
	for (entity_t* pEnt=entities.next ; pEnt != &entities ; pEnt=pEnt->next)
	{
		DeleteKey(pEnt, sKEY_HIDDENWAYPOINT);		
	}

	Sys_UpdateWindows (W_XY|W_CAMERA);
}
Exemple #17
0
void R_Entity_UpdateAllTargetWaypoints(entity_t *pEnt, entity_t *pOriginalEnt, bool bHide)
{
	if (pEnt)
	{
		if (strlen(ValueForKey(pEnt, sKEY_WAYPOINTHIDE_RECURSION_PROTECT))==0)
		{
			SetKeyValue(pEnt, sKEY_WAYPOINTHIDE_RECURSION_PROTECT, "1");	// note: actual value irrelevant, just so long as strlen()!=0

			CString str;
			entity_t *pDestEnt;			

			str = ValueForKey(pEnt, "target");
			if (str.GetLength() > 0)
			{
				pDestEnt = FindEntity("targetname", str.GetBuffer(0));

				R_Entity_UpdateAllTargetWaypoints(pDestEnt, pOriginalEnt, bHide);
			}

			str = ValueForKey(pEnt, "target2");
			if (str.GetLength() > 0)
			{
				pDestEnt = FindEntity("targetname", str.GetBuffer(0));

				R_Entity_UpdateAllTargetWaypoints(pDestEnt, pOriginalEnt, bHide);
			}

			str = ValueForKey(pEnt, "target3");
			if (str.GetLength() > 0)
			{
				pDestEnt = FindEntity("targetname", str.GetBuffer(0));

				R_Entity_UpdateAllTargetWaypoints(pDestEnt, pOriginalEnt, bHide);				
			}

			str = ValueForKey(pEnt, "target4");
			if (str.GetLength() > 0)
			{
				pDestEnt = FindEntity("targetname", str.GetBuffer(0));

				R_Entity_UpdateAllTargetWaypoints(pDestEnt, pOriginalEnt, bHide);				
			}

			if (pEnt != pOriginalEnt)	// because we don't want to hide/unhide ourselves, just the children
			{
				if (bHide)
				{
					SetKeyValue(pEnt, sKEY_HIDDENWAYPOINT, "1");	// note: actual value irrelevant, just so long as strlen()!=0
				}
				else
				{
					DeleteKey(pEnt, sKEY_HIDDENWAYPOINT);
				}
			}
		}
	}
}
void CEntityDlg::DelProp() {
	CString key;
	if( editEntity == NULL ) {
		return;
	}
	editKey.GetWindowText( key );
	if( multipleEntities ) {
		for( brush_t *b = selected_brushes.next; b != &selected_brushes; b = b->next ) {
			DeleteKey( b->owner, key );
			Entity_UpdateCurveData( b->owner );
		}
	} else {
		DeleteKey( editEntity, key );
		Entity_UpdateCurveData( editEntity );
	}
	// refresh the prop listbox
	SetKeyValPairs();
	Sys_UpdateWindows( W_ENTITY | W_XY | W_CAMERA );
}
Exemple #19
0
/* {{{ CI_SetConfigString */
CK_DEFINE_FUNCTION(CK_RV, CI_SetConfigString)(
  CK_CHAR_PTR pSectionName,
  CK_CHAR_PTR pFieldname,
  CK_CHAR_PTR pValue
)
{
  CK_RV rv = CKR_OK;
	bool ret;

  pSectionName=((pSectionName!=NULL_PTR)?pSectionName:(CK_CHAR_PTR)"PKCS11-DLL");

  if(CK_I_config_fname == NULL_PTR)
    {
      rv = CKR_GENERAL_ERROR;
      CI_VarLogEntry("CI_GetConfigString", "Reading config field failed: config file not set", 
		     rv, 0, 
		     pFieldname, 
		     pSectionName,
		     CK_I_config_fname, 
		     CK_I_init_fail_reasons[rv]);
      return rv;
    }

	do 
	{
		ret = OpenIniFile(CK_I_config_fname);
		if (ret != TRUE)
			break;

		ret = DeleteKey(pSectionName, pFieldname);
		if (ret != TRUE)
		{
			CloseIniFile();
			break;
		}
		
		WriteString(pSectionName, pFieldname, pValue);

		WriteIniFile(CK_I_config_fname);
	}while (false);
	if(ret != TRUE)
    {
      CI_VarLogEntry("CI_SetConfigString", "Setting config field '%s' from section [%s] in file '%s' failed: %s", 
		     CKR_GENERAL_ERROR, 0, 
		     pFieldname, 
		     pSectionName,
		     CK_I_config_fname, 
		     CK_I_init_fail_reasons[rv]);
      return CKR_GENERAL_ERROR;
    }
  return CKR_OK;
}
Exemple #20
0
int main ()
{
	DictHndl testDict;
	ListHndl testLookUp;

	testDict = NewDictionary (10);

	InsertKey (testDict, "cat", 123);

	InsertKey (testDict, "dog", 234);

	InsertKey (testDict, "fog", 2345);

	InsertKey (testDict, "fog", 245);

	testLookUp = LookUp (testDict, "cat");

	printf ("%d\n" , *(int*) GetFirst (testLookUp));

	PrintKeyLocations (testDict, "fog");

	if (IsIn (testDict, "dog"))
	{
		printf ("dog is in the table\n");
	}

	DeleteKey (testDict, "cat");

	DeleteKey (testDict, "dog");

	if (IsIn (testDict, "dog"))
	{
		printf ("dog is still in the table\n");
	}

	FreeDictionary (testDict);

	return (0);
}
Exemple #21
0
void Group_RemoveListFromWorld()
{
	if (!g_qeglobals.m_bBrushPrimitMode)
  {
    return;
  }
  CStringArray array;
  Group_GetListFromWorld(&array);
  int nCount = array.GetSize();
  for (int i = 0; i < nCount; i++)
  {
    DeleteKey(world_entity, array.GetAt(i));
  }
}
Exemple #22
0
bool RegHelper::DeleteKey(HKEY hKeyRoot, LPCTSTR lpSubKey)
{
	HKEY hKey;
    long lResult;
    DWORD dwSize;
	TCHAR szName[MAX_PATH] ={0};
	TCHAR szSubKey[MAX_PATH] ={0};

    lResult = ::RegDeleteKey(hKeyRoot, lpSubKey);

    if (lResult == ERROR_SUCCESS)	return true;

    lResult = ::RegOpenKeyEx (hKeyRoot, lpSubKey, 0, KEY_READ, &hKey);

    if (lResult != ERROR_SUCCESS) 
    {
        if (lResult == ERROR_FILE_NOT_FOUND)	return true;

        else	return false;		//打开键值出错
    }

    dwSize = MAX_PATH;
    lResult = ::RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL, NULL, NULL, NULL);

    if (lResult == ERROR_SUCCESS) 
    {
        do 
		{
			lstrcpy(szSubKey, lpSubKey);
			lstrcat(szSubKey, TEXT("\\"));
			lstrcat(szSubKey, szName);

			//递归调用删除下一层子键
            if (!DeleteKey(hKeyRoot, szSubKey))	break;

            dwSize = MAX_PATH;

            lResult = ::RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL, NULL, NULL, NULL);

        } while (lResult == ERROR_SUCCESS);
    }

   ::RegCloseKey (hKey);

   lResult = ::RegDeleteKey(hKeyRoot, lpSubKey);

   if (lResult == ERROR_SUCCESS)	return true;

   return false;
}
Exemple #23
0
void Group_RemoveBrush(brush_t *b)
{
	if (!g_qeglobals.m_bBrushPrimitMode)
	{
		return;
	}
	if (b->itemOwner)
	{
		g_pGroupDlg->m_wndTree.DeleteItem(b->itemOwner);
		b->itemOwner = NULL;
		g_pGroupDlg->m_wndTree.RedrawWindow();
	}
	DeleteKey(b->epairs, "group");
}
FKeyHandle FRichCurve::SetKeyTime( FKeyHandle KeyHandle, float NewTime )
{
	if (!IsKeyHandleValid(KeyHandle)) {return KeyHandle;}

	FRichCurveKey OldKey = GetKey(KeyHandle);
	
	DeleteKey(KeyHandle);
	AddKey(NewTime, OldKey.Value, false, KeyHandle);

	// Copy all properties from old key, but then fix time to be the new time
	GetKey(KeyHandle) = OldKey;
	GetKey(KeyHandle).Time = NewTime;

	return KeyHandle;
}
Exemple #25
0
 int Ardb::Del(Context& ctx, RedisCommandFrame& cmd)
 {
     if (ctx.IsSlave() && m_cfg.slave_ignore_del)
     {
         return 0;
     }
     BatchWriteGuard guard(GetKeyValueEngine());
     int count = 0;
     for (uint32 i = 0; i < cmd.GetArguments().size(); i++)
     {
         count += DeleteKey(ctx, cmd.GetArguments()[i]);
     }
     fill_int_reply(ctx.reply, count);
     return 0;
 }
Exemple #26
0
 int Ardb::RenameList(Context& ctx, DBID srcdb, const std::string& srckey, DBID dstdb, const std::string& dstkey)
 {
     Context tmpctx;
     tmpctx.currentDB = srcdb;
     ValueObject v;
     int err = GetMetaValue(tmpctx, srckey, LIST_META, v);
     CHECK_ARDB_RETURN_VALUE(ctx.reply, err);
     if (0 != err)
     {
         fill_error_reply(ctx.reply, "no such key or some error");
         return 0;
     }
     if (v.meta.Encoding() == COLLECTION_ENCODING_ZIPLIST)
     {
         DelKeyValue(tmpctx, v.key);
         v.key.encode_buf.Clear();
         v.key.db = dstdb;
         v.key.key = dstkey;
         v.meta.expireat = 0;
         SetKeyValue(ctx, v);
     }
     else
     {
         ListIterator iter;
         ListIter(ctx, v, iter, false);
         tmpctx.currentDB = dstdb;
         ValueObject dstmeta;
         dstmeta.key.type = KEY_META;
         dstmeta.key.key = dstkey;
         dstmeta.type = LIST_META;
         dstmeta.meta.SetFlag(COLLECTION_FLAG_SEQLIST);
         dstmeta.meta.SetEncoding(COLLECTION_ENCODING_ZIPLIST);
         BatchWriteGuard guard(GetKeyValueEngine());
         while (iter.Valid())
         {
             std::string tmpstr;
             ListInsert(tmpctx, dstmeta, NULL, iter.Element()->GetDecodeString(tmpstr), false, false);
             iter.Next();
         }
         SetKeyValue(tmpctx, dstmeta);
         tmpctx.currentDB = srcdb;
         DeleteKey(tmpctx, srckey);
     }
     ctx.data_change = true;
     return 0;
 }
Exemple #27
0
/*=============================================================================
*NAME		:TYSIniFile::WriteStringList
			:
*MODULE		:YSIniFiles.cpp
			:
*FUNCTION	:文字列リスト書き込み処理関数です
			:
*PROCESS	:・文字列リストの書き込みです。
			:
*INPUT		:const CString section		:セクション名
*INPUT		:const CString iname		:Ident名
*INPUT		:const TStringList& slist	:内容
			:
*PROGRAMMED	:Y.Sasai
*HISTORY	:
*ID -- DATE ------- NOTE ------------------------------------------------------
*00 03.02.13 Y.Sasai Ver.0.90 初期作成
*/
void TYSIniFile::WriteStringList( const CString section, const CString iname, TStringList& slist )
{
	CString ident;
	int tempi;

	for ( tempi = 0; true; tempi++ ) {
		ident = iname + Number[tempi];															// 2003.02.13 Y.Sasai Ver.0.00 Ident名作成
		if ( tempi < slist.Count ) {															// 2003.02.13 Y.Sasai Ver.0.00 文字列リスト行数内なら…
			WriteString( section, iname + Number[tempi], slist[tempi] );						// 2003.02.13 Y.Sasai Ver.0.90 文字列書き込み
		} else {																				// 2003.02.13 Y.Sasai Ver.0.00 行数を超えたら…
			if ( ValueExists( section, ident ) == false ) {										// 2003.02.13 Y.Sasai Ver.0.90 Ident名がなかったら…
				break;																			// 2003.02.13 Y.Sasai Ver.0.00 ぬけるぞ
			}
			DeleteKey( section, ident );														// 2003.02.13 Y.Sasai Ver.0.00 削除だ
		}
	}
}
Exemple #28
0
 int Ardb::RenameHash(Context& ctx, DBID srcdb, const std::string& srckey, DBID dstdb, const std::string& dstkey)
 {
     Context tmpctx;
     tmpctx.currentDB = srcdb;
     ValueObject v;
     int err = GetMetaValue(tmpctx, srckey, HASH_META, v);
     CHECK_ARDB_RETURN_VALUE(ctx.reply, err);
     if (0 != err)
     {
         fill_error_reply(ctx.reply, "no such key or some error");
         return 0;
     }
     if (v.meta.encoding == COLLECTION_ECODING_ZIPMAP)
     {
         DelKeyValue(tmpctx, v.key);
         v.key.encode_buf.Clear();
         v.key.db = dstdb;
         v.key.key = dstkey;
         v.meta.expireat = 0;
         SetKeyValue(ctx, v);
     }
     else
     {
         HashIterator iter;
         HashIter(ctx, v, "", iter, false);
         tmpctx.currentDB = dstdb;
         ValueObject dstmeta;
         dstmeta.key.type = KEY_META;
         dstmeta.key.key = dstkey;
         dstmeta.type = HASH_META;
         dstmeta.meta.encoding = COLLECTION_ECODING_ZIPMAP;
         BatchWriteGuard guard(GetKeyValueEngine());
         while (iter.Valid())
         {
             HashSet(tmpctx, dstmeta, *(iter.Field()), *(iter.Value()));
             iter.Next();
         }
         SetKeyValue(tmpctx, dstmeta);
         tmpctx.currentDB = srcdb;
         DeleteKey(tmpctx, srckey);
     }
     ctx.data_change = true;
     return 0;
 }
BOOL CRegistry::RecursiveDeleteKey(LPCTSTR pszPath, BOOL bAdmin)
{
	ASSERT(pszPath);

	CRegistry tmp(bAdmin, false);
	if(!tmp.Open(pszPath))
		return FALSE;

	CString subkey;
	BOOL bSuccess = TRUE;
	while(bSuccess && tmp.EnumKey(0, subkey))
	{
		CString path(pszPath);
		path.TrimRight(_T("\\"));
		path += _T("\\") + subkey;
		bSuccess = RecursiveDeleteKey(path, bAdmin);
	}
	tmp.Close();
	return DeleteKey(pszPath, bAdmin);
}
Exemple #30
0
/**
 * Deletes the key with the given key name.  This is useful when using
 * the -Dsun.java2d.accelReset flag, which resets the registry values
 * to force the startup tests to be rerun and re-recorded.
 *
 */
void RegistryKey::DeleteKey(WCHAR *keyName)
{
    if (disableRegistry) {
        return;
    }
    // We should be able to do this with the ShDeleteKey() function, but
    // that is apparently not available on the ia64 sdk, so we revert back
    // to recursively deleting all subkeys until we can delete the key in
    // question
    DWORD buffSize = 1024;
    WCHAR subKeyName[1024];
    int subKeyIndex = 0;
    FILETIME lastWriteTime;
    HKEY hKey;
    DWORD ret = RegOpenKeyEx(HKEY_CURRENT_USER, keyName, 0, KEY_ALL_ACCESS,
                             &hKey);
    if (ret != ERROR_SUCCESS) {
        PrintRegistryError(ret, "DeleteKey, during RegOpenKeyEx");
    }
    while ((ret = RegEnumKeyEx(hKey, subKeyIndex, subKeyName, &buffSize,
                               NULL, NULL, NULL, &lastWriteTime)) ==
           ERROR_SUCCESS)
    {
        WCHAR subKeyBuffer[1024];
        swprintf(subKeyBuffer, L"%s\\%s", keyName, subKeyName);
        DeleteKey(subKeyBuffer);
        ++subKeyIndex;
        buffSize = 1024;
    }
    ret = RegCloseKey(hKey);
    if (ret != ERROR_SUCCESS) {
        PrintRegistryError(ret, "DeleteKey, during RegCloseKey");
    }
    ret = RegDeleteKey(HKEY_CURRENT_USER, keyName);
    if (ret != ERROR_SUCCESS) {
        PrintRegistryError(ret, "DeleteKey, during RegDeleteKey");
    }
}