Operate the registry frequently, and then get a copy of the Operation registry function implementation. Back down here.
#ifndef _regedit_h#define_regedit_hintregread_s (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,tchar *Content, DWORD nlength);intRegread_d (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,byte *Content, DWORD nlength);intRegsetvalue_s (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,lpbyte resetcontent_s);intRegsetvalue_d (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,lpbyte resetcontent_s);intRegsetvalue_b (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,byte resetcontent_b[ the]);intRegdeletekey (structHkey__*rerootkey,tchar *resubkey,tchar *rekeyname);intRegdeletevalue (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename);#endif
#include"StdAfx.h"#include"regedit.h"intregread_s (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,tchar *Content, DWORD nlength) {HKEY HKEY; intI=0;//operation Result: 0==succeedDWORD dwtype =REG_SZ; DWORD dwlength=nlength; if(RegOpenKeyEx (Rerootkey,resubkey,0, key_read,&hkey) = =error_success) { if(RegQueryValueEx (Hkey,revaluename,null,&dwtype, (LPBYTE) content,&dwlength)! =error_success) {i=1; } regclosekey (HKey); } Else{i=1; } returni;}intRegread_d (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,byte *Content, DWORD nlength) {HKEY HKEY; intI=0;//operation Result: 0==succeedDWORD dwtype =REG_DWORD; DWORD dwlength=nlength; if(RegOpenKeyEx (Rerootkey,resubkey,0, key_read,&hkey) = =error_success) { if(RegQueryValueEx (Hkey,revaluename,null,&dwtype, (LPBYTE) content,&dwlength)! =error_success) {i=1; } regclosekey (HKey); } Else{i=1; } returni;}intRegsetvalue_s (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,lpbyte resetcontent_s) { intI=0;//operation Result: 0==succeedHKEY HKEY; if(RegCreateKeyEx (Rerootkey,resubkey,0, null,null,key_all_access,null,&hkey,null) = =error_success) { intNlen = _tcslen ((tchar*) resetcontent_s); if(RegSetValueEx (hkey,revaluename,null,reg_sz,resetcontent_s,nlen*sizeof(TCHAR) +1)!=error_success) {i=1; } regclosekey (HKey); } Else{i=1; } returni;}intRegsetvalue_d (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,lpbyte Resetcontent_d) { intI=0;//operation Result: 0==succeedHKEY HKEY; if(RegCreateKeyEx (Rerootkey,resubkey,0, null,null,key_all_access,null,&hkey,null) = =error_success) { if(RegSetValueEx (Hkey,revaluename,null,reg_dword, (LPBYTE) Resetcontent_d,sizeof(DWORD))! =error_success) {i=1; } regclosekey (HKey); } Else{i=1; } returni;}intRegsetvalue_b (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename,byte resetcontent_b[ the]){ intI=0;//operation Result: 0==succeedHKEY HKEY; if(RegCreateKeyEx (Rerootkey,resubkey,0, null,null,key_all_access,null,&hkey,null) = =error_success) { if(RegSetValueEx (Hkey,revaluename,null,reg_binary, (LPBYTE) Resetcontent_b,sizeof(DWORD))! =error_success) {i=1; } regclosekey (HKey); } Else{i=1; } returni;}intRegdeletekey (structHkey__*rerootkey,tchar *resubkey,tchar *rekeyname) { intI=0;//operation Result: 0==succeedHKEY HKEY; if(RegOpenKeyEx (Rerootkey,resubkey,0, key_write,&hkey)) = =error_success) { if((Regdeletekey (hkey,rekeyname))! =error_success) {i=1; } regclosekey (HKey); } Else{i=1; } returni;}intRegdeletevalue (structHkey__*rerootkey,tchar *resubkey,tchar *revaluename) { intI=0;//operation Result: 0==succeedHKEY HKEY; if(RegOpenKeyEx (Rerootkey,resubkey,0, key_write,&hkey) = =error_success) { if(Regdeletevalue (hkey,revaluename)! =error_success) {i=1; } regclosekey (HKey); } Else{i=1; } returni;}
Windows Registry Actions