1 /* 2 * PROJECT: ReactOS system libraries 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: Functions to read RunOnceEx registry. 5 * COPYRIGHT: Copyright 2021 He Yang <1160386205@qq.com> 6 */ 7 8 #pragma once 9 10 #include <windows.h> 11 #include <atlbase.h> 12 #include <atlstr.h> 13 #include <atlcoll.h> 14 #include <atlsimpcoll.h> 15 16 #define FLAGS_NO_STAT_DIALOG 0x00000080 17 18 #ifndef UNICODE 19 #error This project must be compiled with UNICODE! 20 #endif 21 22 class CRegKeyEx : public CRegKey 23 { 24 public: 25 LONG EnumValueName( 26 _In_ DWORD iIndex, 27 _Out_ LPTSTR pszName, 28 _Inout_ LPDWORD pnNameLength); 29 }; 30 31 class RunOnceExEntry 32 { 33 private: 34 ATL::CStringW m_Value; 35 ATL::CStringW m_Name; 36 37 public: 38 39 RunOnceExEntry( 40 _In_ const ATL::CStringW &Name, 41 _In_ const ATL::CStringW &Value); 42 43 BOOL Delete(_In_ CRegKeyEx &hParentKey); 44 BOOL Exec() const; 45 46 friend int RunOnceExEntryCmp( 47 _In_ const void *a, 48 _In_ const void *b); 49 }; 50 51 class RunOnceExSection 52 { 53 private: 54 ATL::CStringW m_SectionName; 55 CRegKeyEx m_RegKey; 56 57 BOOL HandleValue( 58 _In_ CRegKeyEx &hKey, 59 _In_ const CStringW &ValueName); 60 61 public: 62 BOOL m_bSuccess; 63 ATL::CStringW m_SectionTitle; 64 CSimpleArray<RunOnceExEntry> m_EntryList; 65 66 RunOnceExSection( 67 _In_ CRegKeyEx &hParentKey, 68 _In_ const CStringW &lpSubKeyName); 69 70 RunOnceExSection(_In_ const RunOnceExSection &Section); 71 72 BOOL CloseAndDelete(_In_ CRegKeyEx &hParentKey); 73 74 UINT GetEntryCnt() const; 75 76 BOOL Exec( 77 _Inout_ UINT& iCompleteCnt, 78 _In_ const UINT iTotalCnt); 79 80 friend int RunOnceExSectionCmp( 81 _In_ const void *a, 82 _In_ const void *b); 83 84 friend class RunOnceExInstance; 85 }; 86 87 class RunOnceExInstance 88 { 89 private: 90 CRegKeyEx m_RegKey; 91 92 BOOL HandleSubKey( 93 _In_ CRegKeyEx &hKey, 94 _In_ const CStringW &SubKeyName); 95 96 public: 97 BOOL m_bSuccess; 98 CSimpleArray<RunOnceExSection> m_SectionList; 99 CStringW m_Title; 100 DWORD m_dwFlags; 101 BOOL m_bShowDialog; 102 103 RunOnceExInstance(_In_ HKEY BaseKey); 104 105 BOOL Exec(_In_opt_ HWND hwnd); 106 BOOL Run(_In_ BOOL bSilence); 107 }; 108