It entirely depends on the program, although the registry is the best place to start.
If you open RegEdit.exe and go to either:
- "My Computer\HKEY_LOCAL_MACHINE\Software\"
or - "My Computer\HKEY_CURRENT_USER\Software\"
many installation paths can be found in there. Different applications have their own way of storing the installation path. Adobe uses a key named "InstallPath", Kodak use a "TargetDir" value string saved under the "Kodak\Common" key, while OpenOffice.org uses the "InstallPath" key aswell, but just in another location.
A slightly accurate way is to extract all paths out of the "HKeyCurrentUser\Software\" or "HKeyLocalMachine\Software\" registry branches and search for ones that contain the %ProgramFiles% environment string. Not entirely fool-proof, but is certain to work for about 90% of Win32 applications.
-X