ReactOS 0.4.15-dev-8235-gcd88a97
CInstalledApplicationInfo Class Reference

#include <appinfo.h>

Inheritance diagram for CInstalledApplicationInfo:
Collaboration diagram for CInstalledApplicationInfo:

Public Member Functions

 CInstalledApplicationInfo (HKEY Key, const CStringW &KeyName, AppsCategories Category, UINT KeyInfo)
 
 ~CInstalledApplicationInfo ()
 
CRegKeyGetRegKey ()
 
virtual BOOL Valid () const override
 
virtual BOOL CanModify () override
 
virtual BOOL RetrieveIcon (CStringW &Path) const override
 
virtual BOOL RetrieveScreenshot (CStringW &Path) override
 
virtual VOID ShowAppInfo (CAppRichEdit *RichEdit) override
 
virtual VOID GetDownloadInfo (CStringW &Url, CStringW &Sha1, ULONG &SizeInBytes) const override
 
virtual VOID GetDisplayInfo (CStringW &License, CStringW &Size, CStringW &UrlSite, CStringW &UrlDownload) override
 
virtual InstallerType GetInstallerType () const override
 
virtual BOOL UninstallApplication (UninstallCommandFlags Flags) override
 
- Public Member Functions inherited from CAppInfo
 CAppInfo (const CStringW &Identifier, AppsCategories Category)
 
virtual ~CAppInfo ()
 
virtual BOOL Valid () const =0
 
virtual BOOL CanModify ()=0
 
virtual BOOL RetrieveIcon (CStringW &Path) const =0
 
virtual BOOL RetrieveScreenshot (CStringW &Path)=0
 
virtual VOID ShowAppInfo (CAppRichEdit *RichEdit)=0
 
virtual VOID GetDownloadInfo (CStringW &Url, CStringW &Sha1, ULONG &SizeInBytes) const =0
 
virtual VOID GetDisplayInfo (CStringW &License, CStringW &Size, CStringW &UrlSite, CStringW &UrlDownload)=0
 
virtual InstallerType GetInstallerType () const
 
virtual BOOL UninstallApplication (UninstallCommandFlags Flags)=0
 

Public Attributes

UINT m_KeyInfo
 
- Public Attributes inherited from CAppInfo
const CStringW szIdentifier
 
const AppsCategories iCategory
 
CStringW szDisplayIcon
 
CStringW szDisplayName
 
CStringW szDisplayVersion
 
CStringW szComments
 

Private Member Functions

BOOL GetApplicationRegString (LPCWSTR lpKeyName, CStringW &String)
 
BOOL GetApplicationRegDword (LPCWSTR lpKeyName, DWORD *lpValue)
 
VOID AddApplicationRegString (CAppRichEdit *RichEdit, UINT StringID, const CStringW &String, DWORD TextFlags)
 
VOID RetrieveInstallDate ()
 
VOID RetrieveUninstallStrings ()
 

Private Attributes

CRegKey m_hKey
 
CStringW m_szInstallDate
 
CStringW m_szUninstallString
 
CStringW m_szModifyString
 

Detailed Description

Definition at line 177 of file appinfo.h.

Constructor & Destructor Documentation

◆ CInstalledApplicationInfo()

CInstalledApplicationInfo::CInstalledApplicationInfo ( HKEY  Key,
const CStringW KeyName,
AppsCategories  Category,
UINT  KeyInfo 
)

Definition at line 388 of file appinfo.cpp.

392 : CAppInfo(KeyName, Category), m_hKey(Key), m_KeyInfo(KeyInfo)
393{
394 if (GetApplicationRegString(L"DisplayName", szDisplayName))
395 {
399 }
400}
CStringW szComments
Definition: appinfo.h:104
CStringW szDisplayIcon
Definition: appinfo.h:101
CStringW szDisplayName
Definition: appinfo.h:102
CStringW szDisplayVersion
Definition: appinfo.h:103
BOOL GetApplicationRegString(LPCWSTR lpKeyName, CStringW &String)
Definition: appinfo.cpp:630
#define L(x)
Definition: ntvdm.h:50
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

