VC讀寫登錄檔

2021-04-13 09:10:13 字數 1403 閱讀 8775

讀登錄檔:

void cregeditdlg::onquery()

//查詢有關的資料

lpbyte owner_get=new byte[80];

dword type_1=reg_sz;

dword cbdata_1=80;

long ret1=::regqueryvalueex(hkey,"registeredowner",null,&type_1,owner_get,&cbdata_1);

if(ret1!=error_success)

lpbyte company_get=new byte[80];

dword type_2=reg_sz;

dword cbdata_2=80;

long ret2=::regqueryvalueex(hkey,"registeredorganization",null,&type_2,company_get,&cbdata_2);

if(ret2!=error_success)

//將owner_get company_get轉換成cstring

m_strowner=cstring(owner_get);

m_strcompany=cstring(company_get);

delete owner_get;

delete company_get;

//close the connection

::regclosekey(hkey);

updatedata(false);

}寫登錄檔:

void cregeditdlg::onmodify()

lpbyte owner_set=cstring_to_lpbyte(m_strowner);

dword type_1=reg_sz;

dword cbdata_1=m_strowner.getlength()+1;

long ret1=::regsetvalueex(hkey,"registeredowner",null,type_1,owner_set,cbdata_1);

if(ret1=error_success)

lpbyte company_set=cstring_to_lpbyte(m_strcompany);

dword type_2=reg_sz;

dword cbdata_2=m_strcompany.getlength()+1;

long ret2=::regsetvalueex(hkey,"registeredorganization",null,type_2,company_set,cbdata_2);

if(ret1=error_success)

else

}lpbyte cregeditdlg::cstring_to_lpbyte(cstring str)

VC 讀寫登錄檔

讀伺服器執行狀態 int readregimgsrvstate char ppcrunstate long rv regopenkeyex hkey local machine,keyitem,0,key read,hkey if rv error success rv regsetvalueex ...

讀寫登錄檔

ie 是現在windows 平台下用的最多的瀏覽器,那麼如何用程式來修改 ie,打造有自己的特色的 ie呢?我在這裡向介紹怎麼 c 用通過登錄檔來修改ie。首先我們來熟悉一下 c 中修改登錄檔的方法與函式。在 vc 中提供了 registry 類 registrykey 類來實現對登錄檔的操作。其中...

讀寫登錄檔

寫登錄檔 registrykey regwrite 往hkey current user主鍵裡的software子鍵下寫乙個名為 test 的子鍵 如果test子鍵已經存在系統會自動覆蓋它 regwrite registry.currentuser.createsubkey software tes...