ReactOS 0.4.15-dev-7654-g6bc40d3
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, int KeyIndex)
 
 ~CInstalledApplicationInfo ()
 
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 BOOL UninstallApplication (BOOL bModify) 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 BOOL UninstallApplication (BOOL bModify)=0
 

Public Attributes

const int iKeyIndex
 
- 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 146 of file appinfo.h.

Constructor & Destructor Documentation

◆ CInstalledApplicationInfo()

CInstalledApplicationInfo::CInstalledApplicationInfo ( HKEY  Key,
const CStringW KeyName,
AppsCategories  Category,
int  KeyIndex 
)

Definition at line 374 of file appinfo.cpp.

379 : CAppInfo(KeyName, Category), m_hKey(Key), iKeyIndex(KeyIndex)
380{
381 if (GetApplicationRegString(L"DisplayName", szDisplayName))
382 {
386 }
387}
CStringW szComments
Definition: appinfo.h:80
CStringW szDisplayIcon
Definition: appinfo.h:77
CStringW szDisplayName
Definition: appinfo.h:78
CStringW szDisplayVersion
Definition: appinfo.h:79
BOOL GetApplicationRegString(LPCWSTR lpKeyName, CStringW &String)
Definition: appinfo.cpp:581
#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 389 of file appinfo.cpp.

390{
391}

Member Function Documentation

◆ AddApplicationRegString()

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

Definition at line 394 of file appinfo.cpp.

399{
400 CStringW Tmp;
402 {
403 RichEdit->InsertTextWithString(StringID, Tmp, TextFlags);
404 }
405}
VOID InsertTextWithString(UINT StringID, const CStringW &Text, DWORD TextFlags)
Definition: appview.cpp:260
_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 529 of file appinfo.cpp.

530{
532 {
534 }
535
536 return !m_szModifyString.IsEmpty();
537}
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:389
CStringW m_szUninstallString
Definition: appinfo.h:150

◆ GetApplicationRegDword()

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

Definition at line 627 of file appinfo.cpp.

628{
629 DWORD dwSize = sizeof(DWORD), dwType;
630 if (RegQueryValueExW(m_hKey, lpKeyName, NULL, &dwType, (LPBYTE)lpValue, &dwSize) != ERROR_SUCCESS ||
631 dwType != REG_DWORD)
632 {
633 return FALSE;
634 }
635
636 return TRUE;
637}
#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:4132
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(), and RetrieveUninstallStrings().

◆ GetApplicationRegString()

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

Definition at line 581 of file appinfo.cpp.

582{
583 ULONG nChars = 0;
584 // Get the size
585 if (m_hKey.QueryStringValue(lpKeyName, NULL, &nChars) != ERROR_SUCCESS)
586 {
587 String.Empty();
588 return FALSE;
589 }
590
591 LPWSTR Buffer = String.GetBuffer(nChars);
592 LONG lResult = m_hKey.QueryStringValue(lpKeyName, Buffer, &nChars);
593 if (nChars > 0 && Buffer[nChars - 1] == UNICODE_NULL)
594 nChars--;
595 String.ReleaseBuffer(nChars);
596
597 if (lResult != ERROR_SUCCESS)
598 {
599 String.Empty();
600 return FALSE;
601 }
602
603 if (String.Find('%') >= 0)
604 {
605 CStringW Tmp;
607 if (dwLen > 0)
608 {
609 BOOL bSuccess = ExpandEnvironmentStringsW(String, Tmp.GetBuffer(dwLen), dwLen) == dwLen;
610 Tmp.ReleaseBuffer(dwLen - 1);
611 if (bSuccess)
612 {
613 String = Tmp;
614 }
615 else
616 {
617 String.Empty();
618 return FALSE;
619 }
620 }
621 }
622
623 return TRUE;
624}
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) noexcept
Definition: atlbase.h:1240
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:382
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(), and RetrieveUninstallStrings().

◆ GetDisplayInfo()

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

Implements CAppInfo.

Definition at line 559 of file appinfo.cpp.

560{
561 ATLASSERT(FALSE && "Should not be called");
562}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10

◆ GetDownloadInfo()

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

Implements CAppInfo.

Definition at line 553 of file appinfo.cpp.

554{
555 ATLASSERT(FALSE && "Should not be called");
556}

◆ RetrieveIcon()

BOOL CInstalledApplicationInfo::RetrieveIcon ( CStringW Path) const
overridevirtual

Implements CAppInfo.

Definition at line 540 of file appinfo.cpp.

541{
543 return !Path.IsEmpty();
544}
PRTL_UNICODE_STRING_BUFFER Path

◆ RetrieveInstallDate()

VOID CInstalledApplicationInfo::RetrieveInstallDate ( )
private

Definition at line 444 of file appinfo.cpp.

