Leaked source code of windows server 2003
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.

81 lines
2.0 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. ASSERT( 0 != _cRef );
  22. ULONG cRef = InterlockedDecrement(&_cRef);
  23. if ( 0 == cRef )
  24. {
  25. delete this;
  26. }
  27. return cRef;
  28. }
  29. CExtractIconBase::CExtractIconBase() : _cRef(1)
  30. {
  31. DllAddRef();
  32. }
  33. CExtractIconBase::~CExtractIconBase()
  34. {
  35. DllRelease();
  36. }
  37. // IExtractIconA
  38. STDMETHODIMP CExtractIconBase::GetIconLocation(UINT uFlags,
  39. LPSTR pszIconFile, UINT cchMax, int* piIndex, UINT* pwFlags)
  40. {
  41. WCHAR sz[MAX_PATH];
  42. HRESULT hr = _GetIconLocationW(uFlags, sz, ARRAYSIZE(sz), piIndex, pwFlags);
  43. if (S_OK == hr)
  44. {
  45. // We don't want to copy the icon file name on the S_FALSE case
  46. SHUnicodeToAnsi(sz, pszIconFile, cchMax);
  47. }
  48. return hr;
  49. }
  50. STDMETHODIMP CExtractIconBase::Extract(LPCSTR pszFile, UINT nIconIndex,
  51. HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize)
  52. {
  53. WCHAR sz[MAX_PATH];
  54. SHAnsiToUnicode(pszFile, sz, ARRAYSIZE(sz));
  55. return _ExtractW(sz, nIconIndex, phiconLarge, phiconSmall, nIconSize);
  56. }
  57. // IExtractIconW
  58. STDMETHODIMP CExtractIconBase::GetIconLocation(UINT uFlags,
  59. LPWSTR pszIconFile, UINT cchMax, int* piIndex, UINT* pwFlags)
  60. {
  61. return _GetIconLocationW(uFlags, pszIconFile, cchMax, piIndex, pwFlags);
  62. }
  63. STDMETHODIMP CExtractIconBase::Extract(LPCWSTR pszFile, UINT nIconIndex,
  64. HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize)
  65. {
  66. return _ExtractW(pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
  67. }