◆ ~CInstalledApplicationInfo()

CInstalledApplicationInfo::~CInstalledApplicationInfo ( )

Definition at line 402 of file appinfo.cpp.

403{
404}

Member Function Documentation

◆ AddApplicationRegString()

VOID CInstalledApplicationInfo::AddApplicationRegString ( CAppRichEdit RichEdit,
UINT  StringID,
const CStringW String,
DWORD  TextFlags 
)
private

Definition at line 407 of file appinfo.cpp.

412{
413 CStringW Tmp;
415 {
416 RichEdit->InsertTextWithString(StringID, Tmp, TextFlags);
417 }
418}
VOID InsertTextWithString(UINT StringID, const CStringW &Text, DWORD TextFlags)
Definition: appview.cpp:263
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by ShowAppInfo().

◆ CanModify()

BOOL CInstalledApplicationInfo::CanModify ( )
overridevirtual

Implements CAppInfo.

Definition at line 542 of file appinfo.cpp.

543{
545 {
547 }
548
549 return !m_szModifyString.IsEmpty();
550}
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
CStringW m_szUninstallString
Definition: appinfo.h:181

◆ GetApplicationRegDword()

BOOL CInstalledApplicationInfo::GetApplicationRegDword ( LPCWSTR  lpKeyName,
DWORD lpValue 
)
private

Definition at line 676 of file appinfo.cpp.

677{
678 DWORD dwSize = sizeof(DWORD), dwType;
679 if (RegQueryValueExW(m_hKey, lpKeyName, NULL, &dwType, (LPBYTE)lpValue, &dwSize) != ERROR_SUCCESS ||
680 dwType != REG_DWORD)
681 {
682 return FALSE;
683 }
684
685 return TRUE;
686}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define DWORD
Definition: nt_native.h:44
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by RetrieveInstallDate(), RetrieveUninstallStrings(), and UninstallApplication().

◆ GetApplicationRegString()

BOOL CInstalledApplicationInfo::GetApplicationRegString ( LPCWSTR  lpKeyName,
CStringW String 
)
private

Definition at line 630 of file appinfo.cpp.

631{
632 ULONG nChars = 0;
633 // Get the size
634 if (m_hKey.QueryStringValue(lpKeyName, NULL, &nChars) != ERROR_SUCCESS)
635 {
636 String.Empty();
637 return FALSE;
638 }
639
640 LPWSTR Buffer = String.GetBuffer(nChars);
641 LONG lResult = m_hKey.QueryStringValue(lpKeyName, Buffer, &nChars);
642 if (nChars > 0 && Buffer[nChars - 1] == UNICODE_NULL)
643 nChars--;
644 String.ReleaseBuffer(nChars);
645
646 if (lResult != ERROR_SUCCESS)
647 {
648 String.Empty();
649 return FALSE;
650 }
651
652 if (String.Find('%') >= 0)
653 {
654 CStringW Tmp;
656 if (dwLen > 0)
657 {
658 BOOL bSuccess = ExpandEnvironmentStringsW(String, Tmp.GetBuffer(dwLen), dwLen) == dwLen;
659 Tmp.ReleaseBuffer(dwLen - 1);
660 if (bSuccess)
661 {
662 String = Tmp;
663 }
664 else
665 {
666 String.Empty();
667 return FALSE;
668 }
669 }
670 }
671
672 return TRUE;
673}
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) noexcept
Definition: atlbase.h:1240
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
void Empty() noexcept
Definition: atlsimpstr.h:253
Definition: bufpool.h:45
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
static BOOLEAN bSuccess
Definition: drive.cpp:433
unsigned int BOOL
Definition: ntddk_ex.h:94
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
uint32_t ULONG
Definition: typedefs.h:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AddApplicationRegString(), CInstalledApplicationInfo(), RetrieveInstallDate(), RetrieveUninstallStrings(), and UninstallApplication().

◆ GetDisplayInfo()

