#include <iostream>
#include <Windows.h>
#include <Shlwapi.h>
using namespace std;
#pragma comment(lib,”Shlwapi.lib”)
void regedit(LPCTSTR path);
int main()
{
regedit(L”Software\\Valve\\Steam”);
getchar();
return 0;
}
void regedit(LPCTSTR path)
{
HKEY hkey;
LONG lRet = RegOpenKeyEx(HKEY_CURRENT_USER, path, 0, KEY_ALL_ACCESS, &hkey);
if (ERROR_SUCCESS != lRet)cout<<“RegOpenKeyEx fail!”<<endl;
//获取注册表项值
wchar_t getbuffer[100];
DWORD dwsize = 100;
lRet = RegGetValue(hkey, NULL, L”SteamExe”, RRF_RT_REG_SZ, NULL, (LPDWORD)getbuffer, &dwsize);
if (ERROR_SUCCESS != lRet)cout<<“RegGetValue fail!”<<endl;
wcout<<getbuffer<<endl;
//删除注册表项
lRet =RegDeleteValue(hkey,L”Language”);
if (ERROR_SUCCESS != lRet)cout<<“RegDeleteValue fail!”<<endl;
//修改和增加注册表项
wchar_t lan[20]=L”chinese”;// 修改值 //如果密钥中不存在具有此名称的值,则该函数会将其添加到密钥
lRet = RegSetValueEx(hkey, L”Language”, 0, REG_SZ, (BYTE*)lan, dwsize);
if (ERROR_SUCCESS != lRet)cout<<“RegSetValueEx fail!”<<endl;
//注册表删除子项,此处删除ActiveProcess
SHDeleteKey(HKEY_CURRENT_USER,L”Software\\Valve\\Steam\\ActiveProcess”);
//添加注册表子项,此处添加ActiveProcess
HKEY hke = NULL;
DWORD dw;
lRet = RegCreateKeyExA(HKEY_CURRENT_USER,”Software\\Valve\\Steam\\ActiveProcess”, 0, REG_NONE,REG_OPTION_NON_VOLATILE,KEY_WRITE |KEY_READ,NULL,&hke,&dw);
if (ERROR_SUCCESS != lRet)cout<<“RegCreateKeyExA fail!”<<endl;
}