CString strSQLSrvName;//
HKEY hKEY;
LPCTSTR data_Set="SOFTWARE\\Microsoft\\MSSQLServer\\MSSQLServer\\CurrentVersion\\";
long ret0=(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_READ, &hKEY));
if(ret0 == ERROR_SUCCESS)
{
LPBYTE owner=new BYTE[80];
DWORD type=REG_SZ ; DWORD dData=80;
long ret=::RegQueryValueEx(hKEY, "RegisteredOwner", NULL,&type, owner, &dData);
if(ret == ERROR_SUCCESS)
strSQLSrvName=CString(owner);
delete[] owner;
AfxMessageBox("Your SQL SERVER's name is:"+strSQLSrvName); }
::RegCloseKey(hKEY);
//就不解说了吧,拿去运行一下就知道了~
HKEY hKEY;
LPCTSTR data_Set="SOFTWARE\\Microsoft\\MSSQLServer\\MSSQLServer\\CurrentVersion\\";
long ret0=(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_READ, &hKEY));
if(ret0 == ERROR_SUCCESS)
{
LPBYTE owner=new BYTE[80];
DWORD type=REG_SZ ; DWORD dData=80;
long ret=::RegQueryValueEx(hKEY, "RegisteredOwner", NULL,&type, owner, &dData);
if(ret == ERROR_SUCCESS)
strSQLSrvName=CString(owner);
delete[] owner;
AfxMessageBox("Your SQL SERVER's name is:"+strSQLSrvName); }
::RegCloseKey(hKEY);
//就不解说了吧,拿去运行一下就知道了~