write_dword();
}
break;
default:
cout << "当前笔记本键盘状态获取未知 " << "(" << hex << dwValue << ")" << endl << endl;
break;
}
}
::RegCloseKey(hKEY);
}
//测试成功,读取到start设备名displayname//读取操作表,其类型为REG_SZ
void read_reg_sz(){
HKEY hkey;
LPCTSTR data_set = _T("SYSTEM\\CurrentControlSet\\Services\\i8042prt");
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, data_set, 0, KEY_READ, &hkey)){
char dwValue[256];
DWORD dwSzType = REG_SZ;
DWORD dwSize = sizeof(dwValue);
if (::RegQueryValueEx(hkey, _T("DisplayName"), 0, &dwSzType, (LPBYTE)&dwValue, &dwSize) != ERROR_SUCCESS){
cout << "无法查询有关的注册表信息" << endl << endl;
}
cout << "当前设备名:" << dwValue << endl << endl;
}
::RegCloseKey(hkey);
}
//测试成功,更改(创建)到start键值//在SYSTEM\CurrentControlSet\Services\i8042prt文件夹下读取Start的子键,设置其值为dwValue
void write_dword(){
HKEY hkey;//定义有关的hkey,在查询结束时要关闭
HKEY hTempKey;
char ans;
int flag;
DWORD dwValue;
DWORD dwSize = sizeof(DWORD);
DWORD dwType = REG_DWORD;
LPCTSTR data_set = _T("SYSTEM\\CurrentControlSet\\Services\\i8042prt");
cout << "请设置当前笔记本键盘状态,输入数字:3,表示开启键盘;输入数字4,表示禁用键盘;" << endl;
cin >> flag;
switch (flag) {
case 3:
dwValue = flag; break;
case 4:
dwValue = flag; break;
default:
cout << "状态值输入错误" << endl; break;
}
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, data_set, 0, KEY_SET_VALUE, &hkey)){
//if (ERROR_SUCCESS == ::RegCreateKey(hkey, _T("解开该段落注释,则可更改为:在SYSTEM\\CurrentControlSet\\Services\\i8042prt下,创建以'该文本内容'为名称的子健,并创建一个名为“Start”的子健,其值为:dwValue"), &hTempKey)){
if (ERROR_SUCCESS != ::RegSetValueEx(hkey, _T("Start"), 0, REG_DWORD, (CONST BYTE*) & dwValue, sizeof(DWORD))){
cout << "写入注册表失败" << endl;
}
cout << "修改成功!" << endl << "是否立刻重启电脑,使设置立即生效?" << endl << "输入y或Y,以立刻重新启动电脑;输入n或N退出程序" << endl;
cin >> ans;
if (ans == 'y' (北联网教程,专业提供视频软件下载)
……
operatereg.exe【C++】-operatereg.exe【C++】下载 v免费绿色版 >>本地高速下载
>>本地下载