aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_local/util.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Library/ml_local/util.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Plugins/Library/ml_local/util.cpp')
-rw-r--r--Src/Plugins/Library/ml_local/util.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/Src/Plugins/Library/ml_local/util.cpp b/Src/Plugins/Library/ml_local/util.cpp
new file mode 100644
index 00000000..8ac23b8d
--- /dev/null
+++ b/Src/Plugins/Library/ml_local/util.cpp
@@ -0,0 +1,77 @@
+#include "main.h"
+#include "../replicant/nu/ns_wc.h"
+#include "ml_local.h"
+#include <string.h>
+#include <shlobj.h>
+#include "..\..\General\gen_ml/config.h"
+#include "resource.h"
+
+extern "C" {
+
+void process_substantives(wchar_t* dest)
+{
+ if(!substantives)
+ {
+ wchar_t *b = dest;
+ while (!IsCharSpaceW(*b) && *b) b++;
+ while (IsCharSpaceW(*b) && *b) b++;
+ while (!IsCharSpaceW(*b) && *b) b++;
+ CharLowerW(b);
+ }
+}
+
+HRESULT ResolveShortCut(HWND hwnd, LPCWSTR pszShortcutFile, LPWSTR pszPath)
+{
+ IShellLink* psl = 0;
+ WIN32_FIND_DATA wfd = {0};
+
+ *pszPath = 0; // assume failure
+
+ HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+ IID_IShellLink, (void **) &psl);
+ if (SUCCEEDED(hres))
+ {
+ IPersistFile* ppf;
+
+ hres = psl->QueryInterface(IID_IPersistFile, (void **) &ppf); // OLE 2! Yay! --YO
+ if (SUCCEEDED(hres))
+ {
+ wchar_t wsz[MAX_PATH] = {0};
+
+ hres = ppf->Load(wsz, STGM_READ);
+ if (SUCCEEDED(hres))
+ {
+ hres = psl->Resolve(hwnd, SLR_ANY_MATCH);
+ if (SUCCEEDED(hres))
+ {
+ wchar_t szGotPath[MAX_PATH] = {0};
+ wcsncpy(szGotPath, pszShortcutFile, MAX_PATH);
+ hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA *)&wfd, SLGP_SHORTPATH );
+ wcsncpy(pszPath, szGotPath, MAX_PATH);
+ }
+ }
+ ppf->Release();
+ }
+ psl->Release();
+ }
+ return SUCCEEDED(hres);
+}
+
+void ConvertRatingMenuStar(HMENU menu, UINT menu_id)
+{
+ MENUITEMINFOW mi = {sizeof(mi), MIIM_DATA | MIIM_TYPE, MFT_STRING};
+ wchar_t rateBuf[32], *rateStr = rateBuf;
+ mi.dwTypeData = rateBuf;
+ mi.cch = 32;
+ if(GetMenuItemInfoW(menu, menu_id, FALSE, &mi))
+ {
+ while(rateStr && *rateStr)
+ {
+ if(*rateStr == L'*') *rateStr = L'\u2605';
+ rateStr=CharNextW(rateStr);
+ }
+ SetMenuItemInfoW(menu, menu_id, FALSE, &mi);
+ }
+}
+
+}; \ No newline at end of file