workorder.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "workorder.h"
  2. #include "main.h"
  3. #include "cddb.h"
  4. #include <shlwapi.h>
  5. CDDBModuleWorkOrderManagerInterface *workorder=0;
  6. static HMODULE musicIDLib = 0;
  7. void OpenMusicIDWorkOrder()
  8. {
  9. if (!workorder)
  10. {
  11. char pluginpath[MAX_PATH] = {0};
  12. GetModuleFileNameA(line.hDllInstance, pluginpath, MAX_PATH);
  13. PathRemoveFileSpecA(pluginpath);
  14. PathAppendA(pluginpath, "Gracenote");
  15. char musicidpath[MAX_PATH] = {0};
  16. PathCombineA(musicidpath, pluginpath, "CddbWOManagerWinamp.dll");
  17. musicIDLib = LoadLibraryA(musicidpath);
  18. if (musicIDLib)
  19. {
  20. CDDBModuleQueryInterfaceFunc qi = (CDDBModuleQueryInterfaceFunc)GetProcAddress(musicIDLib, "CDDBModuleQueryInterface");
  21. if (qi)
  22. {
  23. ICDDBControl *pControl;
  24. Cddb_GetIControl((void**)&pControl);
  25. workorder = (CDDBModuleWorkOrderManagerInterface*)qi("workordermanager");
  26. if (!(workorder && workorder->base.version == CDDBMODULE_VERSION && workorder->version == CDDBMODULE_WORKORDER_MGR_VERSION
  27. && workorder->base.Init && workorder->base.Init(0)
  28. && workorder->Initialize(pControl, pluginpath) == 0))
  29. {
  30. workorder = 0;
  31. FreeLibrary(musicIDLib);
  32. musicIDLib=0;
  33. }
  34. if (pControl) pControl->Release();
  35. }
  36. }
  37. }
  38. }
  39. void ShutdownMusicIDWorkOrder()
  40. {
  41. if (workorder)
  42. workorder->Shutdown();
  43. workorder=0;
  44. if (musicIDLib)
  45. FreeLibrary(musicIDLib);
  46. musicIDLib=0;
  47. }