在注册表写入+读取当前软件的语言版本号+路径信息

{
DWORD pCount=1024;
TCHAR szValue[1024];
CString str;
CRegKey reg;
if ( ERROR_SUCCESS==reg.Create(HKEY_CURRENT_USER, _T("Software//Leyard")))
{

if (ERROR_SUCCESS==reg.QueryValue(szValue, _T("Language"), &pCount))
{
str.Format(_T("%s"), szValue);
}
else
{
str = _T("0");
reg.SetValue(str, _T("Language"));
}
}
return str;
}

void CLeadShowApp::SetLanguagePara(CString str)
{
CRegKey reg;
if ( ERROR_SUCCESS==reg.Create(HKEY_CURRENT_USER, _T("Software//Leyard")))
{
reg.SetValue(str, _T("Language"));
}
}




BOOL CLeadShowApp::SetAppPath(CString strSysPath)
{
HKEY hk;
if ( ::RegCreateKey( HKEY_CURRENT_USER, _T("SOFTWARE//Leyard//"), &hk ) != ERROR_SUCCESS )
{
//AfxMessageBox( "打开注册表失败" );
return FALSE;
}

strSysPath = strSysPath+_T("SuperEdit.exe");
LPBYTE BYTECtrlPath = (LPBYTE)strSysPath.GetBuffer(0);
DWORD Len = strSysPath.GetLength() +1;
DWORD type = REG_SZ;
LONG ret1 = ::RegSetValueEx(hk,_T("SuperEdit"),NULL,type,BYTECtrlPath,Len);
if (ret1 != ERROR_SUCCESS)
{
//MessageBox("错误: 无法修改有关注册表信息!");
::RegCloseKey(hk);
return FALSE;
}
::RegCloseKey(hk);
return TRUE;
}

CString CLeadShowApp::GetAppPath()
{
HKEY hk;
if ( ::RegOpenKey( HKEY_CURRENT_USER, _T("SOFTWARE//Leyard//"), &hk ) != ERROR_SUCCESS )
{
//AfxMessageBox( "打开注册表失败" );
return _T("");
}

TCHAR GetLan[80];
memset(GetLan,0,80);
CString SysPath;

DWORD Len = 80;
DWORD type = REG_SZ;
LONG ret1 = ::RegQueryValueEx(hk, _T("SuperEdit"),NULL,&type,(LPBYTE)GetLan,&Len);
if (ret1 != ERROR_SUCCESS)
{
//MessageBox("错误: 无法读取有关注册表信息!");
::RegCloseKey(hk);
return _T("");
}
::RegCloseKey(hk);
//CString str = (char *)GetLan;
SysPath.Format(_T("%s"), GetLan/*str.GetBuffer(0)*/);

return SysPath;
}
原文地址:https://www.cnblogs.com/carl2380/p/2317352.html