Search code examples
c++winapiaccess-rights

how to delete local machine registry key?


I need to delete some local machine registry keys, I tried all registry delete routines but the result is through admin account I cant do it. how can I set access rights of my application to system account using windows API routines??? I also used this routine RegDeleteKey but returned value 5 means access denied, I run my application under full admin rights

even manually open regedit with admin rights, I wont be able to delete local machine registry keys. for purpose I need system account rights.

i opened regedit with system account rights and i was able to delete local machine keys successfully. now i need to do this programmatically


Solution

  • You either need to run your application as an administrator (Run as administrator in the context menu of Explorer), or you need to add a manifest to your application, indicating that your application needs administrator rights. In the latter case, a UAC dialog will ask you for administrator credentials.