Why do i can not delete Registry Keys ?
-
Hello, i created a shell extension for my program but i cannot delete them? Whats going wrong there? Hope someone can help me. Thanks !
HKEY key; DWORD res; RegCreateKeyEx(HKEY_CLASSES_ROOT,L"CPACK\\shell\\Extract with CPACK\\command",0,NULL,REG_OPTION_NON_VOLATILE,0xF003F,NULL,&key,&res); wchar_t *data = L"C:\\cpack.exe e %1"; RegSetValueEx(key,L"",0,REG_SZ,(LPBYTE)data,(DWORD)(lstrlen(data)+1)*sizeof(TCHAR)); RegCloseKey(key); RegCreateKeyEx(HKEY_CLASSES_ROOT,L".cpack",0,NULL,REG_OPTION_NON_VOLATILE,0xF003F,NULL,&key,&res); data = L"CPACK"; RegSetValueEx(key,L"",0,REG_SZ,(LPBYTE)data,(DWORD)(lstrlen(data)+1)*sizeof(TCHAR)); RegCloseKey(key); // deletes a key // RegUnLoadKey(HKEY_CLASSES_ROOT,L"CPACK"); RegDeleteKey(HKEY_CLASSES_ROOT,L"CPACK");
bye, gabbana -
Hello, i created a shell extension for my program but i cannot delete them? Whats going wrong there? Hope someone can help me. Thanks !
HKEY key; DWORD res; RegCreateKeyEx(HKEY_CLASSES_ROOT,L"CPACK\\shell\\Extract with CPACK\\command",0,NULL,REG_OPTION_NON_VOLATILE,0xF003F,NULL,&key,&res); wchar_t *data = L"C:\\cpack.exe e %1"; RegSetValueEx(key,L"",0,REG_SZ,(LPBYTE)data,(DWORD)(lstrlen(data)+1)*sizeof(TCHAR)); RegCloseKey(key); RegCreateKeyEx(HKEY_CLASSES_ROOT,L".cpack",0,NULL,REG_OPTION_NON_VOLATILE,0xF003F,NULL,&key,&res); data = L"CPACK"; RegSetValueEx(key,L"",0,REG_SZ,(LPBYTE)data,(DWORD)(lstrlen(data)+1)*sizeof(TCHAR)); RegCloseKey(key); // deletes a key // RegUnLoadKey(HKEY_CLASSES_ROOT,L"CPACK"); RegDeleteKey(HKEY_CLASSES_ROOT,L"CPACK");
bye, gabbanaYou cannot delete a registry key if subkeys exist. If you were successful with creating the key and subkeys then you should be able to delete them as well. RegDeleteKey will fail with ERROR_ACCESS_DENIED if a subkey exists. You need to implement a recursive deletion[^]. Best Wishes, -David Delaune
-
You cannot delete a registry key if subkeys exist. If you were successful with creating the key and subkeys then you should be able to delete them as well. RegDeleteKey will fail with ERROR_ACCESS_DENIED if a subkey exists. You need to implement a recursive deletion[^]. Best Wishes, -David Delaune
-
Hello, i created a shell extension for my program but i cannot delete them? Whats going wrong there? Hope someone can help me. Thanks !
HKEY key; DWORD res; RegCreateKeyEx(HKEY_CLASSES_ROOT,L"CPACK\\shell\\Extract with CPACK\\command",0,NULL,REG_OPTION_NON_VOLATILE,0xF003F,NULL,&key,&res); wchar_t *data = L"C:\\cpack.exe e %1"; RegSetValueEx(key,L"",0,REG_SZ,(LPBYTE)data,(DWORD)(lstrlen(data)+1)*sizeof(TCHAR)); RegCloseKey(key); RegCreateKeyEx(HKEY_CLASSES_ROOT,L".cpack",0,NULL,REG_OPTION_NON_VOLATILE,0xF003F,NULL,&key,&res); data = L"CPACK"; RegSetValueEx(key,L"",0,REG_SZ,(LPBYTE)data,(DWORD)(lstrlen(data)+1)*sizeof(TCHAR)); RegCloseKey(key); // deletes a key // RegUnLoadKey(HKEY_CLASSES_ROOT,L"CPACK"); RegDeleteKey(HKEY_CLASSES_ROOT,L"CPACK");
bye, gabbanagabbana wrote:
Whats going wrong there?
What's going on is that you are not checking for errors. From MSDN: If RegDeleteKey() fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage() function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hello, i created a shell extension for my program but i cannot delete them? Whats going wrong there? Hope someone can help me. Thanks !
HKEY key; DWORD res; RegCreateKeyEx(HKEY_CLASSES_ROOT,L"CPACK\\shell\\Extract with CPACK\\command",0,NULL,REG_OPTION_NON_VOLATILE,0xF003F,NULL,&key,&res); wchar_t *data = L"C:\\cpack.exe e %1"; RegSetValueEx(key,L"",0,REG_SZ,(LPBYTE)data,(DWORD)(lstrlen(data)+1)*sizeof(TCHAR)); RegCloseKey(key); RegCreateKeyEx(HKEY_CLASSES_ROOT,L".cpack",0,NULL,REG_OPTION_NON_VOLATILE,0xF003F,NULL,&key,&res); data = L"CPACK"; RegSetValueEx(key,L"",0,REG_SZ,(LPBYTE)data,(DWORD)(lstrlen(data)+1)*sizeof(TCHAR)); RegCloseKey(key); // deletes a key // RegUnLoadKey(HKEY_CLASSES_ROOT,L"CPACK"); RegDeleteKey(HKEY_CLASSES_ROOT,L"CPACK");
bye, gabbanaAnd see A Registry Class[^]. ;)