一、獲取安裝程序信息
#include <windows.h>
#include <iostream>
#include <>
#include <vector>
strName;
strDisplayName;
strPublisher;
strVersion;
strDisPlayVersion;
strInstallLocation;
GetAppInfoA(HKEY hKey, LPCSTR lpszAppName, LPCSTR lpszKeyValueName, &
iRet = RegOpenKeyExA(hKey, lpszAppName, , KEY_ALL_ACCESS, & (iRet != -
DWORD dwKeyValueType = DWORD dwKeyValueDataSize =
iRet = RegQueryValueExA(hInstallAppKey, lpszKeyValueName, NULL, &dwKeyValueType, NULL, & (iRet == (iRet != -
(dwKeyValueType !=
LPSTR lpszKeyValueData = [dwKeyValueDataSize + memset(lpszKeyValueData, , dwKeyValueDataSize +
iRet = RegQueryValueExA(hInstallAppKey, lpszKeyValueName, NULL, &dwKeyValueType, (LPBYTE)lpszKeyValueData, & (iRet != -
strKeyValue =
GetAllInstalledAppInfoA(vector<ApplicationInfoA> & LPCSTR lpszSubKey = iRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, lpszSubKey, , KEY_ALL_ACCESS, & (iRet != -
iRet = & & & & & (iRet != -
DWORD dwNameLen = dwMaxSubKeyNameLen + LPSTR lpszSubKeyName =
(dwIndex = ; dwIndex < dwSubKeysCnt; ++ dwNameLen = dwMaxSubKeyNameLen + memset(lpszSubKeyName,
iRet = RegEnumKeyExA(hKey, dwIndex, lpszSubKeyName, & (iRet != -
appInfo.strName = GetAppInfoA(hKey, lpszSubKeyName, GetAppInfoA(hKey, lpszSubKeyName, GetAppInfoA(hKey, lpszSubKeyName, GetAppInfoA(hKey, lpszSubKeyName, GetAppInfoA(hKey, lpszSubKeyName,
main( argc, ** cout << <<
vector<ApplicationInfoA> cout << GetAllInstalledAppInfoA(vecAppInfo) <<
(vector<ApplicationInfoA>::const_iterator iter = vecAppInfo.begin(); iter != vecAppInfo.end(); ++ cout << << cout << << iter->strName << cout << << iter->strDisplayName << cout << << iter->strPublisher << cout << << iter->strVersion << cout << << iter->strDisPlayVersion << cout << << iter->strInstallLocation << cout << << cout << cout <<
}
二、添加環境變量
_CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <iostream>
#include <>
LPCSTR lpszSubKey =
iRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, lpszSubKey, , KEY_ALL_ACCESS, & (ERROR_SUCCESS != cout << << -
LPCSTR lpszKeyValueName = DWORD dwKeyValueType = DWORD dwKeyValueDataSize =
iRet = RegQueryValueExA(hKey, lpszKeyValueName, NULL, &dwKeyValueType, NULL, & (ERROR_FILE_NOT_FOUND != iRet = RegSetValueExA(hKey, lpszKeyValueName, , REG_EXPAND_SZ, ( BYTE*), (ERROR_SUCCESS != cout << << - (ERROR_SUCCESS != cout << << - (REG_EXPAND_SZ != cout << << cout << dwKeyValueType << -
*lpszKeyValueData = [dwKeyValueDataSize + memset(lpszKeyValueData, , dwKeyValueDataSize +
iRet = RegQueryValueExA(hKey, lpszKeyValueName, NULL, &dwKeyValueType, (LPBYTE)lpszKeyValueData, & (ERROR_SUCCESS != cout << << -
unsigned iLen = iLen += *lpszKeyValueData_New = [iLen + memset(lpszKeyValueData_New, , iLen + sprintf(lpszKeyValueData_New, iRet = RegSetValueExA(hKey, lpszKeyValueName, , REG_EXPAND_SZ, ( BYTE*)lpszKeyValueData_New, iLen + (ERROR_SUCCESS != cout << << -
main( argc, * cout << AddPathEnvValue() << }