最近需要開發乙個小工具,用於清除登錄檔中的一些註冊資訊,這裡的技術點有以下幾點:
1) 查詢登錄檔指定項資訊;根據給定的登錄檔項名稱,查詢項的資訊,如包含子項的數量。
2) 迴圈查詢子項;由於登錄檔中的子項名稱不知道,只能根據指定的項下面,迴圈取得子項,然後匹配子項中的特定的鍵和鍵值,從而確定子項。
3) 查詢子項中的鍵和鍵值。
4) 刪除子項。
具體的**如下:
首先取得項的資訊:
retcode = regqueryinfokey(
hkey, // key handle
achclass, // buffer for class name
&cchclassname, // size of class string
null, // reserved
&csubkeys, // number of subkeys
&cbmaxsubkey, // longest subkey size
&cchmaxclass, // longest class string
&cvalues, // number of values for this key
&cchmaxvalue, // longest value name
&cbmaxvaluedata, // longest value data
&cbsecuritydescriptor, // security descriptor
&ftlastwritetime); // last write time
if (csubkeys) //如果子項的數量不為零
else }}
zeromemory( lpvalue,dwvaluelen );}}
regclosekey(hsubkey);
}//_tprintf(text("(%d) %s/n"), i+1, achkey);}}
}在此函式中分別呼叫了regqueryinfokey,regenumkeyex,regopenkeya,regqueryvalueex,shdeletekey和regclosekey 函式,具體使用 可以參看msdn online
C 中對登錄檔的操作 讀寫登錄檔方法
從登錄檔中讀資訊 要讀取的鍵值 讀到的鍵值字串,如果失敗 如登錄檔尚無資訊 則返回 private function readinfo byval p keyname as string dim softwarekey as registrykey registry.localmachine.ope...
C 中對登錄檔的操作
windows 作業系統的登錄檔包含了很多有關計算機執行的配置方式,開啟登錄檔我們可以看到登錄檔是按類似於目錄的樹結構組織的,其中第二級目錄包含了五個預定義主鍵分別是 hkey classes root,hkey current user,hkey local machine,hkey users,...
C 中對登錄檔的操作
c 中對登錄檔的操作 c 中對登錄檔的操作 windows 作業系統的登錄檔包含了很多有關計算機執行的配置方式,開啟登錄檔我們可以看到登錄檔是按類似於目錄的樹結構組織的,其中第二級目錄包含了五個預定義主鍵分別是 hkey classes root,hkey current user,hkey loc...