bool readstrregtable(hkey hkey, lpcstr lpsubkey, lpcstr lpitemname, tchar* pvalue)
else
return false;
return true;
}bool readdwregtable(hkey hkey, lpcstr lpsubkey, lpcstr lpitemname, dword* value)
else
return false;
return true;
}bool createstrregitem(hkey hkey, lpcstr lpsubkey, lpcstr lpitemname, tchar* pvalue)
else
return false;
return true;
}bool createdwregitem(hkey hkey, lpcstr lpsubkey, lpcstr lpitemname, dword dwvalue)
else
return false;
return true;
}上面幾個函式比較簡單,但使用上有很大的侷限性:它們的第乙個引數必須是rootkey,或者是通過先呼叫regopenkeyex獲取相應的hkey作為第乙個引數。
主要介紹一下下面這個函式,它的第乙個引數要求傳入乙個字串,一般的格式為:
"hkey_current_user//software//videohome//skypetv";
可以看出,要使此函式發揮作用,你必須將你想要操作的hkey在登錄檔中的完整路徑
作為乙個字串傳入,第二個引數傳入乙個指標或位址,用於儲存需要的hkey
bool openregkey(tchar* pszregpath,hkey* hkeyreturned)
memset(buf,0,length);
memcpy(buf,pszregpath,length);
memset(strkey1,0,256);
memset(strkey2,0,256);
int j = 0;
for ( int i=0; ielse
if( strcmp(strkey1,"")!=0 && strcmp(strkey2,"")!=0 )
else
}//strkey2 = strkey1;
memcpy(strkey2,strkey1,length);
memset(strkey1,0,length);}}
lresult = regopenkeyex(hkeyopened,strkey1,0,key_read|key_write,hkeyreturned);
lresult = regclosekey(hkeyopened);
if( lresult != error_success )
return false;
return true;
}
VC讀寫登錄檔
讀登錄檔 void cregeditdlg onquery 查詢有關的資料 lpbyte owner get new byte 80 dword type 1 reg sz dword cbdata 1 80 long ret1 regqueryvalueex hkey,registeredowne...
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...