Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.8 KiB

  1. #include "shellprv.h"
  2. #pragma hdrstop
  3. #include "xiconwrap.h"
  4. // IUnknown
  5. STDMETHODIMP CExtractIconBase::QueryInterface(REFIID riid, void** ppv)
  6. {
  7. static const QITAB qit[] =
  8. {
  9. QITABENT(CExtractIconBase, IExtractIconA),
  10. QITABENT(CExtractIconBase, IExtractIconW),
  11. { 0 },
  12. };
  13. return QISearch(this, qit, riid, ppv);
  14. }
  15. STDMETHODIMP_(ULONG) CExtractIconBase::AddRef()
  16. {
  17. return InterlockedIncrement(&_cRef);
  18. }
  19. STDMETHODIMP_(ULONG) CExtractIconBase::Release()
  20. {
  21. if (InterlockedDecrement(&_cRef))
  22. return _cRef;
  23. delete this;
  24. return 0;
  25. }
  26. CExtractIconBase::CExtractIconBase() : _cRef(1)
  27. {
  28. DllAddRef();
  29. }
  30. CExtractIconBase::~CExtractIconBase()
  31. {
  32. DllRelease();
  33. }
  34. // IExtractIconA
  35. STDMETHODIMP CExtractIconBase::GetIconLocation(UINT uFlags,
  36. LPSTR pszIconFile, UINT cchMax, int* piIndex, UINT* pwFlags)
  37. {
  38. WCHAR sz[MAX_PATH];
  39. HRESULT hr = _GetIconLocationW(uFlags, sz, ARRAYSIZE(sz), piIndex, pwFlags);
  40. if (S_OK == hr)
  41. {
  42. // We don't want to copy the icon file name on the S_FALSE case
  43. SHUnicodeToAnsi(sz, pszIconFile, cchMax);
  44. }
  45. return hr;
  46. }
  47. STDMETHODIMP CExtractIconBase::Extract(LPCSTR pszFile, UINT nIconIndex,
  48. HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize)
  49. {
  50. WCHAR sz[MAX_PATH];
  51. SHAnsiToUnicode(pszFile, sz, ARRAYSIZE(sz));
  52. return _ExtractW(sz, nIconIndex, phiconLarge, phiconSmall, nIconSize);
  53. }
  54. // IExtractIconW
  55. STDMETHODIMP CExtractIconBase::GetIconLocation(UINT uFlags,
  56. LPWSTR pszIconFile, UINT cchMax, int* piIndex, UINT* pwFlags)
  57. {
  58. return _GetIconLocationW(uFlags, pszIconFile, cchMax, piIndex, pwFlags);
  59. }
  60. STDMETHODIMP CExtractIconBase::Extract(LPCWSTR pszFile, UINT nIconIndex,
  61. HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize)
  62. {
  63. return _ExtractW(pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
  64. }