PowerToys/src/runner/powertoy_module.h

54 lines
1.1 KiB
C
Raw Normal View History

#pragma once
#include <interface/powertoy_module_interface.h>
#include <string>
#include <memory>
#include <mutex>
#include <vector>
#include <functional>
#include <common/utils/json.h>
2019-12-27 00:26:11 +08:00
struct PowertoyModuleDeleter
{
void operator()(PowertoyModuleIface* pt_module) const
2019-12-27 00:26:11 +08:00
{
if (pt_module)
2019-12-27 00:26:11 +08:00
{
pt_module->destroy();
2019-12-27 00:26:11 +08:00
}
}
};
2019-12-27 00:26:11 +08:00
struct PowertoyModuleDLLDeleter
{
using pointer = HMODULE;
void operator()(HMODULE handle) const
{
FreeLibrary(handle);
}
};
2019-12-27 00:26:11 +08:00
class PowertoyModule
{
public:
PowertoyModule(PowertoyModuleIface* pt_module, HMODULE handle);
2019-12-27 00:26:11 +08:00
inline PowertoyModuleIface* operator->()
2019-12-27 00:26:11 +08:00
{
return pt_module.get();
}
2019-12-27 00:26:11 +08:00
json::JsonObject json_config() const;
void update_hotkeys();
void UpdateHotkeyEx();
private:
2019-12-27 00:26:11 +08:00
std::unique_ptr<HMODULE, PowertoyModuleDLLDeleter> handle;
std::unique_ptr<PowertoyModuleIface, PowertoyModuleDeleter> pt_module;
};
PowertoyModule load_powertoy(const std::wstring_view filename);
std::map<std::wstring, PowertoyModule>& modules();