> For the complete documentation index, see [llms.txt](https://malwaresourcecode.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malwaresourcecode.com/home/wrappers-and-helpers/isregistrykeyvalid.md).

# IsRegistryKeyValid

```
DWORD IsRegistryKeyValidW(_In_ HKEY PredefinedKey, _In_ PWCHAR Path)
{
	HKEY hKey = NULL;
	DWORD dwError = ERROR_SUCCESS;

	dwError = RegOpenKeyExW(PredefinedKey, Path, 0, GENERIC_READ | GENERIC_WRITE, &hKey);

	if (hKey)
		RegCloseKey(hKey);

	return dwError;
}

DWORD IsRegistryKeyValidA(_In_ HKEY PredefinedKey, _In_ PCHAR Path)
{
	HKEY hKey = NULL;
	DWORD dwError = ERROR_SUCCESS;

	dwError = RegOpenKeyExA(PredefinedKey, Path, 0, GENERIC_READ | GENERIC_WRITE, &hKey);

	if (hKey)
		RegCloseKey(hKey);

	return dwError;
}
```
