posts - 12,  comments - 5,  trackbacks - 0
CRegKey reg;  
   
  if(reg.Open(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\Control\\Session Manager\\Environment\\")==ERROR_SUCCESS)   //   路径自定  
  {  
        TCHAR     path[MAX_PATH];  
        DWORD     dw = MAX_PATH;
        if(ERROR_SUCCESS==reg.QueryValue(path,"path",&dw))  
        {   
               MessageBox(path,"找到Path了");   
               CString AltPath = path; 
               CString str;
               //长度
               str.Format("%d",AltPath.GetLength());
               MessageBox(str);
               //显示字符的位置
               str.Format("%d",AltPath.Find("需要的字符串;",1));
               MessageBox(str);
               //删除原来的字符串
               AltPath.Delete(AltPath.Find("字符串;",1),13);
               MessageBox(AltPath);
               //添加新路径
               AltPath.Insert(AltPath.GetLength(),"添加的新字符串;");
               reg.SetValue(HKEY_LOCAL_MACHINE,"System\\CurrentControlSet\\Control\\Session     Manager\\Environment\\path",AltPath,"");
               reg.SetValue(AltPath,"path");
               reg.QueryValue(path,"path",&dw);
               MessageBox(path);
               reg.Close();
           }  
 
  } 
  else
  {
  MessageBox("lalal");
     //注册表键值不存在  
  MessageBox("Path   Not   Found!");
  } 
posted on 2006-09-28 08:51 小歪 阅读(1285) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

Welcome!

常用链接

留言簿(1)

随笔档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