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
2.0 KiB

  1. /*++
  2. Module Name:
  3. WrpMBWrp.cpp
  4. Abstract:
  5. A wrapper for my metabase wrapper wrapper. Why? All it does is provide
  6. AFX support for CString classes. Everything else is passed on to the parent
  7. Author:
  8. Boyd Multerer bmulterer@accessone.com
  9. --*/
  10. //C:\nt\public\sdk\lib\i386
  11. #include "stdafx.h"
  12. #include <iiscnfgp.h>
  13. #include "wrapmb.h"
  14. #include "WrpMBWrp.h"
  15. //-----------------------------------------------------------------------------
  16. BOOL CAFX_MetaWrapper::GetString( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType,
  17. CString &sz, DWORD dwFlags )
  18. {
  19. PCHAR pData = NULL;
  20. DWORD cbData = 0;
  21. DWORD err = 0;
  22. BOOL f;
  23. // first, get the size of the data that we are looking for - it will fail because of the NULL,
  24. // but, the size we need should be in cbData;
  25. f = GetData( pszPath, dwPropID, dwUserType, STRING_METADATA, NULL, &cbData );
  26. // check the error - it should be some sort of memory error
  27. err = GetLastError();
  28. // it is ok that the GetData failed, but the reason had better be ERROR_INSUFFICIENT_BUFFER
  29. // otherwise, it is something we can't handle
  30. if ( err != ERROR_INSUFFICIENT_BUFFER )
  31. return FALSE;
  32. // allocate the buffer
  33. pData = (PCHAR)GlobalAlloc( GPTR, cbData + 1 );
  34. if ( !pData ) return FALSE;
  35. // zero out the buffer
  36. ZeroMemory( pData, cbData + 1 );
  37. // first, get the size of the data that we are looking for
  38. f = GetData( pszPath, dwPropID, dwUserType, STRING_METADATA, pData, &cbData );
  39. // if that getting failed, we need to cleanup
  40. if ( !f )
  41. {
  42. GlobalFree( pData );
  43. return FALSE;
  44. }
  45. // set the answer
  46. sz = pData;
  47. // clean up
  48. GlobalFree( pData );
  49. // return the allocated buffer
  50. return TRUE;
  51. }
  52.