NowPlayingPlugin: Minor changes.

This commit is contained in:
Birunthan Mohanathas 2011-07-15 15:18:02 +00:00
parent 5e20238120
commit 20e2a53324
5 changed files with 18 additions and 20 deletions

View File

@ -32,6 +32,7 @@
static std::map<UINT, ChildMeasure*> g_Measures; static std::map<UINT, ChildMeasure*> g_Measures;
std::wstring g_CachePath; std::wstring g_CachePath;
std::wstring g_SettingsFile; std::wstring g_SettingsFile;
HINSTANCE g_Instance = NULL;
/* /*
** Initialize ** 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."); LSLog(LOG_ERROR, L"Rainmeter", L"NowPlayingPlugin: Unable to get path to Plugins.ini.");
} }
g_Instance = instance;
CInternet::Initialize(); CInternet::Initialize();
} }

View File

@ -22,6 +22,7 @@
CPlayer* CPlayerCAD::c_Player = NULL; CPlayer* CPlayerCAD::c_Player = NULL;
extern std::wstring g_SettingsFile; extern std::wstring g_SettingsFile;
extern HINSTANCE g_Instance;
// This player emulates the CD Art Display IPC interface, which is supported by // This player emulates the CD Art Display IPC interface, which is supported by
// MusicBee, VLC (with libcad plugin), and possibly others. // MusicBee, VLC (with libcad plugin), and possibly others.
@ -76,11 +77,9 @@ CPlayer* CPlayerCAD::Create()
*/ */
void CPlayerCAD::Initialize() void CPlayerCAD::Initialize()
{ {
HINSTANCE hInstance = GetModuleHandle(NULL);
// Create windows class // Create windows class
WNDCLASS wc = {0}; WNDCLASS wc = {0};
wc.hInstance = hInstance; wc.hInstance = g_Instance;
wc.lpfnWndProc = WndProc; wc.lpfnWndProc = WndProc;
wc.lpszClassName = L"NowPlayingCADClass"; wc.lpszClassName = L"NowPlayingCADClass";
RegisterClass(&wc); RegisterClass(&wc);
@ -95,7 +94,7 @@ void CPlayerCAD::Initialize()
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL,
NULL, NULL,
hInstance, g_Instance,
this); this);
// Add WM_USER/WM_COPYDATA to allowed messages from lower level processes // Add WM_USER/WM_COPYDATA to allowed messages from lower level processes
@ -197,7 +196,7 @@ void CPlayerCAD::Initialize()
void CPlayerCAD::Uninitialize() void CPlayerCAD::Uninitialize()
{ {
DestroyWindow(m_Window); DestroyWindow(m_Window);
UnregisterClass(L"NowPlayingCADClass", GetModuleHandle(NULL)); UnregisterClass(L"NowPlayingCADClass", g_Instance);
} }
/* /*

View File

@ -20,6 +20,7 @@
#include "PlayerFoobar.h" #include "PlayerFoobar.h"
CPlayer* CPlayerFoobar::c_Player = NULL; CPlayer* CPlayerFoobar::c_Player = NULL;
extern HINSTANCE g_Instance;
/* /*
** CPlayerFoobar ** CPlayerFoobar
@ -70,11 +71,9 @@ CPlayer* CPlayerFoobar::Create()
*/ */
void CPlayerFoobar::Initialize() void CPlayerFoobar::Initialize()
{ {
HINSTANCE hInstance = GetModuleHandle(NULL);
// Create windows class // Create windows class
WNDCLASS wc = {0}; WNDCLASS wc = {0};
wc.hInstance = hInstance; wc.hInstance = g_Instance;
wc.lpfnWndProc = WndProc; wc.lpfnWndProc = WndProc;
wc.lpszClassName = L"NowPlayingFoobarClass"; wc.lpszClassName = L"NowPlayingFoobarClass";
RegisterClass(&wc); RegisterClass(&wc);
@ -89,7 +88,7 @@ void CPlayerFoobar::Initialize()
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL,
NULL, NULL,
hInstance, g_Instance,
this); this);
m_FooWindow = FindWindow(L"foo_rainmeter_class", NULL); m_FooWindow = FindWindow(L"foo_rainmeter_class", NULL);
@ -125,7 +124,7 @@ void CPlayerFoobar::Uninitialize()
} }
DestroyWindow(m_Window); DestroyWindow(m_Window);
UnregisterClass(L"NowPlayingFoobarClass", GetModuleHandle(NULL)); UnregisterClass(L"NowPlayingFoobarClass", g_Instance);
} }
/* /*

View File

@ -20,6 +20,7 @@
#include "PlayerWLM.h" #include "PlayerWLM.h"
CPlayer* CPlayerWLM::c_Player = NULL; CPlayer* CPlayerWLM::c_Player = NULL;
extern HINSTANCE g_Instance;
// This player emulates the MSN/WLM Messenger 'Listening to' interface, which is // This player emulates the MSN/WLM Messenger 'Listening to' interface, which is
// supported by OpenPandora, Last.fm, Media Player Classic, TTPlayer, Zune, etc. // supported by OpenPandora, Last.fm, Media Player Classic, TTPlayer, Zune, etc.
@ -33,11 +34,9 @@ CPlayer* CPlayerWLM::c_Player = NULL;
CPlayerWLM::CPlayerWLM() : CPlayer(), CPlayerWLM::CPlayerWLM() : CPlayer(),
m_Window() m_Window()
{ {
HINSTANCE hInstance = GetModuleHandle(NULL);
// Create windows class // Create windows class
WNDCLASS wc = {0}; WNDCLASS wc = {0};
wc.hInstance = hInstance; wc.hInstance = g_Instance;
wc.lpfnWndProc = WndProc; wc.lpfnWndProc = WndProc;
wc.lpszClassName = L"MsnMsgrUIManager"; wc.lpszClassName = L"MsnMsgrUIManager";
RegisterClass(&wc); RegisterClass(&wc);
@ -52,7 +51,7 @@ CPlayerWLM::CPlayerWLM() : CPlayer(),
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL,
NULL, NULL,
hInstance, g_Instance,
this); this);
m_Initialized = true; m_Initialized = true;
@ -68,7 +67,7 @@ CPlayerWLM::~CPlayerWLM()
{ {
c_Player = NULL; c_Player = NULL;
DestroyWindow(m_Window); DestroyWindow(m_Window);
UnregisterClass(L"MsnMsgrUIManager", GetModuleHandle(NULL)); UnregisterClass(L"MsnMsgrUIManager", g_Instance);
} }
/* /*

View File

@ -20,6 +20,7 @@
#include "PlayerWMP.h" #include "PlayerWMP.h"
CPlayer* CPlayerWMP::c_Player = NULL; CPlayer* CPlayerWMP::c_Player = NULL;
extern HINSTANCE g_Instance;
/* /*
** CRemoteHost ** CRemoteHost
@ -199,11 +200,9 @@ CPlayer* CPlayerWMP::Create()
*/ */
void CPlayerWMP::Initialize() void CPlayerWMP::Initialize()
{ {
HINSTANCE hInstance = GetModuleHandle(NULL);
// Create windows class // Create windows class
WNDCLASS wc = {0}; WNDCLASS wc = {0};
wc.hInstance = hInstance; wc.hInstance = g_Instance;
wc.lpfnWndProc = DefWindowProc; wc.lpfnWndProc = DefWindowProc;
wc.lpszClassName = L"NowPlayingWMPClass"; wc.lpszClassName = L"NowPlayingWMPClass";
RegisterClass(&wc); RegisterClass(&wc);
@ -218,7 +217,7 @@ void CPlayerWMP::Initialize()
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL,
NULL, NULL,
hInstance, g_Instance,
NULL); NULL);
if (!m_Window) if (!m_Window)
@ -366,7 +365,7 @@ void CPlayerWMP::Uninitialize()
m_AxWindow->DestroyWindow(); m_AxWindow->DestroyWindow();
delete m_AxWindow; delete m_AxWindow;
DestroyWindow(m_Window); DestroyWindow(m_Window);
UnregisterClass(L"NowPlayingWMPClass", GetModuleHandle(NULL)); UnregisterClass(L"NowPlayingWMPClass", g_Instance);
} }
} }