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.

50 lines
1.0 KiB

  1. #include "dataobj.h"
  2. #include <string.h>
  3. HRESULT
  4. CDataObject::RenderText(
  5. LPSTGMEDIUM pSTM,
  6. LPTSTR lptstr,
  7. DWORD flags)
  8. {
  9. DWORD cch;
  10. HGLOBAL hMem;
  11. LPTSTR psz;
  12. UINT i;
  13. if(!(FL_MAKE_ITEM & flags))
  14. hMem = pSTM->hGlobal;
  15. else
  16. hMem = GlobalAlloc(GMEM_SHARE | GMEM_MOVEABLE, m_cDataSize);
  17. if (NULL==hMem)
  18. return ResultFromScode(STG_E_MEDIUMFULL);
  19. cch = 64 / sizeof(TCHAR);
  20. psz=(LPTSTR)GlobalLock(hMem);
  21. wsprintf(psz, TEXT("%ld:"), m_cDataSize);
  22. for (i=lstrlen(psz); i<cch-1, '\0'!=*lptstr; i++, lptstr++)
  23. *(psz+i) = *lptstr;
  24. for ( ; i < cch-1; i++)
  25. *(psz+i)=TEXT(' ') + (i % 32);
  26. *(psz+i)=0;
  27. GlobalUnlock(hMem);
  28. if(FL_MAKE_ITEM & flags)
  29. {
  30. pSTM->hGlobal=hMem;
  31. pSTM->tymed=TYMED_HGLOBAL;
  32. pSTM->pUnkForRelease=NULL;
  33. }
  34. if(FL_PASS_PUNK & flags)
  35. GetStgMedpUnkForRelease(pSTM, &pSTM->pUnkForRelease);
  36. return NOERROR;
  37. }
  38.