util.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "main.h"
  2. #include "../replicant/nu/ns_wc.h"
  3. #include "ml_local.h"
  4. #include <string.h>
  5. #include <shlobj.h>
  6. #include "..\..\General\gen_ml/config.h"
  7. #include "resource.h"
  8. extern "C" {
  9. void process_substantives(wchar_t* dest)
  10. {
  11. if(!substantives)
  12. {
  13. wchar_t *b = dest;
  14. while (!IsCharSpaceW(*b) && *b) b++;
  15. while (IsCharSpaceW(*b) && *b) b++;
  16. while (!IsCharSpaceW(*b) && *b) b++;
  17. CharLowerW(b);
  18. }
  19. }
  20. HRESULT ResolveShortCut(HWND hwnd, LPCWSTR pszShortcutFile, LPWSTR pszPath)
  21. {
  22. IShellLink* psl = 0;
  23. WIN32_FIND_DATA wfd = {0};
  24. *pszPath = 0; // assume failure
  25. HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
  26. IID_IShellLink, (void **) &psl);
  27. if (SUCCEEDED(hres))
  28. {
  29. IPersistFile* ppf;
  30. hres = psl->QueryInterface(IID_IPersistFile, (void **) &ppf); // OLE 2! Yay! --YO
  31. if (SUCCEEDED(hres))
  32. {
  33. wchar_t wsz[MAX_PATH] = {0};
  34. hres = ppf->Load(wsz, STGM_READ);
  35. if (SUCCEEDED(hres))
  36. {
  37. hres = psl->Resolve(hwnd, SLR_ANY_MATCH);
  38. if (SUCCEEDED(hres))
  39. {
  40. wchar_t szGotPath[MAX_PATH] = {0};
  41. wcsncpy(szGotPath, pszShortcutFile, MAX_PATH);
  42. hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA *)&wfd, SLGP_SHORTPATH );
  43. wcsncpy(pszPath, szGotPath, MAX_PATH);
  44. }
  45. }
  46. ppf->Release();
  47. }
  48. psl->Release();
  49. }
  50. return SUCCEEDED(hres);
  51. }
  52. void ConvertRatingMenuStar(HMENU menu, UINT menu_id)
  53. {
  54. MENUITEMINFOW mi = {sizeof(mi), MIIM_DATA | MIIM_TYPE, MFT_STRING};
  55. wchar_t rateBuf[32], *rateStr = rateBuf;
  56. mi.dwTypeData = rateBuf;
  57. mi.cch = 32;
  58. if(GetMenuItemInfoW(menu, menu_id, FALSE, &mi))
  59. {
  60. while(rateStr && *rateStr)
  61. {
  62. if(*rateStr == L'*') *rateStr = L'\u2605';
  63. rateStr=CharNextW(rateStr);
  64. }
  65. SetMenuItemInfoW(menu, menu_id, FALSE, &mi);
  66. }
  67. }
  68. };