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.

74 lines
1.8 KiB

  1. // $$ClassType$$IT.cpp : Implementation of C$$ClassType$$IT
  2. #include "stdafx.h"
  3. #include "InfoTipTest.h"
  4. #include "$$ClassType$$IT.h"
  5. #include "shlobj.h"
  6. /////////////////////////////////////////////////////////////////////////////
  7. // C$$ClassType$$IT
  8. // IPersist methods
  9. STDMETHODIMP C$$ClassType$$IT::GetClassID(CLSID *pclsid)
  10. {
  11. *pclsid = CLSID_$$ClassType$$IT;
  12. return NOERROR;
  13. }
  14. // IPersistFile methods
  15. STDMETHODIMP C$$ClassType$$IT::Load(LPCOLESTR pcwszFileName, DWORD dwMode)
  16. {
  17. lstrcpyW(_wszFileName, pcwszFileName);
  18. return NOERROR;
  19. }
  20. // IQueryInfo methods
  21. STDMETHODIMP C$$ClassType$$IT::GetInfoTip(DWORD dwFlags, WCHAR **ppwszTip)
  22. {
  23. IShellLink* psl;
  24. HRESULT hres;
  25. hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
  26. (void **)&psl);
  27. if(SUCCEEDED(hres))
  28. {
  29. IPersistFile* ppf;
  30. hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
  31. if (SUCCEEDED(hres))
  32. {
  33. hres = ppf->Load(_wszFileName, 0);
  34. if (SUCCEEDED(hres))
  35. {
  36. TCHAR szTarget[MAX_PATH];
  37. hres = psl->GetPath(szTarget, MAX_PATH, NULL, 0);
  38. if (SUCCEEDED(hres))
  39. {
  40. WCHAR* pwszOut = new WCHAR[MAX_PATH];
  41. if (!pwszOut)
  42. hres = E_OUTOFMEMORY;
  43. else
  44. {
  45. MultiByteToWideChar(CP_ACP, 0, szTarget, -1, pwszOut, MAX_PATH);
  46. *ppwszTip = pwszOut;
  47. // Caller will free pszOut
  48. }
  49. }
  50. }
  51. ppf->Release();
  52. }
  53. psl->Release();
  54. }
  55. return hres;
  56. }
  57. STDMETHODIMP C$$ClassType$$IT::GetInfoFlags(DWORD *pdwFlags)
  58. {
  59. *pdwFlags = 0;
  60. return NOERROR;
  61. }