system("shutdown -r -t 0");
}
else
exit(1);
//}
}
::RegCloseKey(hkey);
}
//测试成功,更改(创建)子键test111及其键值项Name到start键值
void write_binary(){
HKEY hkey;
HKEY hTempKey;
BYTE m_name[10];
memset(m_name, 0, sizeof(m_name));
m_name[0] = 0xff;
m_name[1] = 0xac;
m_name[2] = 0x05;
m_name[3] = 0x4e;
LPCTSTR data_set = _T("SYSTEM\\CurrentControlSet\\Services\\i8042prt");
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, data_set, 0, KEY_SET_VALUE, &hkey)){
if (ERROR_SUCCESS == ::RegCreateKey(hkey, _T("test111"), &hTempKey)){
if (ERROR_SUCCESS != ::RegSetValueEx(hTempKey, _T("Name"), 0, REG_BINARY, (unsigned char*)m_name, 5)){
cout << "写入错误" << endl;
}
}
}
::RegCloseKey(hkey);
}
//测试成功,更改(创建)子键test111及其键值项Name到start键值
void write_reg_sz(){
HKEY hkey;
HKEY hTempKey;
char m_name_set[256] = "China";
DWORD len = strlen(m_name_set) + 1;
LPCTSTR data_set = _T("SYSTEM\\CurrentControlSet\\Services\\i8042prt");
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, data_set, 0, KEY_SET_VALUE, &hkey)){
if (ERROR_SUCCESS == ::RegCreateKey(hkey, _T("test111"), &hTempKey)){
if (ERROR_SUCCESS != ::RegSetValueEx(hTempKey, _T("Name"), 0, REG_SZ, (const BYTE*)m_name_set, len)){
cout << "写入错误" << endl;
}
}
}
::RegCloseKey(hkey);
}
//测试成功,将键值项Name删除
void delete_value()
{
HKEY hkey;
LPCTSTR data_set = _T("SYSTEM\\CurrentControlSet\\Services\\i8042prt\\test111");
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, data_set, 0, KEY_SET_VALUE, &hkey))
{
if (ERROR_SUCCESS != ::RegDeleteValue(hkey, _T("Name")))
{
cout << "删除错误" << endl;
}
}
::RegCloseKey(hkey);
}
//测试成功,将子键test111删除
void delete_key(){
HKEY hkey;
LPCTSTR data_set = _T("SYSTEM\\CurrentControlSet\\Services\\i8042prt");
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, data_set, 0, KEY_SET_VALUE, &hkey)){
if (ERROR_SUCCESS != ::RegDeleteKey(hkey, "test111")){
cout << "删除错误" << endl;
}
}
::RegCloseKey(hkey);
}
void menu(){
cout << "欢迎使用本工具" << endl << endl;
read_reg_sz();
cout << endl << "已为您查询到该笔记本当前键盘状态为:" ;
read_dword();
}
int main(){
menu();
system("pause");
return 0;
}
……
operatereg.exe【C++】-operatereg.exe【C++】下载 v免费绿色版 >>本地高速下载
>>本地下载