VOID CInstalledApplicationInfo::GetDisplayInfo ( CStringW License,
CStringW Size,
CStringW UrlSite,
CStringW UrlDownload 
)
overridevirtual

Implements CAppInfo.

Definition at line 572 of file appinfo.cpp.

573{
574 ATLASSERT(FALSE && "Should not be called");
575}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10

◆ GetDownloadInfo()

VOID CInstalledApplicationInfo::GetDownloadInfo ( CStringW Url,
CStringW Sha1,
ULONG SizeInBytes 
) const
overridevirtual

Implements CAppInfo.

Definition at line 566 of file appinfo.cpp.

567{
568 ATLASSERT(FALSE && "Should not be called");
569}

◆ GetInstallerType()

InstallerType CInstalledApplicationInfo::GetInstallerType ( ) const
overridevirtual

Reimplemented from CAppInfo.

Definition at line 578 of file appinfo.cpp.

579{
580 CRegKey reg;
582 {
583 return INSTALLER_GENERATE;
584 }
585 return INSTALLER_UNKNOWN;
586}
#define GENERATE_ARPSUBKEY
Definition: appinfo.h:87
@ INSTALLER_UNKNOWN
Definition: appinfo.h:75
@ INSTALLER_GENERATE
Definition: appinfo.h:76
static int reg
Definition: i386-dis.c:1290
#define KEY_READ
Definition: nt_native.h:1023

Referenced by UninstallApplication().

◆ GetRegKey()

CRegKey & CInstalledApplicationInfo::GetRegKey ( )
inline

Definition at line 201 of file appinfo.h.

201{ return m_hKey; }

◆ RetrieveIcon()

BOOL CInstalledApplicationInfo::RetrieveIcon ( CStringW Path) const
overridevirtual

Implements CAppInfo.

Definition at line 553 of file appinfo.cpp.

554{
556 return !Path.IsEmpty();
557}
PRTL_UNICODE_STRING_BUFFER Path

◆ RetrieveInstallDate()

VOID CInstalledApplicationInfo::RetrieveInstallDate ( )
private

Definition at line 457 of file appinfo.cpp.

458{
459 DWORD dwInstallTimeStamp;
460 SYSTEMTIME InstallLocalTime;
461 if (GetApplicationRegString(L"InstallDate", m_szInstallDate))
462 {
463 ZeroMemory(&InstallLocalTime, sizeof(InstallLocalTime));
464 // Check if we have 8 characters to parse the datetime.
465 // Maybe other formats exist as well?
467 if (m_szInstallDate.GetLength() == 8)
468 {
469 InstallLocalTime.wYear = wcstol(m_szInstallDate.Left(4).GetString(), NULL, 10);
470 InstallLocalTime.wMonth = wcstol(m_szInstallDate.Mid(4, 2).GetString(), NULL, 10);
471 InstallLocalTime.wDay = wcstol(m_szInstallDate.Mid(6, 2).GetString(), NULL, 10);
472 }
473 }
474 // It might be a DWORD (Unix timestamp). try again.
475 else if (GetApplicationRegDword(L"InstallDate", &dwInstallTimeStamp))
476 {
477 FILETIME InstallFileTime;
478 SYSTEMTIME InstallSystemTime;
479
480 UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
481 FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
482
483 // convert to localtime
484 SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime, &InstallLocalTime);
485 }
486
487 // convert to readable date string
488 int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &InstallLocalTime, NULL, 0, 0);
489
491 LOCALE_USER_DEFAULT, // use default locale for current user
492 0, &InstallLocalTime, NULL, m_szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen);
494}
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:340
PXSTR GetString() noexcept
Definition: atlsimpstr.h:367
int GetLength() const noexcept
Definition: atlsimpstr.h:362
CStringT Left(int nCount) const
Definition: cstringt.h:776
CStringT & Trim()
Definition: cstringt.h:1046
CStringT Mid(int iFirst, int nCount) const
Definition: cstringt.h:748
BOOL GetApplicationRegDword(LPCWSTR lpKeyName, DWORD *lpValue)
Definition: appinfo.cpp:676
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
Definition: timezone.c:377
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:993
#define LOCALE_USER_DEFAULT
WORD wYear
Definition: winbase.h:905
WORD wMonth
Definition: winbase.h:906
WORD wDay
Definition: winbase.h:908
#define ZeroMemory
Definition: winbase.h:1712

