1 #pragma once
2 
3 #include <atlcoll.h>
4 #include <atlpath.h>
5 
6 #include "appinfo.h"
7 
8 class CAppDB
9 {
10   private:
11     CPathW m_BasePath;
12     CAtlList<CAppInfo *> m_Available;
13     CAtlList<CAppInfo *> m_Installed;
14 
15     BOOL
16     EnumerateFiles();
17 
18     static CInstalledApplicationInfo *
19     EnumerateRegistry(CAtlList<CAppInfo *> *List, LPCWSTR Name);
20     static CInstalledApplicationInfo *
21     CreateInstalledAppByRegistryKey(LPCWSTR KeyName, HKEY hKeyParent, UINT KeyIndex);
22 
23   public:
24     CAppDB(const CStringW &path);
25 
26     VOID
27     GetApps(CAtlList<CAppInfo *> &List, AppsCategories Type) const;
28     CAvailableApplicationInfo *
29     FindAvailableByPackageName(const CStringW &name);
30     CAppInfo *
FindByPackageName(const CStringW & name)31     FindByPackageName(const CStringW &name) { return FindAvailableByPackageName(name); }
32 
33     VOID
34     UpdateAvailable();
35     VOID
36     UpdateInstalled();
37     VOID
38     RemoveCached();
39 
40     static DWORD
41     RemoveInstalledAppFromRegistry(const CAppInfo *Info);
42 
43     static CInstalledApplicationInfo *
44     CreateInstalledAppByRegistryKey(LPCWSTR Name);
45     static CInstalledApplicationInfo *
46     CreateInstalledAppInstance(LPCWSTR KeyName, BOOL User, REGSAM WowSam);
47     static HKEY
48     EnumInstalledRootKey(UINT Index, REGSAM &RegSam);
49 
GetAvailableCount()50     size_t GetAvailableCount() const
51     {
52         return m_Available.GetCount();
53     }
54 };
55