forked from jame25/foo_nowbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent.cpp
More file actions
65 lines (53 loc) · 2.03 KB
/
component.cpp
File metadata and controls
65 lines (53 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "pch.h"
#include "version.h"
#include "guids.h"
#include "core/playback_state.h"
#include "core/control_panel_core.h"
#include "artwork_bridge.h"
// Module instance handle for dialog creation
HINSTANCE g_hInstance = nullptr;
// Declare component version
DECLARE_COMPONENT_VERSION(
FOO_NOWBAR_DISPLAY_NAME,
FOO_NOWBAR_VERSION_STRING,
FOO_NOWBAR_DESCRIPTION
);
// Prevent component from being unloaded (required for proper cleanup)
VALIDATE_COMPONENT_FILENAME("foo_nowbar.dll");
// GDI+ initialization
namespace {
ULONG_PTR g_gdiplusToken = 0;
class GdiplusInitializer : public initquit {
public:
void on_init() override {
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, nullptr);
// Force early instantiation of PlaybackStateManager to ensure it
// registers for playback callbacks before any playback starts
nowbar::PlaybackStateManager::get();
// Initialize foo_artwork bridge for online artwork support
init_artwork_bridge();
}
void on_quit() override {
// Unregister foo_artwork callback before other cleanup
shutdown_artwork_bridge();
// Clean up static objects while services are still available
// Order matters: ControlPanelCore first (clears instances & theme callback),
// then PlaybackStateManager (unregisters from play_callback_manager)
nowbar::ControlPanelCore::shutdown();
nowbar::PlaybackStateManager::shutdown();
if (g_gdiplusToken) {
Gdiplus::GdiplusShutdown(g_gdiplusToken);
g_gdiplusToken = 0;
}
}
};
static initquit_factory_t<GdiplusInitializer> g_gdiplus_init;
}
// DllMain to capture module instance handle
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID /*reserved*/) {
if (reason == DLL_PROCESS_ATTACH) {
g_hInstance = hModule;
}
return TRUE;
}