You want the user interface to be seperate from the program..???!!
You could do this without a functionality change to fpc or lazarus. Just have a config file that will specify where the wdiget will sit on the form and read it in at startup. You could use dynamic array of controls to add/remove buttons.
The problem is while you can change the user interface dynamically, how do you intend modifying the code (which is compiled and not easily modifiable) by the program itself. However this could also be done by altering the program inmemory but you need to be very careful. Write to a memory location that you don't "own" and your program will crash.
Programs have be modifing themselves under windows for years (I first read about this idea when i was learning Microsoft Visual Basic 3.
Anyway, Jamie, nice idea but not overly practical. I could be wrong though.