Referenced by ShowAppInfo().

◆ RetrieveScreenshot()

BOOL CInstalledApplicationInfo::RetrieveScreenshot ( CStringW Path)
overridevirtual

Implements CAppInfo.

Definition at line 560 of file appinfo.cpp.

561{
562 return FALSE;
563}

◆ RetrieveUninstallStrings()

VOID CInstalledApplicationInfo::RetrieveUninstallStrings ( )
private

Definition at line 497 of file appinfo.cpp.

498{
499 DWORD dwWindowsInstaller = 0;
500 if (GetApplicationRegDword(L"WindowsInstaller", &dwWindowsInstaller) && dwWindowsInstaller)
501 {
502 // MSI has the same info in Uninstall / modify, so manually build it
504 }
505 else
506 {
508 }
509 DWORD dwNoModify = 0;
510 if (!GetApplicationRegDword(L"NoModify", &dwNoModify))
511 {
512 CStringW Tmp;
513 if (GetApplicationRegString(L"NoModify", Tmp))
514 {
515 dwNoModify = Tmp.GetLength() > 0 ? (Tmp[0] == '1') : 0;
516 }
517 else
518 {
519 dwNoModify = 0;
520 }
521 }
522 if (!dwNoModify)
523 {
524 if (dwWindowsInstaller)
525 {
527 }
528 else
529 {
531 }
532 }
533}
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
const CStringW szIdentifier
Definition: appinfo.h:98

Referenced by CanModify(), ShowAppInfo(), and UninstallApplication().

◆ ShowAppInfo()

VOID CInstalledApplicationInfo::ShowAppInfo ( CAppRichEdit RichEdit)
overridevirtual

Implements CAppInfo.

Definition at line 421 of file appinfo.cpp.

422{
423 RichEdit->SetText(szDisplayName, CFE_BOLD);
424 RichEdit->InsertText(L"\n", 0);
425
427 AddApplicationRegString(RichEdit, IDS_INFO_PUBLISHER, L"Publisher", 0);
428 AddApplicationRegString(RichEdit, IDS_INFO_REGOWNER, L"RegOwner", 0);
429 AddApplicationRegString(RichEdit, IDS_INFO_PRODUCTID, L"ProductID", 0);
431 AddApplicationRegString(RichEdit, IDS_INFO_HELPPHONE, L"HelpTelephone", 0);
432 AddApplicationRegString(RichEdit, IDS_INFO_README, L"Readme", 0);
433 AddApplicationRegString(RichEdit, IDS_INFO_CONTACT, L"Contact", 0);
434 AddApplicationRegString(RichEdit, IDS_INFO_UPDATEINFO, L"URLUpdateInfo", CFM_LINK);
435 AddApplicationRegString(RichEdit, IDS_INFO_INFOABOUT, L"URLInfoAbout", CFM_LINK);
437
439 {
441 }
442
444 AddApplicationRegString(RichEdit, IDS_INFO_INSTLOCATION, L"InstallLocation", 0);
445 AddApplicationRegString(RichEdit, IDS_INFO_INSTALLSRC, L"InstallSource", 0);
446
448 {
450 }
451
454}
#define IDS_INFO_INSTALLSRC
Definition: resource.h:155
#define IDS_INFO_REGOWNER
Definition: resource.h:148
#define IDS_INFO_VERSION
Definition: resource.h:142
#define IDS_INFO_HELPLINK
Definition: resource.h:145
#define IDS_INFO_INSTALLDATE
Definition: resource.h:158
#define IDS_INFO_HELPPHONE
Definition: resource.h:146
#define IDS_INFO_INSTLOCATION
Definition: resource.h:154
#define IDS_INFO_COMMENTS
Definition: resource.h:153
#define IDS_INFO_UPDATEINFO
Definition: resource.h:151
#define IDS_INFO_CONTACT
Definition: resource.h:150
#define IDS_INFO_MODIFYPATH
Definition: resource.h:157
#define IDS_INFO_UNINSTALLSTR
Definition: resource.h:156
#define IDS_INFO_PRODUCTID
Definition: resource.h:149
#define IDS_INFO_README
Definition: resource.h:147
#define IDS_INFO_PUBLISHER
Definition: resource.h:144
#define IDS_INFO_INFOABOUT
Definition: resource.h:152
VOID AddApplicationRegString(CAppRichEdit *RichEdit, UINT StringID, const CStringW &String, DWORD TextFlags)
Definition: appinfo.cpp:407
VOID InsertText(LPCWSTR lpszText, DWORD dwEffects)
Definition: crichedit.h:77
VOID SetText(LPCWSTR lpszText, DWORD dwEffects)
Definition: crichedit.h:91
#define CFE_BOLD
Definition: richedit.h:406
#define CFM_LINK
Definition: richedit.h:337

