Skip to content

[Windows] Implement AutoStart: add examples and fix C API array cleanup#38

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/implement-autostart-windows
Closed

[Windows] Implement AutoStart: add examples and fix C API array cleanup#38
Copilot wants to merge 3 commits intomainfrom
copilot/implement-autostart-windows

Conversation

Copy link
Contributor

Copilot AI commented Mar 1, 2026

Adds working examples for the AutoStart API (C++ and C) and fixes a C API memory management issue where callers were incorrectly instructed to use delete[] directly — which is not valid from C code.

C API fix

  • Added native_autostart_free_arguments() to autostart_c.h/autostart_c.cpp for proper C-compatible cleanup of argument arrays returned by native_autostart_get_arguments()

Examples

  • examples/autostart_example/ — C++ example covering Enable, Disable, IsEnabled, SetProgram, and default-detection behavior
  • examples/autostart_c_example/ — C equivalent using the native_autostart_* C API
  • Both added to root CMakeLists.txt
// Before (documented but broken for C consumers):
char** args; size_t n;
native_autostart_get_arguments(as, &args, &n);
delete[] args;  // ❌ not valid C

// After:
native_autostart_get_arguments(as, &args, &n);
native_autostart_free_arguments(args, n);  // ✅ works from C and C++

Platform notes for the underlying Windows implementation: uses HKCU\Software\Microsoft\Windows\CurrentVersion\Run with no elevated privileges required.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Windows] Implement AutoStart</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 1, 2026 05:59
…tion

Co-authored-by: lijy91 <3889523+lijy91@users.noreply.github.com>
Co-authored-by: lijy91 <3889523+lijy91@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement AutoStart feature for Windows [Windows] Implement AutoStart: add examples and fix C API array cleanup Mar 1, 2026
@lijy91 lijy91 closed this Mar 1, 2026
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.

[Windows] Implement AutoStart

2 participants