VC 讀登錄檔獲取安裝程式

2021-08-27 02:18:15 字數 2570 閱讀 6083

windows 系統中,安裝程式都可以在登錄檔hkey_local_machine\software\microsoft\windows\currentversion\uninstall 獲取,並且xp、vista、win7、win8都一樣

開啟登錄檔命令:regedit,依次展開上述登錄檔路徑,安裝程式列表如下圖:

獲取系統安裝程式列表:

// 獲取系統安裝程式列表 

bool cmylistctrltestdlg::allregkey(hkey hkey, lpctstr szdeskeyitem)

; dword cbname = 256*sizeof(tchar);

lresult = regenumkeyex(hsubkey, dwindex, szkeyname, &cbname, 0, null, null, null); // 獲取字段

while (lresult == error_success && lresult != error_more_data)

regclosekey(hsubkey); // 關閉登錄檔

return true;

} regclosekey(hsubkey);

return false;

}

獲取安裝程式屬性資訊(二次讀取登錄檔):

bool softlist::allregkey(hkey hkey, lpctstr szdeskeyitem)

; // 軟體名

tchar s_displayname[256] = ; // 顯示名稱

tchar s_publisher[256] = ; // 發布者

tchar s_installdate[12] = ; // 安裝日期

dword s_estimatedsize; // 大小

tchar s_displayversion[256] = ; // 版本

dword cbname = 256*sizeof(tchar);

dword cbname2 = sizeof(tchar);

dword typesz = reg_sz; // sz 登錄檔型別

dword typedword = reg_dword; // dword 登錄檔型別

lresult = regenumkeyex(hsubkey, dwindex, s_name, &cbname, 0, null, null, null); // 獲取字段

while (lresult == error_success && lresult != error_more_data)

if (::regqueryvalueex(hitem, _t("publisher"), 0, &typesz, (lpbyte)s_publisher, &cbname) == error_success)

if (::regqueryvalueex(hitem, _t("installdate"), 0, &typesz, (lpbyte)s_installdate, &cbname) == error_success)

}if (::regqueryvalueex(hitem, _t("estimatedsize"), 0, &typedword, (lpbyte)&s_estimatedsize, &cbname2) == error_success)

if (::regqueryvalueex(hitem, _t("displayversion"), 0, &typesz, (lpbyte)s_displayversion, &cbname) == error_success)

::regclosekey(hitem); // 關閉二級登錄檔(程式屬性資訊)

}dwindex = dwindex + 1; // 改變dwindex,迴圈獲取下移字段

cbname = 256*sizeof(tchar);

lresult = regenumkeyex(hsubkey, dwindex, s_name, &cbname, 0, null, null, null);

id++;

} regclosekey(hsubkey); // 關閉一級登錄檔(讀取程式資訊)

return true;

} regclosekey(hsubkey);

return false;

}

通過登錄檔路徑獲取呼叫:

allregkey(hkey_local_machine, text("software\\microsoft\\windows\\currentversion\\uninstall"));
執行結果:

VC 讀登錄檔獲取安裝程式

windows 系統中,安裝程式都可以在登錄檔hkey local machine software microsoft windows currentversion uninstall獲取,並且xp vista win7 win8都一樣 開啟登錄檔命令 regedit,依次展開上述登錄檔路徑,安裝...

VC 讀登錄檔獲取安裝程式

windows 系統中,安裝程式都可以在登錄檔 hkey local machine software microsoft windows currentversion uninstall 獲取,並且xp vista win7 win8都一樣 開啟登錄檔命令 regedit,依次展開上述登錄檔路徑,...

VC讀寫登錄檔

讀登錄檔 void cregeditdlg onquery 查詢有關的資料 lpbyte owner get new byte 80 dword type 1 reg sz dword cbdata 1 80 long ret1 regqueryvalueex hkey,registeredowne...