Try to run aspnet_regiis with parameter -lv, i.e.:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -lv
This will give you the following output:
Microsoft (R) ASP.NET RegIIS version 4.0.30319.34209
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
2.0.50727.0 C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll
4.0.30319.0 C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
4.0.30319.0 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
In this example, you can see that v4.0.30319.0, 32 and 64 bit dll's, are installed.
To install the latest version, for example after applying a .NET Framework update, use
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -iru
Note: On 64 bit IIS servers, you need to use "Framework64" instead of "Framework" in the paths above. Strangely, I found on some servers with 64 bit "Framework" in the path worked, on others I had to use "Framework64" - simply try it out. If the registration does not work, run it again with "Framework64" in the path, it does not harm. In one case, I had to change the path using cd C:\Windows\Microsoft.NET\Framework, then I typed aspnet_regiis -iru to make it finally work.
You mentioned that you need to check it programmatically: The command above can be used in a batch file, and via this article you can find the string "4.0.30319.0" in the output (provided you're using "aspnet_regiis -lv > outputfile.txt" to write the output into a text file).