Your job is to write using Delphi 2010 or compatible, a function or a class that can be used to take an ownership and fix permissions of any given registry key.
In other words, let me start [url removed, login to view] and create a key HKEY_LOCAL_MACHINE\Software\foobar\, right click it, select Permissions and remove permissions from all users. Now if I try to use TRegistry to delete the key, it fails. After asking your code to fix the ownership and permissions of the "foobar" key, it must be possible to access it and delete it normally with TRegistry.
Your code must work in Windows Vista, 7 and 8. You might find to see the source code of an open source program called SetACL for inspiration how this can be done. Only make a bid if you can start now, and no, I am not interested of solutions in any other programming languages.