◆ UninstallApplication()

BOOL CInstalledApplicationInfo::UninstallApplication ( UninstallCommandFlags  Flags)
overridevirtual

Implements CAppInfo.

Definition at line 589 of file appinfo.cpp.

590{
592 {
593 return UninstallGenerated(*this, Flags);
594 }
595
596 BOOL bModify = Flags & UCF_MODIFY;
598 {
600 }
601
603 if ((Flags & (UCF_MODIFY | UCF_SILENT)) == UCF_SILENT)
604 {
605 DWORD msi = 0;
606 msi = GetApplicationRegDword(L"WindowsInstaller", &msi) && msi;
607 if (msi)
608 {
609 cmd += L" /qn";
610 }
611 else
612 {
613 CStringW silentcmd;
614 if (GetApplicationRegString(L"QuietUninstallString", silentcmd) && !silentcmd.IsEmpty())
615 {
616 cmd = silentcmd;
617 }
618 }
619 }
620
622
623 if (bSuccess && !bModify)
624 WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szDisplayName);
625
626 return bSuccess;
627}
@ UCF_SILENT
Definition: appinfo.h:70
@ UCF_MODIFY
Definition: appinfo.h:69
BOOL UninstallGenerated(CInstalledApplicationInfo &AppInfo, UninstallCommandFlags Flags)
Definition: geninst.cpp:812
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:224
BOOL StartProcess(const CStringW &Path, BOOL Wait)
Definition: misc.cpp:83
virtual InstallerType GetInstallerType() const override
Definition: appinfo.cpp:578
Definition: ftp_var.h:139
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2833
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

◆ Valid()

BOOL CInstalledApplicationInfo::Valid ( ) const
overridevirtual

Implements CAppInfo.

Definition at line 536 of file appinfo.cpp.

537{
538 return !szDisplayName.IsEmpty();
539}

Referenced by CAppDB::CreateInstalledAppByRegistryKey().

Member Data Documentation

◆ m_hKey

CRegKey CInstalledApplicationInfo::m_hKey
private

◆ m_KeyInfo

UINT CInstalledApplicationInfo::m_KeyInfo

Definition at line 197 of file appinfo.h.

Referenced by CAppDB::RemoveInstalledAppFromRegistry().

◆ m_szInstallDate

CStringW CInstalledApplicationInfo::m_szInstallDate
private

Definition at line 180 of file appinfo.h.

Referenced by RetrieveInstallDate(), and ShowAppInfo().

◆ m_szModifyString

CStringW CInstalledApplicationInfo::m_szModifyString
private

Definition at line 182 of file appinfo.h.

Referenced by CanModify(), RetrieveUninstallStrings(), ShowAppInfo(), and UninstallApplication().

◆ m_szUninstallString

CStringW CInstalledApplicationInfo::m_szUninstallString
private

Definition at line 181 of file appinfo.h.

Referenced by CanModify(), RetrieveUninstallStrings(), ShowAppInfo(), and UninstallApplication().


The documentation for this class was generated from the following files: