1
0

winampApi.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include "main.h"
  2. #include "./winampApi.h"
  3. WinampApi::WinampApi()
  4. {}
  5. WinampApi::~WinampApi()
  6. {}
  7. HRESULT WinampApi::CreateInstance(WinampApi **instance)
  8. {
  9. if (NULL == instance) return E_POINTER;
  10. *instance = new WinampApi();
  11. if (NULL == *instance) return E_OUTOFMEMORY;
  12. return S_OK;
  13. }
  14. const char *WinampApi::getServiceName()
  15. {
  16. return "Winamp API";
  17. }
  18. const GUID WinampApi::getServiceGuid()
  19. {
  20. return winampApiGuid;
  21. }
  22. size_t WinampApi::AddRef()
  23. {
  24. return _ref.fetch_add( 1 );
  25. }
  26. size_t WinampApi::Release()
  27. {
  28. if ( _ref.load() == 0 )
  29. return _ref.load();
  30. LONG r = _ref.fetch_sub( 1 );
  31. if (0 == r)
  32. delete(this);
  33. return r;
  34. }
  35. int WinampApi::QueryInterface(GUID interface_guid, void **object)
  36. {
  37. if (NULL == object) return E_POINTER;
  38. *object = NULL;
  39. return E_NOINTERFACE;
  40. }
  41. HWND WinampApi::GetMainWindow(void)
  42. {
  43. return hMainWindow;
  44. }
  45. HWND WinampApi::GetDlgParent(void)
  46. {
  47. return (g_dialog_box_parent) ? g_dialog_box_parent : hMainWindow;
  48. }
  49. HRESULT WinampApi::OpenUrl(HWND hwnd, const wchar_t *url)
  50. {
  51. myOpenURL(hwnd, (wchar_t*)url);
  52. return S_OK;
  53. }
  54. int WinampApi::GetRegVer()
  55. {
  56. return 2;
  57. }
  58. #define CBCLASS WinampApi
  59. START_DISPATCH;
  60. CB(ADDREF, AddRef)
  61. CB(RELEASE, Release)
  62. CB(QUERYINTERFACE, QueryInterface)
  63. CB(API_GETMAINWINDOW, GetMainWindow)
  64. CB(API_GETDLGPARENT, GetDlgParent)
  65. CB(API_OPENURL, OpenUrl)
  66. CB(API_GETREGVER, GetRegVer)
  67. END_DISPATCH;
  68. #undef CBCLASS