日誌原文:
編寫軟體登錄檔的讀寫是基本的操作,這裡直接將源**貼出來,大家共享並擴充套件,希望大家還可以回來,將您的**貼出來,共同進步,這裡對網友的幫助表示感謝。
// regop.cpp: implementation of the regop class.
//註冊軟體
//#include "stdafx.h"
#include "regop.h"
#ifdef _debug
#undef this_file
static char this_file=__file__;
#define new debug_new
#endif
//// construction/destruction
//regop::regop()
regop::~regop()
regop::err regop::setstrvalue(hkey hmainkey, cstring szsubkey, cstring szitem, cstring szvalue)
//***********************************設定登錄檔值
lrslt = regsetvalueex(hrsltkey, szitem, null, reg_sz,
lpbyte(szvalue.getbuffer(szvalue.getlength())), szvalue.getlength());
if (lrslt != error_success)
//****************************************====關閉登錄檔鍵
if (hmainkey)
if (hrsltkey)
return err_success;
}regop::err regop::getstrvalue(hkey hmainkey, cstring szsubkey, cstring szitem, cstring& szvalue)
lpbyte lpdata = new byte[256];
dword dwtype = reg_sz;
dword dwnum = 256;
//查詢登錄檔項值
long lrslt = regqueryvalueex(hrsltkey, szitem, 0, &dwtype, lpdata, &dwnum);
if (lrslt != error_success)
szvalue = (cstring)lpdata;
//關閉開啟的鍵
if (hmainkey)
if (hrsltkey)
return err_success;
}regop::err regop::addsubkey(hkey hmainkey, cstring szsubkey)
//******************************====如果不存在,則增加此子鍵
long lrslt = regcreatekey(hmainkey, szsubkey, &hrsltkey);
// long lcrtrslt = regcreatekey(hkey_local_machine, "software\\wzj", &hrsltkey);
if (lrslt != error_success)
//******************************=關閉開啟的登錄檔鍵控制代碼
if(hmainkey)
if (hrsltkey)
return this->err_success;
}regop::err regop::deletestrvalue(hkey hmainkey, cstring szsubkey, cstring szitem)
//刪除登錄檔項
lrslt = regdeletevalue(hrsltkey, szitem);
if (lrslt != error_success)
return err_success;
}regop::err regop::deletesubkey(hkey hmainkey, cstring szsubkey)
//關閉開啟的鍵
if (hmainkey)
return err_success;
}以下是.h檔案
// regop.h: inte***ce for the regop class.
////
#if !defined(afx_regop_h__0459ccae_b265_4678_8e70_ce31ba8c2784__included_)
#define afx_regop_h__0459ccae_b265_4678_8e70_ce31ba8c2784__included_
#if _msc_ver > 1000
#pragma once
#endif // _msc_ver > 1000
class regop
;enum hkey
;public:
regop();
virtual ~regop();
public:
//設定或修改登錄檔字串型別值
err setstrvalue(hkey hmainkey, cstring szsubkey, cstring szitem, cstring szvalue);
//查詢得到登錄檔字串型別值
err getstrvalue(hkey hmainkey, cstring szsubkey, cstring szitem, cstring& szvalue);
//刪除登錄檔中項
err deletestrvalue(hkey hmainkey, cstring szsubkey, cstring szitem);
//增加登錄檔子鍵
err addsubkey(hkey hmainkey, cstring szsubkey);
//刪除登錄檔子鍵
err deletesubkey(hkey hmainkey, cstring szsubkey);
};#endif // !defined(afx_regop_h__0459ccae_b265_4678_8e70_ce31ba8c2784__included_)
大家用的時候也要記得回來豐富我的小站。謝謝大家!
VC操作登錄檔
1.vc讀取登錄檔資訊 hkey hkey lpctstr data set software yeete s long ret5 regopenkeyex hkey local machine,data set,0,key write key read,hkey long ret0 regdele...
VC操作登錄檔
vc操作登錄檔 邵盛松 2010 3 2 新增標頭檔案atlbase.h 寫入登錄檔鍵值 以設定字串值為例 cstring strpath t c name.exe cregkey key if key.create hkey local machine,t software microsoft w...
VC 登錄檔操作
獲取登錄檔值 hkey hkey lpctstr data set software internet long ret0 regopenkeyex hkey local machine,data set,0,key all access,hkey lpbyte lpa new byte 500 d...