What is the most reliable way to determine which version of SharePoint is installed. Whether it is WSS or MOSS. If MOSS, whether it is standard or enterprise.
I want to programmatically detect the exact SharePoint version installed..
PS: I already have posted this question at SharePoint.SE but could not find a convincing answer.
You could try to use SPFarm.Local.BuildVersion
or SPWebService.ContentService.Farm.BuildVersion
(from this previous question) and to build a lookup table based on this: How to find the level of SharePoint you are running?
Another option is to read directly from ConfigDB
database, on Versions
table; you can find more information here.
Registry keys on server
You can look for these within the registry key HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\InstalledProducts.
BEED1F75-C398-4447-AEF1-E66E1F0DF91E: SharePoint Foundation 2010
1328E89E-7EC8-4F7E-809E-7E945796E511: Search Server Express 2010
B2C0B444-3914-4ACB-A0B8-7CF50A8F7AA0: SharePoint Server 2010 Standard Trial
3FDFBCC8-B3E4-4482-91FA-122C6432805C: SharePoint Server 2010 Standard
88BED06D-8C6B-4E62-AB01-546D6005FE97: SharePoint Server 2010 Enterprise Trial
D5595F62-449B-4061-B0B2-0CBAD410BB51: SharePoint Server 2010 Enterprise
BC4C1C97-9013-4033-A0DD-9DC9E6D6C887: Search Server 2010 Trial
08460AA2-A176-442C-BDCA-26928704D80B: Search Server 2010
84902853-59F6-4B20-BC7C-DE4F419FEFAD: Project Server 2010 Trial
ED21638F-97FF-4A65-AD9B-6889B93065E2: Project Server 2010
926E4E17-087B-47D1-8BD7-91A394BC6196: Office Web Companions 2010
Programmatically
See the article How To: Detect the Installed SKU of SharePoint 2010 on MSDN. It has a list of GUIDs for each SKU:
PowerShell
You can also use the PowerShell command get-spfarm | select Products to output GUIDs for the installed SKUs.
As suggested there, the probably most reliable method is to check for the availability of a feature.
There is no function in the SharePoint API that can tell you if it's WSS, MOSS Standard, or MOSS Enterprise.