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
小歪 閱讀(1323)
評論(0) 編輯 收藏 引用