Export (0) Print
Expand All

ReallocADsStr function

The ReallocADsStr function creates a copy of a Unicode string.

Syntax


BOOL ReallocADsStr(
  _Out_  LPWSTR *ppStr,
  _In_   LPWSTR pStr
);

Parameters

ppStr [out]

Type: LPWSTR*

Pointer to null-terminated Unicode string pointer that receives the allocated string. ReallocADsStr will attempt to free this memory with FreeADsStr before reallocating the string, so this parameter should be initialized to NULL if the memory should not be freed or was not allocated with the AllocADsMem, AllocADsStr, ReallocADsMem or ReallocADsStr function.

The caller must free this memory when it is no longer required by passing this pointer to FreeADsStr.

pStr [in]

Type: LPWSTR

Pointer to a null-terminated Unicode string that contains the string to copy.

Return value

Type: BOOL

The function returns TRUE if successful, otherwise FALSE is returned.

Examples

The following code example shows how to use the ReallocADsStr function.


LPWSTR pwszSrc1 = L"This is string 1.";

// Allocate a new string buffer and copy the specified string to it.
LPWSTR pwszDest = (LPWSTR)AllocADsStr(pwszSrc1);
if(pwszDest)
{
    wprintf(L"Copy of %s is %s\npw", szSrc1, pwszDest);

    LPWSTR pwszSrc2 = L"This is string 2.";

    /*
    This will free the original pwszDest buffer, so it is not necessary 
    to free it manually.
    */
    if(ReallocADsStr(&pwszDest, pwszSrc2) 
    {
        wprintf(L"Copy of %s is  %s\n", pwszSrc2, pwszDest);
    }

    FreeADsStr(pwszDest);
}

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Adshlp.h

Library

Activeds.lib

DLL

Activeds.dll

See also

FreeADsStr
AllocADsMem
AllocADsStr
ReallocADsMem
ADSI Functions

 

 

Show:
© 2014 Microsoft