Tests any memory address to ensure that it is contained entirely within the program's memory space.
测试任何内存地址,以确保它是完全包含在程序的内存空间。
BOOL AfxIsValidAddress(
const void* lp,
UINT nBytes,
BOOL bReadWrite = TRUE
);
Parameters
Return Value
In debug builds, nonzero if the specified memory block is contained entirely within the program's memory space; otherwise 0.
在调试版,如果指定的内存被完全包含在程序的内存空间,返回值不为0,否则为0.
In non-debug builds, nonzero if lp is not NULL; otherwise 0.
在调试构建,如果lp不为空,返回值不为0,否则返回值为0.
Remarks
The address is not restricted to blocks allocated by new.
地址不仅限于模块分配新的地址。
Example
// Allocate a 5 character array, which should have a valid memory address.
char* arr = new char[5];
// Create a null pointer, which should be an invalid memory address.
char* null = (char*)0x0;
ASSERT(AfxIsValidAddress(arr, 5));
ASSERT(!AfxIsValidAddress(null, 5));
Requirements
Header: afx.h