olevar1.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // new COleVariant code (uses new features of OLEAUT32.DLL)
  17. COleVariant::COleVariant(LPCITEMIDLIST pidl)
  18. {
  19. AfxVariantInit(this);
  20. if (pidl != NULL)
  21. {
  22. // walk through entries in the list and accumulate their size
  23. UINT cbTotal = 0;
  24. SAFEARRAY *psa = NULL;
  25. LPCITEMIDLIST pidlWalker = pidl;
  26. while (pidlWalker->mkid.cb)
  27. {
  28. cbTotal += pidlWalker->mkid.cb;
  29. pidlWalker = (LPCITEMIDLIST)
  30. (((LPBYTE)pidlWalker) + pidlWalker->mkid.cb);
  31. }
  32. // add the base structure size
  33. cbTotal += sizeof(ITEMIDLIST);
  34. // get a safe array for them
  35. psa = SafeArrayCreateVector(VT_UI1, 0, cbTotal);
  36. // copy it and set members
  37. if (psa != NULL)
  38. {
  39. memcpy(psa->pvData, (LPBYTE) pidl, cbTotal);
  40. vt = VT_ARRAY | VT_UI1;
  41. parray = psa;
  42. }
  43. }
  44. }
  45. /////////////////////////////////////////////////////////////////////////////