1
0

setup.cpp 918 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "./main.h"
  2. #include "../winamp/setup/svc_setup.h"
  3. #include <shlwapi.h>
  4. EXTERN_C _declspec(dllexport) BOOL RegisterSetup(HINSTANCE hInstance, api_service *waServices)
  5. {
  6. WIN32_FIND_DATAW findData = {0};
  7. WCHAR szPath[MAX_PATH] = {0}, szBase[MAX_PATH] = {0};
  8. if (0 == GetModuleFileNameW(hInstance, szBase, ARRAYSIZE(szBase)))
  9. return 0;
  10. PathRemoveFileSpecW(szBase);
  11. PathCombineW(szPath, szBase, L"ml_*.dll");
  12. HANDLE hFind = FindFirstFileW(szPath, &findData);
  13. if (INVALID_HANDLE_VALUE == hFind)
  14. return FALSE;
  15. do
  16. {
  17. PathCombineW(szPath, szBase, findData.cFileName);
  18. HINSTANCE hLib = LoadLibraryW(szPath);
  19. if (NULL != hLib)
  20. {
  21. Plugin_RegisterSetup fn = (Plugin_RegisterSetup)GetProcAddress(hLib, "RegisterSetup");
  22. if (NULL == fn || FALSE == fn(hLib, waServices))
  23. {
  24. FreeModule(hLib);
  25. }
  26. }
  27. }
  28. while (FindNextFileW(hFind, &findData));
  29. FindClose(hFind);
  30. return FALSE;
  31. }