开发者

Deleting all values under a specific registry key

Is there an API that will delete all the values under a specific registry key?

for example, I have the following 开发者_如何学Pythonkey

HKEY_CURRENT_USER\Software\MyCompany\Program\Myconfig

under it I have

(Default)

SomeVal

SomeOtherVal

YetSomeOtherVat

...

There might be 10, 20, 100 values there. It depends what you set on the application. Is there a way in C to delete them all without having to iterate one by one and delete them?

Thanks, code is appreciated.


The SHDeleteKey function from Shlwapi.lib does what you want.

When you only need this on Vista and later OS versions, you can use RegDeleteTree


This ought to do it:

if (RegDeleteTree("HKEY_CURRENT_USER", "Software\MyCompany\Program\Myconfig") == ERROR_SUCCESS)
{
    . . .
}

This function deletes a specified registry key and all its subkeys. However, there is an issue with Windows 7 deleting keys on a Windows XP machine using this. See MSDN for details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