Chinaunix首页 | 论坛 | 博客
  • 博客访问: 220301
  • 博文数量: 88
  • 博客积分: 3020
  • 博客等级: 中校
  • 技术积分: 707
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-12 16:56
文章分类
文章存档

2010年(26)

2009年(62)

我的朋友

分类:

2009-03-19 09:03:55

虽然是转载的文章,但是看来还是每天要坚持呀。一不留神,都几天没有写点东西了,记忆中都有空白了,呵呵
用代码实现远程注册表的文章
 
 
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;  
 
 
 
阅读(674) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~