mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[IERNONCE] Add InitCallback
function
This commit is contained in:
parent
32340a2ae6
commit
5ce6ce18f4
8 changed files with 119 additions and 51 deletions
|
@ -4,10 +4,14 @@ include_directories(include)
|
||||||
|
|
||||||
spec2def(iernonce.dll iernonce.spec)
|
spec2def(iernonce.dll iernonce.spec)
|
||||||
|
|
||||||
add_library(iernonce MODULE
|
list(APPEND SOURCE
|
||||||
dialog.cpp
|
dialog.cpp
|
||||||
iernonce.cpp
|
iernonce.cpp
|
||||||
registry.cpp
|
registry.cpp
|
||||||
|
iernonce.h)
|
||||||
|
|
||||||
|
add_library(iernonce MODULE
|
||||||
|
${SOURCE}
|
||||||
iernonce.rc
|
iernonce.rc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/iernonce.def)
|
${CMAKE_CURRENT_BINARY_DIR}/iernonce.def)
|
||||||
|
|
||||||
|
@ -15,4 +19,5 @@ set_module_type(iernonce win32dll UNICODE)
|
||||||
target_link_libraries(iernonce cppstl atl_classes)
|
target_link_libraries(iernonce cppstl atl_classes)
|
||||||
set_target_cpp_properties(iernonce WITH_EXCEPTIONS)
|
set_target_cpp_properties(iernonce WITH_EXCEPTIONS)
|
||||||
add_importlibs(iernonce advapi32 msvcrt gdi32 ole32 shell32 shlwapi kernel32 user32 ntdll)
|
add_importlibs(iernonce advapi32 msvcrt gdi32 ole32 shell32 shlwapi kernel32 user32 ntdll)
|
||||||
|
add_pch(iernonce iernonce.h SOURCE)
|
||||||
add_cd_file(TARGET iernonce DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET iernonce DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -5,14 +5,9 @@
|
||||||
* COPYRIGHT: Copyright 2021 He Yang <1160386205@qq.com>
|
* COPYRIGHT: Copyright 2021 He Yang <1160386205@qq.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <atlbase.h>
|
#include "iernonce.h"
|
||||||
#include <atlwin.h>
|
|
||||||
#include <windowsx.h>
|
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
#include "dialog.h"
|
|
||||||
#include "registry.h"
|
|
||||||
|
|
||||||
#define ITEM_VPADDING 3
|
#define ITEM_VPADDING 3
|
||||||
#define ITEM_LEFTPADDING 22
|
#define ITEM_LEFTPADDING 22
|
||||||
|
|
||||||
|
@ -37,10 +32,7 @@ BOOL ProgressDlg::RunDialogBox()
|
||||||
// Show the dialog and run the items only when the list is not empty.
|
// Show the dialog and run the items only when the list is not empty.
|
||||||
if (m_RunOnceExInst.m_SectionList.GetSize() != 0)
|
if (m_RunOnceExInst.m_SectionList.GetSize() != 0)
|
||||||
{
|
{
|
||||||
if (DoModal() == -1)
|
return (DoModal() == 1);
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -220,8 +212,8 @@ ProgressDlg::ProcessWindowMessage(
|
||||||
{
|
{
|
||||||
if ((int)wParam == m_RunOnceExInst.m_SectionList.GetSize())
|
if ((int)wParam == m_RunOnceExInst.m_SectionList.GetSize())
|
||||||
{
|
{
|
||||||
// All sections are handled.
|
// All sections are handled, lParam is bSuccess.
|
||||||
EndDialog(0);
|
EndDialog(lParam);
|
||||||
}
|
}
|
||||||
m_PointedItem = wParam;
|
m_PointedItem = wParam;
|
||||||
InvalidateRect(NULL);
|
InvalidateRect(NULL);
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
|
|
||||||
|
// When wParam < item count ==> wParam is item index (0 based)
|
||||||
|
// wParam = item count ==> all finished, lParam = bSuccess
|
||||||
#define WM_SETINDEX (WM_USER + 1)
|
#define WM_SETINDEX (WM_USER + 1)
|
||||||
|
|
||||||
class ProgressDlg : public CDialogImpl<ProgressDlg>
|
class ProgressDlg : public CDialogImpl<ProgressDlg>
|
||||||
|
|
|
@ -6,16 +6,10 @@
|
||||||
* Copyright 2021 He Yang <1160386205@qq.com>
|
* Copyright 2021 He Yang <1160386205@qq.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WIN32_NO_STATUS
|
#include "iernonce.h"
|
||||||
#include <windef.h>
|
|
||||||
#include <winbase.h>
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#define NDEBUG
|
RUNONCEEX_CALLBACK g_Callback = NULL;
|
||||||
#include <debug.h>
|
BOOL g_bSilence = FALSE;
|
||||||
|
|
||||||
#include "registry.h"
|
|
||||||
#include "dialog.h"
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
|
@ -52,28 +46,16 @@ RunOnceExProcess(_In_ HWND hwnd,
|
||||||
for (UINT i = 0; i < _countof(RootKeys); ++i)
|
for (UINT i = 0; i < _countof(RootKeys); ++i)
|
||||||
{
|
{
|
||||||
RunOnceExInstance Instance(RootKeys[i]);
|
RunOnceExInstance Instance(RootKeys[i]);
|
||||||
if (!Instance.m_bSuccess)
|
Instance.Run(g_bSilence);
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((Instance.m_dwFlags & FLAGS_NO_STAT_DIALOG) || !Instance.m_bShowDialog)
|
|
||||||
{
|
|
||||||
Instance.Exec(NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// The dialog is responsible to create a thread and execute.
|
|
||||||
ProgressDlg dlg(Instance);
|
|
||||||
dlg.RunDialogBox();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" VOID WINAPI
|
extern "C" VOID WINAPI
|
||||||
InitCallback(
|
InitCallback(_In_ RUNONCEEX_CALLBACK Callback,
|
||||||
_In_ PVOID Callback,
|
_In_ BOOL bSilence)
|
||||||
_In_ BOOL bSilence)
|
|
||||||
{
|
{
|
||||||
// FIXME: unimplemented
|
g_Callback = Callback;
|
||||||
|
g_bSilence = bSilence;
|
||||||
}
|
}
|
||||||
|
|
24
dll/win32/iernonce/iernonce.h
Normal file
24
dll/win32/iernonce/iernonce.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
|
* PURPOSE: ReactOS Extended RunOnce processing with UI.
|
||||||
|
* COPYRIGHT: Copyright 2021 He Yang <1160386205@qq.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
|
#include <windef.h>
|
||||||
|
#include <winbase.h>
|
||||||
|
#include <windowsx.h>
|
||||||
|
#include <shlwapi.h>
|
||||||
|
#include <iernonce_undoc.h>
|
||||||
|
|
||||||
|
#include <atlbase.h>
|
||||||
|
#include <atlwin.h>
|
||||||
|
|
||||||
|
#include "registry.h"
|
||||||
|
#include "dialog.h"
|
|
@ -71,7 +71,11 @@ public:
|
||||||
|
|
||||||
BOOL CloseAndDelete(_In_ CRegKeyEx &hParentKey);
|
BOOL CloseAndDelete(_In_ CRegKeyEx &hParentKey);
|
||||||
|
|
||||||
BOOL Exec();
|
UINT GetEntryCnt() const;
|
||||||
|
|
||||||
|
BOOL Exec(
|
||||||
|
_Inout_ UINT& iCompleteCnt,
|
||||||
|
_In_ const UINT iTotalCnt);
|
||||||
|
|
||||||
friend int RunOnceExSectionCmp(
|
friend int RunOnceExSectionCmp(
|
||||||
_In_ const void *a,
|
_In_ const void *a,
|
||||||
|
@ -99,4 +103,5 @@ public:
|
||||||
RunOnceExInstance(_In_ HKEY BaseKey);
|
RunOnceExInstance(_In_ HKEY BaseKey);
|
||||||
|
|
||||||
BOOL Exec(_In_opt_ HWND hwnd);
|
BOOL Exec(_In_opt_ HWND hwnd);
|
||||||
|
BOOL Run(_In_ BOOL bSilence);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,15 +5,9 @@
|
||||||
* COPYRIGHT: Copyright 2021 He Yang <1160386205@qq.com>
|
* COPYRIGHT: Copyright 2021 He Yang <1160386205@qq.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "iernonce.h"
|
||||||
|
|
||||||
#include <cassert>
|
extern RUNONCEEX_CALLBACK g_Callback;
|
||||||
#include <cstdlib>
|
|
||||||
#include <shlwapi.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <winreg.h>
|
|
||||||
|
|
||||||
#include "registry.h"
|
|
||||||
#include "dialog.h"
|
|
||||||
|
|
||||||
LONG CRegKeyEx::EnumValueName(
|
LONG CRegKeyEx::EnumValueName(
|
||||||
_In_ DWORD iIndex,
|
_In_ DWORD iIndex,
|
||||||
|
@ -199,7 +193,14 @@ BOOL RunOnceExSection::CloseAndDelete(
|
||||||
return hParentKey.RecurseDeleteKey(m_SectionName) == ERROR_SUCCESS;
|
return hParentKey.RecurseDeleteKey(m_SectionName) == ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL RunOnceExSection::Exec()
|
UINT RunOnceExSection::GetEntryCnt() const
|
||||||
|
{
|
||||||
|
return m_EntryList.GetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL RunOnceExSection::Exec(
|
||||||
|
_Inout_ UINT& iCompleteCnt,
|
||||||
|
_In_ const UINT iTotalCnt)
|
||||||
{
|
{
|
||||||
BOOL bSuccess = TRUE;
|
BOOL bSuccess = TRUE;
|
||||||
|
|
||||||
|
@ -207,6 +208,10 @@ BOOL RunOnceExSection::Exec()
|
||||||
{
|
{
|
||||||
m_EntryList[i].Delete(m_RegKey);
|
m_EntryList[i].Delete(m_RegKey);
|
||||||
bSuccess &= m_EntryList[i].Exec();
|
bSuccess &= m_EntryList[i].Exec();
|
||||||
|
iCompleteCnt++;
|
||||||
|
// TODO: the meaning of the third param is still unknown, seems it's always 0.
|
||||||
|
if (g_Callback)
|
||||||
|
g_Callback(iCompleteCnt, iTotalCnt, NULL);
|
||||||
}
|
}
|
||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
@ -289,13 +294,20 @@ BOOL RunOnceExInstance::Exec(_In_opt_ HWND hwnd)
|
||||||
{
|
{
|
||||||
BOOL bSuccess = TRUE;
|
BOOL bSuccess = TRUE;
|
||||||
|
|
||||||
|
UINT TotalCnt = 0;
|
||||||
|
UINT CompleteCnt = 0;
|
||||||
|
for (int i = 0; i < m_SectionList.GetSize(); i++)
|
||||||
|
{
|
||||||
|
TotalCnt += m_SectionList[i].GetEntryCnt();
|
||||||
|
}
|
||||||
|
|
||||||
// Execute items from registry one by one, and remove them.
|
// Execute items from registry one by one, and remove them.
|
||||||
for (int i = 0; i < m_SectionList.GetSize(); i++)
|
for (int i = 0; i < m_SectionList.GetSize(); i++)
|
||||||
{
|
{
|
||||||
if (hwnd)
|
if (hwnd)
|
||||||
SendMessageW(hwnd, WM_SETINDEX, i, 0);
|
SendMessageW(hwnd, WM_SETINDEX, i, 0);
|
||||||
|
|
||||||
bSuccess &= m_SectionList[i].Exec();
|
bSuccess &= m_SectionList[i].Exec(CompleteCnt, TotalCnt);
|
||||||
m_SectionList[i].CloseAndDelete(m_RegKey);
|
m_SectionList[i].CloseAndDelete(m_RegKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,10 +316,26 @@ BOOL RunOnceExInstance::Exec(_In_opt_ HWND hwnd)
|
||||||
|
|
||||||
// Notify the dialog all sections are handled.
|
// Notify the dialog all sections are handled.
|
||||||
if (hwnd)
|
if (hwnd)
|
||||||
SendMessageW(hwnd, WM_SETINDEX, m_SectionList.GetSize(), 0);
|
SendMessageW(hwnd, WM_SETINDEX, m_SectionList.GetSize(), bSuccess);
|
||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL RunOnceExInstance::Run(_In_ BOOL bSilence)
|
||||||
|
{
|
||||||
|
if (bSilence ||
|
||||||
|
(m_dwFlags & FLAGS_NO_STAT_DIALOG) ||
|
||||||
|
!m_bShowDialog)
|
||||||
|
{
|
||||||
|
return Exec(NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The dialog is responsible to create a thread and execute.
|
||||||
|
ProgressDlg dlg(*this);
|
||||||
|
return dlg.RunDialogBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOL RunOnceExInstance::HandleSubKey(
|
BOOL RunOnceExInstance::HandleSubKey(
|
||||||
_In_ CRegKeyEx &hKey,
|
_In_ CRegKeyEx &hKey,
|
||||||
_In_ const CStringW& SubKeyName)
|
_In_ const CStringW& SubKeyName)
|
||||||
|
|
30
sdk/include/reactos/iernonce_undoc.h
Normal file
30
sdk/include/reactos/iernonce_undoc.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef _IERNONCE_UNDOC_H_
|
||||||
|
#define _IERNONCE_UNDOC_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef VOID
|
||||||
|
(CALLBACK *RUNONCEEX_CALLBACK)(
|
||||||
|
_In_ UINT CompleteCnt,
|
||||||
|
_In_ UINT TotalCnt,
|
||||||
|
_In_ DWORD_PTR dwReserved);
|
||||||
|
|
||||||
|
VOID WINAPI
|
||||||
|
InitCallback(
|
||||||
|
_In_ RUNONCEEX_CALLBACK Callback,
|
||||||
|
_In_ BOOL bSilence);
|
||||||
|
|
||||||
|
VOID WINAPI
|
||||||
|
RunOnceExProcess(
|
||||||
|
_In_ HWND hwnd,
|
||||||
|
_In_ HINSTANCE hInst,
|
||||||
|
_In_ LPCSTR pszCmdLine,
|
||||||
|
_In_ int nCmdShow);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _IERNONCE_UNDOC_H_ */
|
Loading…
Reference in a new issue