diff --git a/Plugins/PluginNowPlaying/NowPlaying.cpp b/Plugins/PluginNowPlaying/NowPlaying.cpp index cc6b96fb..ce64cb3b 100644 --- a/Plugins/PluginNowPlaying/NowPlaying.cpp +++ b/Plugins/PluginNowPlaying/NowPlaying.cpp @@ -32,6 +32,7 @@ static std::map g_Measures; std::wstring g_CachePath; std::wstring g_SettingsFile; +HINSTANCE g_Instance = NULL; /* ** Initialize @@ -63,6 +64,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) LSLog(LOG_ERROR, L"Rainmeter", L"NowPlayingPlugin: Unable to get path to Plugins.ini."); } + g_Instance = instance; CInternet::Initialize(); } diff --git a/Plugins/PluginNowPlaying/PlayerCAD.cpp b/Plugins/PluginNowPlaying/PlayerCAD.cpp index c23f4262..7cb62c92 100644 --- a/Plugins/PluginNowPlaying/PlayerCAD.cpp +++ b/Plugins/PluginNowPlaying/PlayerCAD.cpp @@ -22,6 +22,7 @@ CPlayer* CPlayerCAD::c_Player = NULL; extern std::wstring g_SettingsFile; +extern HINSTANCE g_Instance; // This player emulates the CD Art Display IPC interface, which is supported by // MusicBee, VLC (with libcad plugin), and possibly others. @@ -76,11 +77,9 @@ CPlayer* CPlayerCAD::Create() */ void CPlayerCAD::Initialize() { - HINSTANCE hInstance = GetModuleHandle(NULL); - // Create windows class WNDCLASS wc = {0}; - wc.hInstance = hInstance; + wc.hInstance = g_Instance; wc.lpfnWndProc = WndProc; wc.lpszClassName = L"NowPlayingCADClass"; RegisterClass(&wc); @@ -95,7 +94,7 @@ void CPlayerCAD::Initialize() CW_USEDEFAULT, NULL, NULL, - hInstance, + g_Instance, this); // Add WM_USER/WM_COPYDATA to allowed messages from lower level processes @@ -197,7 +196,7 @@ void CPlayerCAD::Initialize() void CPlayerCAD::Uninitialize() { DestroyWindow(m_Window); - UnregisterClass(L"NowPlayingCADClass", GetModuleHandle(NULL)); + UnregisterClass(L"NowPlayingCADClass", g_Instance); } /* diff --git a/Plugins/PluginNowPlaying/PlayerFoobar.cpp b/Plugins/PluginNowPlaying/PlayerFoobar.cpp index 3788777d..ee569bef 100644 --- a/Plugins/PluginNowPlaying/PlayerFoobar.cpp +++ b/Plugins/PluginNowPlaying/PlayerFoobar.cpp @@ -20,6 +20,7 @@ #include "PlayerFoobar.h" CPlayer* CPlayerFoobar::c_Player = NULL; +extern HINSTANCE g_Instance; /* ** CPlayerFoobar @@ -70,11 +71,9 @@ CPlayer* CPlayerFoobar::Create() */ void CPlayerFoobar::Initialize() { - HINSTANCE hInstance = GetModuleHandle(NULL); - // Create windows class WNDCLASS wc = {0}; - wc.hInstance = hInstance; + wc.hInstance = g_Instance; wc.lpfnWndProc = WndProc; wc.lpszClassName = L"NowPlayingFoobarClass"; RegisterClass(&wc); @@ -89,7 +88,7 @@ void CPlayerFoobar::Initialize() CW_USEDEFAULT, NULL, NULL, - hInstance, + g_Instance, this); m_FooWindow = FindWindow(L"foo_rainmeter_class", NULL); @@ -125,7 +124,7 @@ void CPlayerFoobar::Uninitialize() } DestroyWindow(m_Window); - UnregisterClass(L"NowPlayingFoobarClass", GetModuleHandle(NULL)); + UnregisterClass(L"NowPlayingFoobarClass", g_Instance); } /* diff --git a/Plugins/PluginNowPlaying/PlayerWLM.cpp b/Plugins/PluginNowPlaying/PlayerWLM.cpp index 592091c6..fc7de47a 100644 --- a/Plugins/PluginNowPlaying/PlayerWLM.cpp +++ b/Plugins/PluginNowPlaying/PlayerWLM.cpp @@ -20,6 +20,7 @@ #include "PlayerWLM.h" CPlayer* CPlayerWLM::c_Player = NULL; +extern HINSTANCE g_Instance; // This player emulates the MSN/WLM Messenger 'Listening to' interface, which is // supported by OpenPandora, Last.fm, Media Player Classic, TTPlayer, Zune, etc. @@ -33,11 +34,9 @@ CPlayer* CPlayerWLM::c_Player = NULL; CPlayerWLM::CPlayerWLM() : CPlayer(), m_Window() { - HINSTANCE hInstance = GetModuleHandle(NULL); - // Create windows class WNDCLASS wc = {0}; - wc.hInstance = hInstance; + wc.hInstance = g_Instance; wc.lpfnWndProc = WndProc; wc.lpszClassName = L"MsnMsgrUIManager"; RegisterClass(&wc); @@ -52,7 +51,7 @@ CPlayerWLM::CPlayerWLM() : CPlayer(), CW_USEDEFAULT, NULL, NULL, - hInstance, + g_Instance, this); m_Initialized = true; @@ -68,7 +67,7 @@ CPlayerWLM::~CPlayerWLM() { c_Player = NULL; DestroyWindow(m_Window); - UnregisterClass(L"MsnMsgrUIManager", GetModuleHandle(NULL)); + UnregisterClass(L"MsnMsgrUIManager", g_Instance); } /* diff --git a/Plugins/PluginNowPlaying/PlayerWMP.cpp b/Plugins/PluginNowPlaying/PlayerWMP.cpp index fc16f830..04146686 100644 --- a/Plugins/PluginNowPlaying/PlayerWMP.cpp +++ b/Plugins/PluginNowPlaying/PlayerWMP.cpp @@ -20,6 +20,7 @@ #include "PlayerWMP.h" CPlayer* CPlayerWMP::c_Player = NULL; +extern HINSTANCE g_Instance; /* ** CRemoteHost @@ -199,11 +200,9 @@ CPlayer* CPlayerWMP::Create() */ void CPlayerWMP::Initialize() { - HINSTANCE hInstance = GetModuleHandle(NULL); - // Create windows class WNDCLASS wc = {0}; - wc.hInstance = hInstance; + wc.hInstance = g_Instance; wc.lpfnWndProc = DefWindowProc; wc.lpszClassName = L"NowPlayingWMPClass"; RegisterClass(&wc); @@ -218,7 +217,7 @@ void CPlayerWMP::Initialize() CW_USEDEFAULT, NULL, NULL, - hInstance, + g_Instance, NULL); if (!m_Window) @@ -366,7 +365,7 @@ void CPlayerWMP::Uninitialize() m_AxWindow->DestroyWindow(); delete m_AxWindow; DestroyWindow(m_Window); - UnregisterClass(L"NowPlayingWMPClass", GetModuleHandle(NULL)); + UnregisterClass(L"NowPlayingWMPClass", g_Instance); } }