445{
446 DWORD dwInstallTimeStamp;
447 SYSTEMTIME InstallLocalTime;
448 if (GetApplicationRegString(L"InstallDate", m_szInstallDate))
449 {
450 ZeroMemory(&InstallLocalTime, sizeof(InstallLocalTime));
451 // Check if we have 8 characters to parse the datetime.
452 // Maybe other formats exist as well?
454 if (m_szInstallDate.GetLength() == 8)
455 {
456 InstallLocalTime.wYear = wcstol(m_szInstallDate.Left(4).GetString(), NULL, 10);
457 InstallLocalTime.wMonth = wcstol(m_szInstallDate.Mid(4, 2).GetString(), NULL, 10);
458 InstallLocalTime.wDay = wcstol(m_szInstallDate.Mid(6, 2).GetString(), NULL, 10);
459 }
460 }
461 // It might be a DWORD (Unix timestamp). try again.
462 else if (GetApplicationRegDword(L"InstallDate", &dwInstallTimeStamp))
463 {
464 FILETIME InstallFileTime;
465 SYSTEMTIME InstallSystemTime;
466
467 UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
468 FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
469
470 // convert to localtime
471 SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime, &InstallLocalTime);
472 }
473
474 // convert to readable date string
475 int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &InstallLocalTime, NULL, 0, 0);
476
478 LOCALE_USER_DEFAULT, // use default locale for current user
479 0, &InstallLocalTime, NULL, m_szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen);
481}
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:361
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:627
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 547 of file appinfo.cpp.

548{
549 return FALSE;
550}

◆ RetrieveUninstallStrings()

VOID CInstalledApplicationInfo::RetrieveUninstallStrings ( )
private

Definition at line 484 of file appinfo.cpp.

485{
486 DWORD dwWindowsInstaller = 0;
487 if (GetApplicationRegDword(L"WindowsInstaller", &dwWindowsInstaller) && dwWindowsInstaller)
488 {
489 // MSI has the same info in Uninstall / modify, so manually build it
491 }
492 else
493 {
495 }
496 DWORD dwNoModify = 0;
497 if (!GetApplicationRegDword(L"NoModify", &dwNoModify))
498 {
499 CStringW Tmp;
500 if (GetApplicationRegString(L"NoModify", Tmp))
501 {
502 dwNoModify = Tmp.GetLength() > 0 ? (Tmp[0] == '1') : 0;
503 }
504 else
505 {
506 dwNoModify = 0;
507 }
508 }
509 if (!dwNoModify)
510 {
511 if (dwWindowsInstaller)
512 {
514 }
515 else
516 {
518 }
519 }
520}
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
const CStringW szIdentifier
Definition: appinfo.h:74

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

◆ ShowAppInfo()

VOID CInstalledApplicationInfo::ShowAppInfo ( CAppRichEdit RichEdit)
overridevirtual

Implements CAppInfo.

Definition at line 408 of file appinfo.cpp.

409{
410 RichEdit->SetText(szDisplayName, CFE_BOLD);
411 RichEdit->InsertText(L"\n", 0);
412
414 AddApplicationRegString(RichEdit, IDS_INFO_PUBLISHER, L"Publisher", 0);
415 AddApplicationRegString(RichEdit, IDS_INFO_REGOWNER, L"RegOwner", 0);
416 AddApplicationRegString(RichEdit, IDS_INFO_PRODUCTID, L"ProductID", 0);
418 AddApplicationRegString(RichEdit, IDS_INFO_HELPPHONE, L"HelpTelephone", 0);
419 AddApplicationRegString(RichEdit, IDS_INFO_README, L"Readme", 0);
420 AddApplicationRegString(RichEdit, IDS_INFO_CONTACT, L"Contact", 0);
421 AddApplicationRegString(RichEdit, IDS_INFO_UPDATEINFO, L"URLUpdateInfo", CFM_LINK);
422 AddApplicationRegString(RichEdit, IDS_INFO_INFOABOUT, L"URLInfoAbout", CFM_LINK);
424
426 {
428 }
429
431 AddApplicationRegString(RichEdit, IDS_INFO_INSTLOCATION, L"InstallLocation", 0);
432 AddApplicationRegString(RichEdit, IDS_INFO_INSTALLSRC, L"InstallSource", 0);
433
435 {
437 }
438
441}
#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:394
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 ( BOOL  bModify)
overridevirtual

Implements CAppInfo.

Definition at line 565 of file appinfo.cpp.

566{
568 {
570 }
571
573
574 if (bSuccess && !bModify)
575 WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szDisplayName);
576
577 return bSuccess;
578}
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:227
BOOL StartProcess(const CStringW &Path, BOOL Wait)
Definition: misc.cpp:86
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2833

◆ Valid()

BOOL CInstalledApplicationInfo::Valid ( ) const
overridevirtual

Implements CAppInfo.

Definition at line 523 of file appinfo.cpp.

524{
525 return !szDisplayName.IsEmpty();
526}

Member Data Documentation

◆ iKeyIndex

const int CInstalledApplicationInfo::iKeyIndex

Definition at line 166 of file appinfo.h.

Referenced by CAppDB::RemoveInstalledAppFromRegistry().

◆ m_hKey

CRegKey CInstalledApplicationInfo::m_hKey
private

Definition at line 148 of file appinfo.h.

Referenced by GetApplicationRegDword(), and GetApplicationRegString().

◆ m_szInstallDate

CStringW CInstalledApplicationInfo::m_szInstallDate
private

Definition at line 149 of file appinfo.h.

Referenced by RetrieveInstallDate(), and ShowAppInfo().

◆ m_szModifyString

CStringW CInstalledApplicationInfo::m_szModifyString
private

Definition at line 151 of file appinfo.h.

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

◆ m_szUninstallString

CStringW CInstalledApplicationInfo::m_szUninstallString
private

Definition at line 150 of file appinfo.h.

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


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