Directory Services |
The ReallocADsMem function resizes an existing memory block.
LPVOID ReallocADsMem( LPVOID pOldMem, DWORD cbOld, DWORD cbNew );
If cbNew is less than cbOld, the existing memory is truncated to fit the new memory size. The following code example illustrates how to use ReallocADsMem to enlarge a string.
LPWSTR path = (LPWSTR)AllocADsMem(9*sizeof(WCHAR)); wcsncpy(path, L"WinNT://",9); // Path becomes "WinNT://" printf("path = %S\n",path); path = (LPWSTR)ReallocADsMem(path, 9*sizeof(WCHAR), 18*sizeof(WCHAR)); // Path is still "WinNT://" if(path) { wcscat(path, L"localhost",18 - wcslen(path)); printf("path = %S\n",path); // Path is "WinNT://localhost" } else { printf("Unable to allocate additional memory."); }
Client: Included in Windows XP and
Windows 2000 Professional.
Server: Included in Windows Server 2003 and
Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension
on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Adshlp.h.
Library: Use ActiveDS.lib.