InstalledPrograms.7z
DWORD GetRegistryValues(HKEY hRootKey, LPCTSTR pszSubPath, std::vector& Items)
{
/*
if
SystemComponent is Exists and Set 1, then this pass
if
ParentDisplayName is Exists
ParentKeyName is Exists
ReleaseType is Exists, then this pass
*/
CRegistry RegUninstBase(CREG_NOCACHE);
if ( RegUninstBase.Open( pszSubPath, hRootKey, KEY_ENUMERATE_SUB_KEYS|KEY_QUERY_VALUE ) )
{
TCHAR szKeyItem[MAX_PATH];
while ( RegUninstBase.EnumSubKey(szKeyItem, MAX_PATH) == ERROR_SUCCESS )
{
WaitForSingleObject(GetCurrentThread(), 1);
TCHAR szKeyPath[MAX_PATH];
StringCchPrintf(szKeyPath, MAX_PATH, _T("%s\\%s"), pszSubPath, szKeyItem );
CRegistry RegUninstItem(CREG_NOCACHE);
if ( RegUninstItem.Open( szKeyPath, hRootKey, KEY_QUERY_VALUE ) )
{
LPTSTR pszDisplayName = RegUninstItem[_T("DisplayName")];
LPCTSTR pszParentKeyName = RegUninstItem[_T("ParentKeyName")];
LPCTSTR pszParentDisplayName = RegUninstItem[_T("ParentDisplayName")];
BOOL bExistSystemComponentKey = RegUninstItem[_T("SystemComponent")].Exists();
BOOL bIsSystemComponent = (BOOL)(int) RegUninstItem[_T("SystemComponent")];
if ( _tcslen(pszParentDisplayName) > 0 || _tcslen(pszParentKeyName) > 0 )
{
// This is Package Install Software
}
else if ( bExistSystemComponentKey && bIsSystemComponent )
{
// This is System Component Base-Root
}
else if ( _tcslen(pszDisplayName) > 0 )
{
TCHAR szLocalized[MAX_PATH];
LPCTSTR pszFinalDisplayName = pszDisplayName;
if ( RegUninstItem[_T("DisplayName_Localized")].Exists() )
{
DWORD dwSize = 0;
LPCTSTR pszDisplayNameLocalized = RegUninstItem[_T("DisplayName_Localized")];
if ( _tcslen(pszDisplayNameLocalized) > 1 )
{
if ( RegLoadMUIString(RegUninstItem.hKey, _T("DisplayName_Localized"), szLocalized, MAX_PATH, &dwSize, NULL, NULL ) == ERROR_SUCCESS )
{
pszFinalDisplayName = szLocalized;
}
}
}
INSTALLINFO II;
StringCchCopy(II.szDisplayName, MAX_PATH, pszFinalDisplayName);
StringCchCopy(II.szDisplayIcon, MAX_PATH, RegUninstItem[_T("DisplayIcon")]);
StringCchCopy(II.szDisplayVersion, MAX_PATH, RegUninstItem[_T("DisplayVersion")]);
StringCchCopy(II.szHelpLink, MAX_PATH, RegUninstItem[_T("HelpLink")]);
StringCchCopy(II.szHelpTelephone, MAX_PATH, RegUninstItem[_T("HelpTelephone")]);
StringCchCopy(II.szInstallDate, MAX_PATH, RegUninstItem[_T("InstallDate")]);
StringCchCopy(II.szInstallLocation, MAX_PATH, RegUninstItem[_T("InstallLocation")]);
StringCchCopy(II.szInstallSource, MAX_PATH, RegUninstItem[_T("InstallSource")]);
StringCchCopy(II.szPublisher, MAX_PATH, RegUninstItem[_T("Publisher")]);
StringCchCopy(II.szURLInfoAbout, MAX_PATH, RegUninstItem[_T("URLInfoAbout")]);
StringCchCopy(II.szURLUpdateInfo, MAX_PATH, RegUninstItem[_T("URLUpdateInfo")]);
StringCchCopy(II.szModifyPath, MAX_PATH, RegUninstItem[_T("ModifyPath")]);
StringCchCopy(II.szUninstallString, MAX_PATH, RegUninstItem[_T("UninstallString")]);
StringCchCopy(II.szQuietUninstallString, MAX_PATH, RegUninstItem[_T("QuietUninstallString")]);
StringCchCopy(II.szRegistryKey, MAX_PATH, szKeyItem);
StringCchCopy(II.szRegistryPath, MAX_PATH, szKeyPath);
II.dwEstimatedSize = RegUninstItem[_T("EstimatedSize")];
II.dwLanguage = RegUninstItem[_T("Language")];
if ( hRootKey == HKEY_LOCAL_MACHINE )
II.bIsInstalledUserAccount = FALSE;
else
II.bIsInstalledUserAccount = TRUE;
#ifdef _M_X64
if ( _tcsnicmp( szKeyPath, _T("SOFTWARE\\Microsoft"), _tcslen(_T("SOFTWARE\\Microsoft"))) == 0 )
II.bIsX64 = TRUE;
else
II.bIsX64 = FALSE;
#else
II.bIsX64 = FALSE;
#endif
Items.push_back(II);
}
}
}
}
return ERROR_SUCCESS;
}
void GetInstalledPrograms(std::vector& Items)
{
struct _REGISTRYPATH
{
HKEY hRootKey;
LPCTSTR pszRegistryPath;
}
RegistryPath[] =
{
{ HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall") }
, { HKEY_USERS, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall") }
, { HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall") }
, { HKEY_USERS, _T("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall") }
};
#ifdef _M_X64
const int MAX_LOOP = 4;
#else
const int MAX_LOOP = 2;
#endif
for (int i=0; i
최근 댓글