home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / MFC / SRC / VALIDADD.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-30  |  1.1 KB  |  39 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1997 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.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_AUX_SEG
  14. #pragma code_seg(AFX_AUX_SEG)
  15. #endif
  16.  
  17. BOOL AFXAPI AfxIsValidString(LPCWSTR lpsz, int nLength)
  18. {
  19.     if (lpsz == NULL)
  20.         return FALSE;
  21.     return afxData.bWin32s || ::IsBadStringPtrW(lpsz, nLength) == 0;
  22. }
  23.  
  24. BOOL AFXAPI AfxIsValidString(LPCSTR lpsz, int nLength)
  25. {
  26.     if (lpsz == NULL)
  27.         return FALSE;
  28.     return ::IsBadStringPtrA(lpsz, nLength) == 0;
  29. }
  30.  
  31. BOOL AFXAPI AfxIsValidAddress(const void* lp, UINT nBytes, BOOL bReadWrite)
  32. {
  33.     // simple version using Win-32 APIs for pointer validation.
  34.     return (lp != NULL && !IsBadReadPtr(lp, nBytes) &&
  35.         (!bReadWrite || !IsBadWritePtr((LPVOID)lp, nBytes)));
  36. }
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39.