UtilAssembleStringsWithAlloc function

The UtilAssembleStringsWithAlloc function allocates a string and formats it using strings provided by the string table. This function uses StringCchPrintf to create the formatted string.

Syntax

HRESULT UtilAssembleStringsWithAlloc(
  _Out_ LPWSTR  *Buffer,
  _In_  UINT    BufferMax,
  _In_  LPCWSTR InputFormat,
  _In_  LPCWSTR InputString,
  _In_  BOOLEAN AdditionalArgument,
  _In_  ULONG   AdditionalValue
);

Parameters

Buffer [out]

Type: LPWSTR*

The location where the newly allocated string will be placed. When the string is no longer needed, it must be released with CoTaskMemFree.

BufferMax [in]

Type: UINT

The maximum number of characters allowed in the string allocated by Buffer. If the resulting formatted string is longer than the number of characters specified, it is truncated and null-terminated.

Note

This parameter may not be set to zero.

InputFormat [in]

Type: LPCWSTR

String resource out of the string table representing a format parameter passed to StringCchPrintf. It is constructed using MAKEINTRESOURCE.

The resource string format must specify either a format parameter taking a wide string, or a format parameter taking an unsigned long and a wide string.

InputString [in]

Type: LPCWSTR

String resource out of the string table representing an argument passed to StringCchPrintf in place of the wide string in the format parameter. It is constructed using MAKEINTRESOURCE.

AdditionalArgument [in]

Type: BOOLEAN

True if AdditionalValue should be passed in as the first formatting argument to StringCchPrintf; otherwise, false (and only the resource string identified by InputString will be passed).

AdditionalValue [in]

Type: ULONG

The value to pass as the first formatting argument to StringCchPrintf if AdditionalArgument is true.

Return value

Type: HRESULT

Possible return values include, but are not limited to, the following.

Return code Description
S_OK
The operation succeeded.
E_INVALIDARG
One or more parameters has not been provided correctly.

Requirements

Requirement Value
Minimum supported client
Windows 8 [desktop apps only]
Minimum supported server
Windows Server 2012 [desktop apps only]
Header
Ndattributils.h

See also

UtilStringCopyWithAlloc

UtilLoadStringWithAlloc

StringCchPrintf

MAKEINTRESOURCE

CoTaskMemFree