Hi
How to get the Sqlserver Installation Path Programatically.
If we go for the Registry Then Registry Hives May be Different from one OS to other OS
Like w2k3 to w3k8 and VISTA and W2k8 R2 like that..
But i did Using Registry as follows But I gave Some Hard Code Key vAlues If Hives are same then no problem if Different The Problem rises....
CRegKey cregkey;
DWORD result;
const char subkey[]="SOFTWARE\\Microsoft\\Microsoft SQL Server\\100";
const char keyval[] = "VerSpecificRootDir";
char path[ 2048 ];
result = cregkey.Open(HKEY_LOCAL_MACHINE,subkey);
if (ERROR_SUCCESS == result)
{
DWORD dwCount = sizeof( path );
result = cregkey.QueryStringValue(keyval, path, &dwCount);
if (ERROR_SUCCESS == result)
{
cout<<" The SQLSERVER Pathis "<<path<<endl;
}
}