Skip to content

Conversation

@primetime43
Copy link

  • A checkbox labeled "Start with Windows" appears in the options dialog
  • When checked, the app adds itself to the Windows Run registry key
  • When unchecked, it removes itself from the registry
  • The setting persists across app restarts by reading from the registry
image

- A checkbox labeled "Start with Windows" appears in the options dialog
  - When checked, the app adds itself to the Windows Run registry key
  - When unchecked, it removes itself from the registry
  - The setting persists across app restarts by reading from the registry
Copilot AI review requested due to automatic review settings December 30, 2025 06:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a "Start with Windows" feature that allows the application to automatically launch when Windows starts. The implementation adds a checkbox to the options dialog that, when toggled, modifies the Windows registry Run key to enable or disable automatic startup.

  • Added registry interaction methods to manage Windows startup configuration
  • Extended the settings infrastructure to include and persist the startup preference
  • Integrated a checkbox control in the options dialog for user configuration

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Src/let-it-rain/SettingsManager.h Added StartWithWindows field to Setting struct and declared static methods for registry operations
Src/let-it-rain/SettingsManager.cpp Implemented registry read/write operations for managing Windows startup and integrated startup status into settings loading
Src/let-it-rain/Resource.h Added IDC_CHECK_STARTUP control identifier for the startup checkbox
Src/let-it-rain/OptionDialog.h Extended constructor and class to include StartWithWindows parameter and field
Src/let-it-rain/OptionDialog.cpp Implemented checkbox initialization and click event handler that updates registry
Src/let-it-rain/DisplayWindow.cpp Updated OptionsDialog instantiation to pass StartWithWindows setting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Set the image and the text
SendMessage(hButton, BM_SETIMAGE, IMAGE_ICON, reinterpret_cast<LPARAM>(hIcon));
SetWindowText(hButton, L"Github Repo");
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling from 'Github' to 'GitHub'.

Suggested change
SetWindowText(hButton, L"Github Repo");
SetWindowText(hButton, L"GitHub Repo");

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +119
GetModuleFileName(nullptr, exePath, MAX_PATH);

Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of GetModuleFileName should be checked to ensure it succeeds. If the function fails (returns 0) or if the path is truncated (returns MAX_PATH and GetLastError returns ERROR_INSUFFICIENT_BUFFER), the exePath buffer may contain incomplete or invalid data, which would then be written to the registry.

Suggested change
GetModuleFileName(nullptr, exePath, MAX_PATH);
DWORD length = GetModuleFileName(nullptr, exePath, MAX_PATH);
// If GetModuleFileName fails or the path is truncated, do not modify the registry
if (length == 0 ||
(length == MAX_PATH && GetLastError() == ERROR_INSUFFICIENT_BUFFER))
{
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines +122 to +124
RegSetValueEx(hKey, appName, 0, REG_SZ,
reinterpret_cast<const BYTE*>(exePath),
static_cast<DWORD>((wcslen(exePath) + 1) * sizeof(wchar_t)));
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of RegSetValueEx should be checked to ensure the registry write operation succeeds. If the operation fails, the application will silently fail to enable startup functionality, leaving the user interface state inconsistent with the actual registry state.

Suggested change
RegSetValueEx(hKey, appName, 0, REG_SZ,
reinterpret_cast<const BYTE*>(exePath),
static_cast<DWORD>((wcslen(exePath) + 1) * sizeof(wchar_t)));
const LONG result = RegSetValueEx(hKey, appName, 0, REG_SZ,
reinterpret_cast<const BYTE*>(exePath),
static_cast<DWORD>((wcslen(exePath) + 1) * sizeof(wchar_t)));
if (result != ERROR_SUCCESS)
{
std::wcerr << L"Failed to set startup registry value for " << appName
<< L" (error code: " << result << L")" << std::endl;
}

Copilot uses AI. Check for mistakes.
{
if (RegOpenKeyEx(HKEY_CURRENT_USER, runKeyPath, 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS)
{
RegDeleteValue(hKey, appName);
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of RegDeleteValue should be checked to ensure the registry delete operation succeeds. If the operation fails, the application will silently fail to disable startup functionality, leaving the user interface state inconsistent with the actual registry state.

Suggested change
RegDeleteValue(hKey, appName);
LONG deleteResult = RegDeleteValue(hKey, appName);
if (deleteResult != ERROR_SUCCESS)
{
std::wcerr << L"Failed to delete startup registry value for " << appName
<< L". Error code: " << deleteResult << L'\n';
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant