虽然是转载的文章,但是看来还是每天要坚持呀。一不留神,都几天没有写点东西了,记忆中都有空白了,呵呵
用代码实现远程注册表的文章
SDK實現如下:
int i;
HKEY hKey;
BOOL bResult = TRUE;
DWORD lResult;
//打開子鍵
//比如:主鍵HKEY_CURRENT_USER,枚舉其子鍵下"Softwa....rPorts\\"的所有值
lResult = RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows NT\\CurrentVersion\\PrinterPorts\\",
0, KEY_QUERY_VALUE,hKey);
if (lResult != ERROR_SUCCESS)
{
return FALSE;
}
//開始枚舉鍵值
for (i = 0; ;i++) //中間為空,沒有進行i值的比較
{
TCHAR szValueName[_MAX_PATH + 1];
DWORD dwValueName = sizeof(szValueName);
DWORD dwValueType;
lResult = RegEnumValue(hKey,i,szValueName,dwValueName,
NULL,dwValueType,NULL,NULL);
if (lResult != ERROR_SUCCESS) //通過此項退出循環
{
if (lResult != ERROR_NO_MORE_ITEMS) bResult = FALSE;
break;
}
szValueName[dwValueName] = (TCHAR) '\n';
//如果成功,則將其顯示出來
MessageBox(NULL,szValueName,"Key Value",MB_OK);
}
if (i == 0)
{
MessageBox(NULL,"Can not find KeyValue","Key Value",MB_OK);
}
RegCloseKey(hKey);
return bResult;
阅读(683) | 评论(0) | 转发(0) |