https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56b0f836c518d7f737dc9…
commit 56b0f836c518d7f737dc933697836a753fea1bbb
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Jan 26 11:45:28 2025 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Jan 26 11:46:04 2025 +0100
[SYSSETUP] Move the creation of start menu items into the wizard
Start menu items were created after the wizard had finished. This patch moves the
creation of the start menu items into the process page of the wizard and enables the 2nd
item of the task list.
---
dll/win32/syssetup/globals.h | 45 ++++++++++++++
dll/win32/syssetup/install.c | 142 ++++++++++++++++++++++++++++++++-----------
dll/win32/syssetup/wizard.c | 38 +++---------
3 files changed, 159 insertions(+), 66 deletions(-)
diff --git a/dll/win32/syssetup/globals.h b/dll/win32/syssetup/globals.h
index 8c020acefb3..85b3f8dea3a 100644
--- a/dll/win32/syssetup/globals.h
+++ b/dll/win32/syssetup/globals.h
@@ -25,12 +25,57 @@ typedef struct _ADMIN_INFO
LPWSTR Password;
} ADMIN_INFO, *PADMIN_INFO;
+
+typedef struct _ITEMSDATA
+{
+ HWND hwndDlg;
+} ITEMSDATA, *PITEMSDATA;
+
+typedef struct _REGISTRATIONNOTIFY
+{
+ ULONG Progress;
+ UINT ActivityID;
+ LPCWSTR CurrentItem;
+ LPCWSTR ErrorMessage;
+ UINT MessageID;
+ DWORD LastError;
+} REGISTRATIONNOTIFY, *PREGISTRATIONNOTIFY;
+
+
+#define PM_REGISTRATION_NOTIFY (WM_APP + 1)
+/* Private Message used to communicate progress from the background
+ registration thread to the main thread.
+ wParam = 0 Registration in progress
+ = 1 Registration completed
+ lParam = Pointer to a REGISTRATIONNOTIFY structure */
+
+#define PM_ITEM_START (WM_APP + 2)
+/* Start of a new Item
+ wParam = item number
+ lParam = number of steps */
+
+#define PM_ITEM_END (WM_APP + 3)
+/* End of a new Item
+ wParam = unused
+ lParam = Error Code */
+
+#define PM_STEP_START (WM_APP + 4)
+#define PM_STEP_END (WM_APP + 5)
+#define PM_ITEMS_DONE (WM_APP + 6)
+
+
extern HINSTANCE hDllInstance;
extern HINF hSysSetupInf;
extern ADMIN_INFO AdminInfo;
BOOL RegisterTypeLibraries (HINF hinf, LPCWSTR szSection);
+/* install */
+
+VOID
+InstallStartMenuItems(
+ _In_ PITEMSDATA pItemsData);
+
/* netinstall.c */
BOOL
diff --git a/dll/win32/syssetup/install.c b/dll/win32/syssetup/install.c
index 0f6a150da4e..61d5da1bc33 100644
--- a/dll/win32/syssetup/install.c
+++ b/dll/win32/syssetup/install.c
@@ -180,7 +180,13 @@ CreateShortcut(
}
-static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR pszFolder)
+static BOOL
+CreateShortcutsFromSection(
+ _In_ PITEMSDATA pItemsData,
+ _In_ PREGISTRATIONNOTIFY pNotify,
+ _In_ HINF hinf,
+ _In_ LPWSTR pszSection,
+ _In_ LPCWSTR pszFolder)
{
INFCONTEXT Context;
DWORD dwFieldCount;
@@ -196,6 +202,10 @@ static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection,
LPCWSTR psz
do
{
+ pNotify->Progress++;
+
+ SendMessage(pItemsData->hwndDlg, PM_STEP_START, 0, (LPARAM)pNotify);
+
dwFieldCount = SetupGetFieldCount(&Context);
if (dwFieldCount < 3)
continue;
@@ -222,12 +232,19 @@ static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection,
LPCWSTR psz
CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr, szDirectory,
szArgs);
+ SendMessage(pItemsData->hwndDlg, PM_STEP_END, 0, (LPARAM)pNotify);
+
} while (SetupFindNextLine(&Context, &Context));
return TRUE;
}
-static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection)
+static BOOL
+CreateShortcuts(
+ _In_ PITEMSDATA pItemsData,
+ _In_ PREGISTRATIONNOTIFY pNotify,
+ _In_ HINF hinf,
+ _In_ LPCWSTR szSection)
{
INFCONTEXT Context;
WCHAR szPath[MAX_PATH];
@@ -257,7 +274,7 @@ static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection)
if (FAILED(SHGetFolderPathAndSubDirW(NULL, csidl|CSIDL_FLAG_CREATE, (HANDLE)-1,
SHGFP_TYPE_DEFAULT, szFolder, szPath)))
continue;
- CreateShortcutsFromSection(hinf, szFolderSection, szPath);
+ CreateShortcutsFromSection(pItemsData, pNotify, hinf, szFolderSection, szPath);
} while (SetupFindNextLine(&Context, &Context));
@@ -266,6 +283,92 @@ static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection)
return TRUE;
}
+static LONG
+CountShortcuts(
+ _In_ HINF hinf,
+ _In_ LPCWSTR szSection)
+{
+ INFCONTEXT Context;
+ WCHAR szFolderSection[MAX_PATH];
+ LONG Steps = 0;
+
+ if (!SetupFindFirstLine(hinf, szSection, NULL, &Context))
+ return FALSE;
+
+ do
+ {
+ if (SetupGetFieldCount(&Context) < 2)
+ continue;
+
+ if (!SetupGetStringFieldW(&Context, 0, szFolderSection,
ARRAYSIZE(szFolderSection), NULL))
+ continue;
+
+ Steps += SetupGetLineCountW(hinf, szFolderSection);
+ } while (SetupFindNextLine(&Context, &Context));
+
+ return Steps;
+}
+
+VOID
+InstallStartMenuItems(
+ _In_ PITEMSDATA pItemsData)
+{
+ HINF hShortcutsInf1 = INVALID_HANDLE_VALUE;
+ HINF hShortcutsInf2 = INVALID_HANDLE_VALUE;
+ LONG Steps = 0;
+ DWORD LastError = 0;
+ REGISTRATIONNOTIFY Notify;
+
+ ZeroMemory(&Notify, sizeof(Notify));
+
+ hShortcutsInf1 = SetupOpenInfFileW(L"shortcuts.inf",
+ NULL,
+ INF_STYLE_WIN4,
+ NULL);
+ if (hShortcutsInf1 == INVALID_HANDLE_VALUE)
+ {
+ DPRINT1("Failed to open shortcuts.inf");
+ return;
+ }
+
+ hShortcutsInf2 = SetupOpenInfFileW(L"rosapps_shortcuts.inf",
+ NULL,
+ INF_STYLE_WIN4,
+ NULL);
+
+// Steps = SetupGetLineCountW(hShortcutsInf1, L"ShortcutFolders");
+ Steps = CountShortcuts(hShortcutsInf1, L"ShortcutFolders");
+ if (hShortcutsInf2 != INVALID_HANDLE_VALUE)
+ Steps += CountShortcuts(hShortcutsInf2, L"ShortcutFolders");
+// Steps += SetupGetLineCountW(hShortcutsInf2, L"ShortcutFolders");
+
+ SendMessage(pItemsData->hwndDlg, PM_ITEM_START, 1, (LPARAM)Steps);
+
+ if (!CreateShortcuts(pItemsData, &Notify, hShortcutsInf1,
L"ShortcutFolders"))
+ {
+ DPRINT1("CreateShortcuts() failed");
+ goto done;
+ }
+
+ if (hShortcutsInf2 != INVALID_HANDLE_VALUE)
+ {
+ if (!CreateShortcuts(pItemsData, &Notify, hShortcutsInf2,
L"ShortcutFolders"))
+ {
+ DPRINT1("CreateShortcuts(rosapps) failed");
+ goto done;
+ }
+ }
+
+done:
+ if (hShortcutsInf2 != INVALID_HANDLE_VALUE)
+ SetupCloseInfFile(hShortcutsInf2);
+
+ if (hShortcutsInf1 != INVALID_HANDLE_VALUE)
+ SetupCloseInfFile(hShortcutsInf1);
+
+ SendMessage(pItemsData->hwndDlg, PM_ITEM_END, 1, LastError);
+}
+
static VOID
CreateTempDir(
IN LPCWSTR VarName)
@@ -1393,7 +1496,6 @@ InstallReactOS(VOID)
HANDLE token;
TOKEN_PRIVILEGES privs;
HKEY hKey;
- HINF hShortcutsInf;
HANDLE hHotkeyThread;
BOOL ret;
@@ -1484,38 +1586,6 @@ InstallReactOS(VOID)
SetAutoAdminLogon();
- hShortcutsInf = SetupOpenInfFileW(L"shortcuts.inf",
- NULL,
- INF_STYLE_WIN4,
- NULL);
- if (hShortcutsInf == INVALID_HANDLE_VALUE)
- {
- FatalError("Failed to open shortcuts.inf");
- return 0;
- }
-
- if (!CreateShortcuts(hShortcutsInf, L"ShortcutFolders"))
- {
- FatalError("CreateShortcuts() failed");
- return 0;
- }
-
- SetupCloseInfFile(hShortcutsInf);
-
- hShortcutsInf = SetupOpenInfFileW(L"rosapps_shortcuts.inf",
- NULL,
- INF_STYLE_WIN4,
- NULL);
- if (hShortcutsInf != INVALID_HANDLE_VALUE)
- {
- if (!CreateShortcuts(hShortcutsInf, L"ShortcutFolders"))
- {
- FatalError("CreateShortcuts(rosapps) failed");
- return 0;
- }
- SetupCloseInfFile(hShortcutsInf);
- }
-
SetupCloseInfFile(hSysSetupInf);
SetSetupType(0);
diff --git a/dll/win32/syssetup/wizard.c b/dll/win32/syssetup/wizard.c
index 491e2504e12..4675ff904a9 100644
--- a/dll/win32/syssetup/wizard.c
+++ b/dll/win32/syssetup/wizard.c
@@ -27,34 +27,6 @@
#define NDEBUG
#include <debug.h>
-#define PM_REGISTRATION_NOTIFY (WM_APP + 1)
-/* Private Message used to communicate progress from the background
- registration thread to the main thread.
- wParam = 0 Registration in progress
- = 1 Registration completed
- lParam = Pointer to a REGISTRATIONNOTIFY structure */
-
-#define PM_ITEM_START (WM_APP + 2)
-#define PM_ITEM_END (WM_APP + 3)
-#define PM_STEP_START (WM_APP + 4)
-#define PM_STEP_END (WM_APP + 5)
-#define PM_ITEMS_DONE (WM_APP + 6)
-
-typedef struct _REGISTRATIONNOTIFY
-{
- ULONG Progress;
- UINT ActivityID;
- LPCWSTR CurrentItem;
- LPCWSTR ErrorMessage;
- UINT MessageID;
- DWORD LastError;
-} REGISTRATIONNOTIFY, *PREGISTRATIONNOTIFY;
-
-typedef struct _ITEMSDATA
-{
- HWND hwndDlg;
-} ITEMSDATA, *PITEMSDATA;
-
typedef struct _REGISTRATIONDATA
{
HWND hwndDlg;
@@ -2043,7 +2015,7 @@ RegistrationNotificationProc(PVOID Context,
{
DPRINT("Received SPFILENOTIFY_STARTREGISTRATION notification for
%S\n",
StatusInfo->FileName);
- RegistrationNotify.ErrorMessage = NULL;
+// RegistrationNotify.ErrorMessage = NULL;
RegistrationNotify.Progress = RegistrationData->Registered;
SendMessage(RegistrationData->hwndDlg, PM_STEP_START, 0,
(LPARAM)&RegistrationNotify);
}
@@ -2193,10 +2165,14 @@ ItemCompletionThread(
pItemsData = (PITEMSDATA)Parameter;
hwndDlg = pItemsData->hwndDlg;
+ /* Step 0 - Registering components */
RegisterDlls(pItemsData);
RegisterTypeLibraries(hSysSetupInf, L"TypeLibraries");
+ /* Step 1 - Installing start menu items */
+ InstallStartMenuItems(pItemsData);
+
/* FIXME: Add completion steps here! */
// FIXME: Move this call to a separate cleanup page!
@@ -2345,7 +2321,6 @@ ProcessPageDlgProc(HWND hwndDlg,
/* Save pointer to the global setup data */
SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR)SetupData);
- ShowWindow(GetDlgItem(hwndDlg, IDC_TASKTEXT2), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_TASKTEXT3), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_TASKTEXT4), SW_HIDE);
break;
@@ -2354,12 +2329,15 @@ ProcessPageDlgProc(HWND hwndDlg,
switch (((LPNMHDR)lParam)->code)
{
case PSN_SETACTIVE:
+ LogItem(L"BEGIN", L"ProcessPage");
+
/* Disable the Back and Next buttons */
PropSheet_SetWizButtons(GetParent(hwndDlg), 0);
RunItemCompletionThread(hwndDlg);
break;
case PSN_WIZNEXT:
+ LogItem(L"END", L"ProcessPage");
break;
case PSN_WIZBACK: