PowerToys/doc/devdocs/modules/interface.md
Josh Soref bf16e10baf
Some checks failed
Spell checking / Check Spelling (push) Has been cancelled
Spell checking / Report (Push) (push) Has been cancelled
Spell checking / Report (PR) (push) Has been cancelled
Spell checking / Update PR (push) Has been cancelled
Updates for check-spelling v0.0.25 (#40386)
## Summary of the Pull Request

- #39572 updated check-spelling but ignored:
   > 🐣 Breaking Changes
[Code Scanning action requires a Code Scanning
Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset)
If you use SARIF reporting, then instead of the workflow yielding an 
when it fails, it will rely on [github-advanced-security
🤖](https://github.com/apps/github-advanced-security) to report the
failure. You will need to adjust your checks for PRs.

This means that check-spelling hasn't been properly doing its job 😦.

I'm sorry, I should have pushed a thing to this repo earlier,...

Anyway, as with most refreshes, this comes with a number of fixes, some
are fixes for typos that snuck in before the 0.0.25 upgrade, some are
for things that snuck in after, some are based on new rules in
spell-check-this, and some are hand written patterns based on running
through this repository a few times.

About the 🐣 **breaking change**: someone needs to create a ruleset for
this repository (see [Code Scanning action requires a Code Scanning
Ruleset: Sample ruleset

](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)).

The alternative to adding a ruleset is to change the condition to not
use sarif for this repository. In general, I think the github
integration from sarif is prettier/more helpful, so I think that it's
the better choice.

You can see an example of it working in:
- https://github.com/check-spelling-sandbox/PowerToys/pull/23

---------

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-07-08 17:16:52 -05:00

3.6 KiB

Interface definition

class PowertoyModuleIface {
public:
  virtual const wchar_t* get_name() = 0;
  virtual const wchar_t** get_events() = 0;
  virtual bool get_config(wchar_t* buffer, int *buffer_size) = 0;
  virtual void set_config(const wchar_t* config) = 0;
  virtual void call_custom_action(const wchar_t* action) {};
  virtual void enable() = 0;
  virtual void disable() = 0;
  virtual bool is_enabled() = 0;
  virtual void destroy() = 0;
};

typedef PowertoyModuleIface* (__cdecl *powertoy_create_func)();

Runtime logic

The PowerToys runner will, for each PowerToy DLL:

On the received object, the runner will call:

While running, the runner might call the following methods between create_powertoy() and destroy():

When terminating, the runner will:

  • call disable(),
  • call destroy() which should free all the memory and delete the PowerToy object,
  • unload the DLL.

Method definition

This section contains a more detailed description of each of the interface methods.

powertoy_create_func

typedef PowertoyModuleIface* (__cdecl *powertoy_create_func)()

Typedef of the factory function that creates the PowerToy object. Must be exported by the DLL as powertoy_create().

Called by the PowerToys runner to initialize each PowerToy. It will be called only once before a call to destroy() is made.

The returned PowerToy should be in the disabled state. The runner will call the enable() method to start the PowerToy.

In case of errors returns nullptr.

get_name

virtual const wchar_t* get_name()

Returns the name of the PowerToy, it will be cached by the runner.

get_config

virtual bool get_config(wchar_t* buffer, int *buffer_size)

Fills a buffer with the available configuration settings.

If buffer is a null pointer or the buffer size is not large enough sets the required buffer size in 'buffer_size' and return false.

Returns true if successful.

set_config

virtual void set_config(const wchar_t* config)

After the user has changed the module settings in the Settings editor, the runner calls this method to pass the updated values to the module. It's a good place to save the settings as well.

call_custom_action

  virtual void call_custom_action(const wchar_t* action)

Calls a custom action in response to the user pressing the custom action button in the Settings editor. This can be used to spawn custom editors defined by the PowerToy.

enable

  virtual void enable()

Enables the PowerToy.

disable

  virtual void disable()

Disables the PowerToy, should free as much memory as possible.

is_enabled

  virtual bool is_enabled() = 0;

Returns the PowerToy state.

destroy

  virtual void destroy()

Destroy the PowerToy and free all memory.

Code organization

powertoy_module_interface.h

Contains the PowerToys interface definition.