diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Winamp/SHELL.CPP | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Winamp/SHELL.CPP')
-rw-r--r-- | Src/Winamp/SHELL.CPP | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Src/Winamp/SHELL.CPP b/Src/Winamp/SHELL.CPP new file mode 100644 index 00000000..a434799e --- /dev/null +++ b/Src/Winamp/SHELL.CPP @@ -0,0 +1,85 @@ +/** (c) Nullsoft, Inc. C O N F I D E N T I A L + ** Filename: + ** Project: + ** Description: + ** Author: + ** Created: + **/ + +#include "main.h" +#include "../nu/ns_wc.h" +extern "C" +{ + HRESULT ResolveShortCut(HWND hwnd, LPCWSTR pszShortcutFile, LPWSTR pszPath) + { + IShellLinkW *psl = 0; + WIN32_FIND_DATAW wfd = {0}; + + *pszPath = 0; // assume failure + + HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (void **) & psl); + if (SUCCEEDED(hres)) + { + IPersistFile *ppf = 0; + hres = psl->QueryInterface(IID_IPersistFile, (void **) &ppf); // OLE 2! Yay! --YO + if (SUCCEEDED(hres)) + { + hres = ppf->Load(pszShortcutFile, STGM_READ); + if (SUCCEEDED(hres)) + { + hres = psl->Resolve(hwnd, SLR_ANY_MATCH); + if (SUCCEEDED(hres)) + { + wchar_t szGotPath[MAX_PATH] = {0}; + StringCchCopyW(szGotPath, MAX_PATH, pszShortcutFile); + hres = psl->GetPath(szGotPath, MAX_PATH, & wfd, + SLGP_SHORTPATH ); + StringCchCopyW(pszPath, MAX_PATH, szGotPath); + } + } + ppf->Release(); + } + psl->Release(); + } + return SUCCEEDED(hres); + } + + /*void CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszExe, LPCSTR pszArg, int iconindex) + { + HRESULT hres; + IShellLink* psl; + + 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}; + MultiByteToWideCharSZ(CP_ACP, 0, pszShortcutFile, -1, wsz, MAX_PATH); + + hres = psl->SetPath(pszExe); + if (pszArg) + { + psl->SetArguments(pszArg); + } + psl->SetIconLocation(pszExe, iconindex); + + if (SUCCEEDED(hres)) + { + ppf->Save(wsz, TRUE); + } + ppf->Release(); + } + psl->Release(); + } + }*/ + + void Shell_Free(void *p) + { + CoTaskMemFree(p); + } +}
\ No newline at end of file |