The best way to detect if they are unable to perform an action is to attempt it and catch the UnauthorizedAccessException
.
However as @DannySmurf correctly points out you can only elevate a COM object or separate process.
There is a demonstration application within the Windows SDK Cross Technology Samples called UAC Demo. This demonstration application shows a method of executing actions with an elevated process. It also demonstrates how to find out if a user is currently an administrator.