Ejemplo n.º 1
1
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;
}
Ejemplo n.º 2
0
/***************************************************************
 * DMOUnregister (MSDMO.@)
 *
 * Unregister a DirectX Media Object.
 */
HRESULT WINAPI DMOUnregister(REFCLSID clsidDMO, REFGUID guidCategory)
{
    HRESULT hres;
    WCHAR szguid[64];
    HKEY hrkey = 0;
    HKEY hckey = 0;

    GUIDToString(szguid, clsidDMO);

    TRACE("%s %p\n", debugstr_w(szguid), guidCategory);

    hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_WRITE, &hrkey);
    if (ERROR_SUCCESS != hres)
        goto lend;

    hres = RegDeleteKeyW(hrkey, szguid);
    if (ERROR_SUCCESS != hres)
        goto lend;

    hres = RegOpenKeyExW(hrkey, szDMOCategories, 0, KEY_WRITE, &hckey);
    if (ERROR_SUCCESS != hres)
        goto lend;

    hres = RegDeleteKeyW(hckey, szguid);
    if (ERROR_SUCCESS != hres)
        goto lend;

lend:
    if (hckey)
        RegCloseKey(hckey);
    if (hrkey)
        RegCloseKey(hrkey);

    return hres;
}
Ejemplo n.º 3
0
STDAPI DllUnregisterServer(void)
{
    DebugLog(L"Unregistering server");

    TCHAR clsid[MAX_PATH];
    StringFromGUID2(SHELLEXT_GUID, clsid, ARRAYSIZE(clsid));
    
    Unregist_CLSID(clsid);
    
    RegDeleteKeyW(HKEY_CLASSES_ROOT, L"*\\ShellEx\\ContextMenuHandlers\\00TiXExt");

    RegDeleteKeyW(HKEY_CLASSES_ROOT, L"Directory\\ShellEx\\ContextMenuHandlers\\00TiXExt");

    HKEY hTmpKey;
    if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", &hTmpKey) == ERROR_SUCCESS)
    {
        RegDeleteValueW(hTmpKey, clsid);
        RegCloseKey(hTmpKey);
    }

    if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\RyuaNerin", &hTmpKey) == ERROR_SUCCESS)
    {
        RegDeleteValueW(hTmpKey, L"TiX");
        RegDeleteValueW(hTmpKey, L"TiX-Option");
        RegCloseKey(hTmpKey);
    }


    return S_OK;
}
Ejemplo n.º 4
0
static void test_SQLWritePrivateProfileString(void)
{
   static const WCHAR odbc_key[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C','\\','O','D','B','C','.','I','N','I','\\','w','i','n','e','o','d','b','c',0};
   static const WCHAR abcd_key[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C','\\','a','b','c','d','.','I','N','I','\\','w','i','n','e','o','d','b','c',0};
   static const WCHAR abcdini_key[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C','\\','a','b','c','d','.','I','N','I',0 };
   BOOL ret;
   LONG reg_ret;
   DWORD error_code;

   ret = SQLWritePrivateProfileString("wineodbc", "testing" , "value", "");
   ok(!ret, "SQLWritePrivateProfileString passed\n");
   SQLInstallerErrorW(1, &error_code, NULL, 0, NULL);
   ok(error_code == ODBC_ERROR_INVALID_STR, "SQLInstallerErrorW ret: %d\n", error_code);

   ret = SQLWritePrivateProfileString("wineodbc", "testing" , "value", NULL);
   ok(!ret, "SQLWritePrivateProfileString passed\n");
   SQLInstallerErrorW(1, &error_code, NULL, 0, NULL);
   ok(error_code == ODBC_ERROR_INVALID_STR, "SQLInstallerErrorW ret: %d\n", error_code);

   ret = SQLWritePrivateProfileString("wineodbc", "testing" , "value", "odbc.ini");
   ok(ret, "SQLWritePrivateProfileString failed\n");
   if(ret)
   {
        HKEY hkey;

        reg_ret = RegOpenKeyExW(HKEY_CURRENT_USER, odbc_key, 0, KEY_READ, &hkey);
        ok(reg_ret == ERROR_SUCCESS, "RegOpenKeyExW failed\n");
        if(reg_ret == ERROR_SUCCESS)
        {
            reg_ret = RegDeleteKeyW(HKEY_CURRENT_USER, odbc_key);
            ok(reg_ret == ERROR_SUCCESS, "RegDeleteKeyW failed\n");

            RegCloseKey(hkey);
        }
   }

   ret = SQLWritePrivateProfileString("wineodbc", "testing" , "value", "abcd.ini");
   ok(ret, "SQLWritePrivateProfileString failed\n");
   if(ret)
   {
        HKEY hkey;

        reg_ret = RegOpenKeyExW(HKEY_CURRENT_USER, abcd_key, 0, KEY_READ, &hkey);
        ok(reg_ret == ERROR_SUCCESS, "RegOpenKeyExW failed\n");
        if(reg_ret == ERROR_SUCCESS)
        {
            reg_ret = RegDeleteKeyW(HKEY_CURRENT_USER, abcd_key);
            ok(reg_ret == ERROR_SUCCESS, "RegDeleteKeyW failed\n");

            RegCloseKey(hkey);
        }

        /* Cleanup key */
        reg_ret = RegDeleteKeyW(HKEY_CURRENT_USER, abcdini_key);
        ok(reg_ret == ERROR_SUCCESS, "RegDeleteKeyW failed\n");
   }
}
Ejemplo n.º 5
0
void Unregist_CLSID(LPWSTR clsid)
{
    TCHAR subKey[MAX_PATH];
    wsprintf(subKey, L"CLSID\\%s\\InprocServer32", clsid);
    RegDeleteKeyW(HKEY_CLASSES_ROOT, subKey);

    wsprintf(subKey, L"CLSID\\%s", clsid);
    RegDeleteKeyW(HKEY_CLASSES_ROOT, subKey);
}
Ejemplo n.º 6
0
//------------------------------------------------------------------------------
// DllUnregisterServer
//------------------------------------------------------------------------------
STDAPI DllUnregisterServer()
{
	HKEY    hKey = NULL;
	HRESULT hr = S_OK;
	LONG    lResult = ERROR_SUCCESS;
	WCHAR   szKey[MAX_PATH] = { 0 };
	WCHAR   szCLSID[OLEGUID_LEN_CCH] = { 0 };

	//
	// Register the COM object in the registry
	//
	if (0 == StringFromGUID2(CLSID_SsysPrinterSvcProxy, szCLSID, ARRAYSIZE(szCLSID)))
	{
		hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
	}

	if (S_OK == hr)
	{
		hr = StringCchPrintfW(szKey, ARRAYSIZE(szKey), L"%s\\InProcServer32", szCLSID);
	}

	if (S_OK == hr)
	{
		lResult = RegOpenKeyExW(
			HKEY_CLASSES_ROOT,
			L"CLSID",
			0,
			KEY_SET_VALUE,
			&hKey
			);
		hr = HRESULT_FROM_WIN32(lResult);
	}

	if (S_OK == hr)
	{
		lResult = RegDeleteKeyW(hKey, szKey);
		hr = HRESULT_FROM_WIN32(lResult);
	}

	if (S_OK == hr)
	{
		lResult = RegDeleteKeyW(hKey, szCLSID);
		hr = HRESULT_FROM_WIN32(lResult);
	}

	RegCloseKey(hKey);
	hKey = NULL;

	return hr;
}// DllUnregisterServer
Ejemplo n.º 7
0
static BOOL
InputList_PrepareUserRegistry(VOID)
{
    BOOL bResult = FALSE;
    HKEY hTempKey = NULL;
    HKEY hKey = NULL;

    if (RegOpenKeyExW(HKEY_CURRENT_USER,
                      L"Keyboard Layout",
                      0,
                      KEY_ALL_ACCESS,
                      &hKey) == ERROR_SUCCESS)
    {
        RegDeleteKeyW(hKey, L"Preload");
        RegDeleteKeyW(hKey, L"Substitutes");

        RegCloseKey(hKey);
    }

    if (RegCreateKeyW(HKEY_CURRENT_USER, L"Keyboard Layout", &hKey) != ERROR_SUCCESS)
    {
        goto Cleanup;
    }

    if (RegCreateKeyW(hKey, L"Preload", &hTempKey) != ERROR_SUCCESS)
    {
        goto Cleanup;
    }

    RegCloseKey(hTempKey);

    if (RegCreateKeyW(hKey, L"Substitutes", &hTempKey) != ERROR_SUCCESS)
    {
        goto Cleanup;
    }

    RegCloseKey(hTempKey);

    bResult = TRUE;

Cleanup:
    if (hTempKey != NULL)
        RegCloseKey(hTempKey);
    if (hKey != NULL)
        RegCloseKey(hKey);

    return bResult;
}
Ejemplo n.º 8
0
static void s_RemoveRegistry(wchar_t *s) {
  HKEY key, result;
  wchar_t *subkey, *last;
  DWORD rc;

  SplitRegistryKey("remove-registry!", s, &key, &subkey, &last);

 /* open the key */
  if (last == subkey) {
    rc = RegOpenKeyExW(key, L"", 0, KEY_ALL_ACCESS, &result);
  } else {
    *last = '\0'; /* Truncate subkey at backslash */
    rc = RegOpenKeyExW(key, subkey, 0, KEY_ALL_ACCESS, &result);
    *last++ = '\\'; /* Restore backslash */
  }
  if (rc == ERROR_SUCCESS) {
   /* delete the value */
    rc = RegDeleteValueW(result, last);
    if (rc == ERROR_FILE_NOT_FOUND)
     /* value by given name not found; try deleting as key */
      rc = RegDeleteKeyW(result, last);
    RegCloseKey(result);
  }

  if (rc != ERROR_SUCCESS) {
    char *s_utf8 = Swide_to_utf8(s);
    ptr s_scheme = Sstring_utf8(s_utf8, -1);
    free(s_utf8);
    S_error2("remove-registry!", "cannot remove ~a (~a)", s_scheme,
      rc == ERROR_FILE_NOT_FOUND ? Sstring("not found") :
      rc == ERROR_ACCESS_DENIED ? Sstring("insufficient permission or subkeys exist") :
      s_ErrorString(rc));
  }
}
Ejemplo n.º 9
0
LONG WINAPI
RegDeleteKeyA(
	IN HKEY hKey,
	IN LPCSTR lpSubKey)
{
	PWSTR lpSubKeyW = NULL;
	LONG rc;

	if (lpSubKey != NULL && strchr(lpSubKey, '\\') != NULL)
		return ERROR_INVALID_PARAMETER;

	if (lpSubKey)
	{
		lpSubKeyW = MultiByteToWideChar(lpSubKey);
		if (!lpSubKeyW)
			return ERROR_OUTOFMEMORY;
	}

	rc = RegDeleteKeyW(hKey, lpSubKeyW);

	if (lpSubKey)
		free(lpSubKeyW);

	return rc;
}
Ejemplo n.º 10
0
/*
 * Delete a key and all its subkeys
 */
HRESULT DeleteEntireSubKey(HKEY hkey, LPWSTR strSubKey)
{
    WCHAR buffer[MAX_KEY_LEN];
    DWORD dw = MAX_KEY_LEN;
    FILETIME ft;
    HKEY hk;
    LONG ret = RegOpenKeyExW(hkey, strSubKey, 0, MAXIMUM_ALLOWED, &hk);

    if (ERROR_SUCCESS == ret)
    {
        /* Keep on enumerating the first key and deleting that */
        for( ; ; )
        {
            dw = MAX_KEY_LEN;

            ret = RegEnumKeyExW(hk, 0, buffer, &dw, NULL, NULL, NULL, &ft);

            if (ERROR_SUCCESS == ret)
                DeleteEntireSubKey(hk, buffer);
            else
                break;
        }
        RegCloseKey(hk);
        RegDeleteKeyW(hkey, strSubKey);
    }
    return NOERROR;
}
Ejemplo n.º 11
0
VOID
RemoveAppFromRegistry(INT Index)
{
    PINSTALLED_INFO Info;
    WCHAR szFullName[MAX_PATH] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
    WCHAR szMsgText[MAX_STR_LEN], szMsgTitle[MAX_STR_LEN];
    INT ItemIndex = SendMessage(hListView, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);

    if (!IS_INSTALLED_ENUM(SelectedEnumType))
        return;

    Info = (PINSTALLED_INFO) ListViewGetlParam(Index);
    if (!Info || !Info->hSubKey || (ItemIndex == -1)) return;

    if (!LoadStringW(hInst, IDS_APP_REG_REMOVE, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)) ||
        !LoadStringW(hInst, IDS_INFORMATION, szMsgTitle, sizeof(szMsgTitle) / sizeof(WCHAR)))
        return;

    if (MessageBoxW(hMainWnd, szMsgText, szMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
    {
        wcsncat(szFullName, Info->szKeyName, MAX_PATH - wcslen(szFullName));

        if (RegDeleteKeyW(Info->hRootKey, szFullName) == ERROR_SUCCESS)
        {
            (VOID) ListView_DeleteItem(hListView, ItemIndex);
            return;
        }

        if (!LoadStringW(hInst, IDS_UNABLE_TO_REMOVE, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
            return;

        MessageBoxW(hMainWnd, szMsgText, NULL, MB_OK | MB_ICONERROR);
    }
}
Ejemplo n.º 12
0
KSDDKAPI
HRESULT
WINAPI
DllUnregisterServer(void)
{
    ULONG Index = 0;
    LPOLESTR pStr;
    HRESULT hr = S_OK;
    HKEY hClass;

    if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS)
        return E_FAIL;

    do
    {
        hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
        if (FAILED(hr))
            break;

        RegDeleteKeyW(hClass, pStr);
        CoTaskMemFree(pStr);
        Index++;
    }while(InterfaceTable[Index].lpfnCI != 0);

    RegCloseKey(hClass);
    return hr;
}
Ejemplo n.º 13
0
/***********************************************************************
 *		recursive_delete_key
 */
static LONG recursive_delete_key(HKEY key)
{
    LONG res;
    WCHAR subkey_name[MAX_PATH];
    DWORD cName;
    HKEY subkey;

    for (;;) {
	cName = sizeof(subkey_name) / sizeof(WCHAR);
	res = RegEnumKeyExW(key, 0, subkey_name, &cName,
			    NULL, NULL, NULL, NULL);
	if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
	    res = ERROR_SUCCESS; /* presumably we're done enumerating */
	    break;
	}
	res = RegOpenKeyExW(key, subkey_name, 0,
			    KEY_READ | KEY_WRITE, &subkey);
	if (res == ERROR_FILE_NOT_FOUND) continue;
	if (res != ERROR_SUCCESS) break;

	res = recursive_delete_key(subkey);
	RegCloseKey(subkey);
	if (res != ERROR_SUCCESS) break;
    }

    if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
    return res;
}
Ejemplo n.º 14
0
/**********************************************************************
 * COMCAT_ICatRegister_UnRegisterCategories
 */
static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories(
    LPCATREGISTER iface,
    ULONG cCategories,
    CATID *rgcatid)
{
    HKEY comcat_key;
    HRESULT res;

    TRACE("\n");

    if (cCategories && rgcatid == NULL)
	return E_POINTER;

    /* Open the component categories key. */
    res = open_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ|KEY_WRITE, &comcat_key);
    if (res != ERROR_SUCCESS) return E_FAIL;

    for (; cCategories; --cCategories, ++rgcatid) {
	WCHAR keyname[CHARS_IN_GUID];

	/* Delete the key for this category. */
	if (!StringFromGUID2(rgcatid, keyname, CHARS_IN_GUID)) continue;
	RegDeleteKeyW(comcat_key, keyname);
    }

    RegCloseKey(comcat_key);
    return S_OK;
}
Ejemplo n.º 15
0
/**********************************************************************
 * COMCAT_UnRegisterClassCategories
 */
static HRESULT COMCAT_UnRegisterClassCategories(
    REFCLSID rclsid,
    LPCWSTR type,
    ULONG cCategories,
    const CATID *rgcatid)
{
    WCHAR keyname[68] = { 'C', 'L', 'S', 'I', 'D', '\\' };
    HRESULT res;
    HKEY type_key;

    if (cCategories && rgcatid == NULL) return E_POINTER;

    /* Format the class category type key name. */
    res = StringFromGUID2(rclsid, keyname + 6, 39);
    if (FAILED(res)) return res;
    keyname[44] = '\\';
    lstrcpyW(keyname + 45, type);

    /* Open the class category type key. */
    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0,
			KEY_READ | KEY_WRITE, &type_key);
    if (res != ERROR_SUCCESS) return E_FAIL;

    for (; cCategories; --cCategories, ++rgcatid) {
	/* Format the category key name. */
	res = StringFromGUID2(rgcatid, keyname, 39);
	if (FAILED(res)) continue;

	/* Do the unregister. */
	RegDeleteKeyW(type_key, keyname);
    }
    RegCloseKey(type_key);

    return S_OK;
}
Ejemplo n.º 16
0
/**********************************************************************
 * COMCAT_ICatRegister_UnRegisterCategories
 */
static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories(
    LPCATREGISTER iface,
    ULONG cCategories,
    CATID *rgcatid)
{
/*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
    HKEY comcat_key;
    HRESULT res;

    TRACE("\n");

    if (iface == NULL || (cCategories && rgcatid == NULL))
	return E_POINTER;

    /* Open the component categories key. */
    res = RegOpenKeyExW(HKEY_CLASSES_ROOT, comcat_keyname, 0,
			KEY_READ | KEY_WRITE, &comcat_key);
    if (res != ERROR_SUCCESS) return E_FAIL;

    for (; cCategories; --cCategories, ++rgcatid) {
	WCHAR keyname[39];

	/* Delete the key for this category. */
	if (!StringFromGUID2(rgcatid, keyname, 39)) continue;
	RegDeleteKeyW(comcat_key, keyname);
    }

    RegCloseKey(comcat_key);
    return S_OK;
}
Ejemplo n.º 17
0
void WinRegistryKey::deleteKey()
{
	Keys keys;
	subKeys(keys);
	close();
	for (Keys::iterator it = keys.begin(); it != keys.end(); ++it)
	{
		std::string subKey(_subKey);
		subKey += "\\";
		subKey += *it;
		WinRegistryKey subRegKey(_hRootKey, subKey);
		subRegKey.deleteKey();
	}

	// NOTE: RegDeleteKeyEx is only available on Windows XP 64-bit SP3, Windows Vista or later.
	// We cannot call it directly as this would prevent the code running on Windows XP 32-bit.
	// Therefore, if we need to call RegDeleteKeyEx (_extraSam != 0) we need to check for
	// its existence in ADVAPI32.DLL and call it indirectly.
#if defined(POCO_WIN32_UTF8)
	std::wstring usubKey;
	Poco::UnicodeConverter::toUTF16(_subKey, usubKey);
	
	typedef LONG (WINAPI *RegDeleteKeyExWFunc)(HKEY hKey, const wchar_t* lpSubKey, REGSAM samDesired, DWORD Reserved);
	if (_extraSam != 0)
	{
		AutoHandle advAPI32(LoadLibraryW(L"ADVAPI32.DLL"));
		if (advAPI32.handle())
		{
			RegDeleteKeyExWFunc pRegDeleteKeyExW = reinterpret_cast<RegDeleteKeyExWFunc>(GetProcAddress(advAPI32.handle() , "RegDeleteKeyExW"));
			if (pRegDeleteKeyExW)
			{
				if ((*pRegDeleteKeyExW)(_hRootKey, usubKey.c_str(), _extraSam, 0) != ERROR_SUCCESS)
					throw NotFoundException(key());
				return;
			}
		}
	}
	if (RegDeleteKeyW(_hRootKey, usubKey.c_str()) != ERROR_SUCCESS)
		throw NotFoundException(key());
#else
	typedef LONG (WINAPI *RegDeleteKeyExAFunc)(HKEY hKey, const char* lpSubKey, REGSAM samDesired, DWORD Reserved);
	if (_extraSam != 0)
	{
		AutoHandle advAPI32(LoadLibraryA("ADVAPI32.DLL"));
		if (advAPI32.handle())
		{
			RegDeleteKeyExAFunc pRegDeleteKeyExA = reinterpret_cast<RegDeleteKeyExAFunc>(GetProcAddress(advAPI32.handle() , "RegDeleteKeyExA"));
			if (pRegDeleteKeyExA)
			{
				if ((*pRegDeleteKeyExA)(_hRootKey, _subKey.c_str(), _extraSam, 0) != ERROR_SUCCESS)
					throw NotFoundException(key());
				return;
			}
		}
	}
	if (RegDeleteKey(_hRootKey, _subKey.c_str()) != ERROR_SUCCESS)
		throw NotFoundException(key());
#endif
}
Ejemplo n.º 18
0
BOOL My_RegDeleteKeyW()
{
	HKEY hKey=NULL;
	LPCWSTR lpSubKey=NULL;
	LONG returnVal_Real = NULL;
	LONG returnVal_Intercepted = NULL;

	DWORD error_Real = 0;
	DWORD error_Intercepted = 0;
	disableInterception();
	returnVal_Real = RegDeleteKeyW (hKey,lpSubKey);
	error_Real = GetLastError();
	enableInterception();
	returnVal_Intercepted = RegDeleteKeyW (hKey,lpSubKey);
	error_Intercepted = GetLastError();
	return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
Ejemplo n.º 19
0
bool Key::delete_sub_key_nt(const wchar_t* name) {
  LONG res = RegDeleteKeyW(h_key, name);
  if (res != ERROR_SUCCESS) {
    SetLastError(res);
    return false;
  }
  return true;
}
Ejemplo n.º 20
0
 void Key::remove() const
 {
     LONG lRtn = RegDeleteKeyW( m_hRootKey, m_wsPath.c_str() );
     if (lRtn != ERROR_SUCCESS) {
         BP_THROW( "RegDeleteKeyW(" + wideToUtf8(m_wsPath)
                   + ") returned: " + bp::conv::toString( lRtn ) );
     }
 }
Ejemplo n.º 21
0
NS_IMETHODIMP
nsWindowsRegKey::RemoveChild(const nsAString &name)
{
  NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);

  LONG rv = RegDeleteKeyW(mKey, PromiseFlatString(name).get());

  return (rv == ERROR_SUCCESS) ? NS_OK : NS_ERROR_FAILURE;
}
Ejemplo n.º 22
0
//---------------------------------------------------------------------------
HRESULT DeleteRegistryKey(HKEY RootKey,const wchar_t * KeyName)
{
  HKEY hkey;
  HRESULT hr;
  if( (hr = RegOpenKeyExW(RootKey,KeyName,0,KEY_ENUMERATE_SUB_KEYS | KEY_READ | KEY_WRITE,&hkey)) == ERROR_SUCCESS ){
    DWORD SubKeyNameLen, SubKeyNameLen2;
    wchar_t * SubKeyName, * SubKeyName2;
    for(;;){
      LONG a;
      SubKeyName = (wchar_t *) malloc(sizeof(wchar_t));
      SubKeyName[0] = L'\0';
      SubKeyNameLen = 1;
      for(;;){
        SubKeyNameLen2 = SubKeyNameLen;
        a = RegEnumKeyExW(hkey,0,SubKeyName,&SubKeyNameLen2,NULL,NULL,NULL,NULL);
        if( a != ERROR_MORE_DATA ) break;
        SubKeyName2 = (wchar_t *) realloc(SubKeyName,sizeof(wchar_t) * (SubKeyNameLen << 1));
        if( SubKeyName2 == NULL ) break;
        SubKeyName = SubKeyName2;
        SubKeyNameLen <<= 1;
      }  
      if( a != ERROR_SUCCESS || a == ERROR_NO_MORE_ITEMS ){
        free(SubKeyName);
        break;
      }
      hr = RegDeleteKeyW(hkey,SubKeyName);
      if( FAILED(hr) ){
        SubKeyName2 = (wchar_t *) malloc((wcslen(KeyName) + 1 + wcslen(SubKeyName) + 1) * sizeof(wchar_t));
        if( SubKeyName2 != NULL ){
          wcscpy_s(SubKeyName2,~rsize_t(0),KeyName);
          wcscat_s(SubKeyName2,~rsize_t(0),L"\\");
          wcscat_s(SubKeyName2,~rsize_t(0),SubKeyName);
          hr = DeleteRegistryKey(RootKey,SubKeyName2);
          free(SubKeyName2);
        }
      }
      free(SubKeyName);
      if( FAILED(hr) ) break;
    }
    RegCloseKey(hkey);
    if( SUCCEEDED(hr) ) hr = RegDeleteKeyW(RootKey,KeyName);
  }
  return hr;
}
Ejemplo n.º 23
0
static LONG MyRegistry_DeleteKey_32(HKEY parentKey, LPCWSTR name)
{
#if k_Reg_WOW_Flag_32 != 0
    if (func_RegDeleteKeyExW)
        return func_RegDeleteKeyExW(parentKey, name, k_Reg_WOW_Flag_32, 0);
    return E_FAIL;
#else
    return RegDeleteKeyW(parentKey, name);
#endif
}
Ejemplo n.º 24
0
static HRESULT unregister_namespace_extensions(struct regsvr_namespace const *list) {
    WCHAR *pwszKey;
    
    for (; list->clsid; list++) {
        pwszKey = get_namespace_key(list);
        RegDeleteKeyW(HKEY_LOCAL_MACHINE, pwszKey);
        HeapFree(GetProcessHeap(), 0, pwszKey);
    }
    return S_OK;
}
Ejemplo n.º 25
0
NS_IMETHODIMP
nsWindowsRegKey::RemoveChild(const nsAString& aName)
{
  if (NS_WARN_IF(!mKey)) {
    return NS_ERROR_NOT_INITIALIZED;
  }

  LONG rv = RegDeleteKeyW(mKey, PromiseFlatString(aName).get());

  return (rv == ERROR_SUCCESS) ? NS_OK : NS_ERROR_FAILURE;
}
LONG
Win32U_RegDeleteKey(HKEY keyName,   // IN:
                    LPCSTR subKey)  // IN:
{
   LONG ret;
   utf16_t *subKeyW = Unicode_GetAllocUTF16(subKey);

   ret = RegDeleteKeyW(keyName, subKeyW);
   free(subKeyW);

   return ret;
}
Ejemplo n.º 27
0
/*****************************************************************************
 * UnregisterInprocServer()
 *****************************************************************************
 */
HRESULT 
UnregisterInprocServer
(
    IN      REFGUID ClassId
)
{
    WCHAR ClsIdStr[MAX_PATH];
    StringFromGUID2(ClassId, ClsIdStr, MAX_PATH);

    WCHAR KeyName[MAX_PATH];

	wcscpy(KeyName, L"CLSID\\"); wcscat(KeyName, ClsIdStr); wcscat(KeyName, L"\\InprocServer32");  
	
	RegDeleteKeyW(HKEY_CLASSES_ROOT, KeyName);

    wcscpy(KeyName, L"CLSID\\"); wcscat(KeyName, ClsIdStr);

    RegDeleteKeyW(HKEY_CLASSES_ROOT, KeyName);

    return S_OK;
}
Ejemplo n.º 28
0
/***********************************************************************
 *              WINTRUST_RemoveProviderFromReg
 *
 * Helper function for WintrustRemoveActionID
 *
 */
static void WINTRUST_RemoveProviderFromReg(WCHAR* GuidString,
                                           const WCHAR* FunctionType)
{
    WCHAR ProvKey[MAX_PATH];

    /* Create the needed key string */
    ProvKey[0]='\0';
    lstrcatW(ProvKey, Trust);
    lstrcatW(ProvKey, FunctionType);
    lstrcatW(ProvKey, GuidString);

    /* We don't care about success or failure */
    RegDeleteKeyW(HKEY_LOCAL_MACHINE, ProvKey);
}
Ejemplo n.º 29
0
static HRESULT unregister_dmo_from_category(const WCHAR *dmoW, const WCHAR *catW, HKEY categories)
{
    HKEY catkey;
    LONG ret;

    ret = RegOpenKeyExW(categories, catW, 0, KEY_WRITE, &catkey);
    if (!ret)
    {
        ret = RegDeleteKeyW(catkey, dmoW);
        RegCloseKey(catkey);
    }

    return !ret ? S_OK : S_FALSE;
}
Ejemplo n.º 30
0
static HRESULT UnregisterComponent(REFGUID clsid)
{
    WCHAR szClsid[MAX_PATH];
    WCHAR szRoot[MAX_PATH];
    HKEY hkRoot;

    if (!StringFromGUID2(clsid, szClsid, _countof(szClsid)))
        return E_FAIL;

    HRESULT hr = StringCchPrintfW(szRoot, 0x104u, L"CLSID\\%s", szClsid);
    if (FAILED(hr))
        return hr;

    if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szRoot, 0, KEY_WRITE, &hkRoot) != 0)
        return E_FAIL;

    RegDeleteKeyW(hkRoot, L"InprocServer32");
    RegCloseKey(hkRoot);

    RegDeleteKeyW(HKEY_CLASSES_ROOT, szRoot);

    return S_OK;
}