-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcomponent.cpp
More file actions
66 lines (54 loc) · 2.26 KB
/
component.cpp
File metadata and controls
66 lines (54 loc) · 2.26 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
66
#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();
// GdiplusShutdown is intentionally NOT called here. DUI element
// destructors run after initquit::on_quit returns, and they own
// std::unique_ptr<Gdiplus::Bitmap/Font/SolidBrush> members. Shutting
// GDI+ down here would cause their destructors to dereference
// disposed GDI+ state. Windows reclaims GDI+ on process exit.
}
};
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;
}