VC 操作登錄檔

2021-06-07 18:59:14 字數 1148 閱讀 6257

操作登錄檔的一般步驟如下:

1、呼叫regopenkeyex()或regcreatekeyex()來開啟或新建乙個鍵。即登錄檔左邊顯示的資料夾。

如:regopenkeyex(hkey_local_machine,"software\\microsoft\\windows\\currentversion\\uninstall\\驅動1", 0, key_all_access, &hkey),其成功返回error_success,錯誤為對應的數字

2、再呼叫regqueryvalueex()讀子鍵的值,或呼叫regsetvalueex()設定子鍵的值,或呼叫regdeletevalue刪除指定的項。

如:regqueryvalueex(hkey, "uninstallstring", null, &dwtype, (unsigned char *)(lpstr)lpstrreturn, &dwlength) ;

dword dwret = getmodulefilename(null, pfilename, max_path); //新增乙個子key,並設定值 // 下面的第二項是應用程式名字(不加字尾.exe)

lret = regsetvalueex(hkey, "scheduler", 0, reg_sz, (byte *)pfilename, dwret);

regdeletevalue(hkey,"scheduler");  //hkey為開啟的鍵,第二個引數為要刪除的項名。

3、呼叫regclosekey()關閉鍵。

lpstr lpstrreturn = (lpstr)new char[255];

hkey hkey = 0 ;

dword dlen = 256;

dword dwtype = reg_sz;

regopenkeyex(hkey_local_machine,"software\\microsoft\\windows\\currentversion\\uninstall\\驅動1",0,key_all_access,&hkey);

regqueryvalue(hkey,"uninstallstring",null,&dwtype,(unsigned char *)(lpstr)lpstrreturn,&dwlen);

regclosekey(hkey);

delete lpstrreturn;

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...