RtlUnicodeStringToAnsiString - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTRTL_H

NTSYSAPI
NTSTATUS
NTAPI
RtlUnicodeStringToAnsiString(
    _Inout_ PANSI_STRING DestinationString,
    _In_ PCUNICODE_STRING SourceString,
    _In_ BOOLEAN AllocateDestinationString
    );

#endif

View code on GitHub
// wdm.h

NTSYSAPI NTSTATUS RtlUnicodeStringToAnsiString(
  [in, out] PANSI_STRING     DestinationString,
  [in]      PCUNICODE_STRING SourceString,
  [in]      BOOLEAN          AllocateDestinationString
);

View the official Windows Driver Kit DDI reference
// winternl.h

NTSTATUS RtlUnicodeStringToAnsiString(
  [in, out] PANSI_STRING     DestinationString,
  [in]      PCUNICODE_STRING SourceString,
  [in]      BOOLEAN          AllocateDestinationString
);

View the official Win32 API reference

NtDoc

This function is documented in Windows Driver Kit.

Windows Driver Kit DDI reference (nf-wdm-rtlunicodestringtoansistring)

RtlUnicodeStringToAnsiString function

Description

The RtlUnicodeStringToAnsiString routine converts a given Unicode string into an ANSI string.

Parameters

DestinationString [in, out]

Pointer to an ANSI_STRING structure to hold the converted ANSI string. If AllocateDestinationString is TRUE, the routine allocates a new buffer to hold the string data, and updates the Buffer member of DestinationString to point to the new buffer. Otherwise, the routine uses the currently specified buffer to hold the string.

SourceString [in]

Pointer to the Unicode source string to be converted to ANSI.

AllocateDestinationString [in]

TRUE if this routine is to allocate the buffer space for the DestinationString. If it does, the buffer must be deallocated by calling RtlFreeAnsiString.

Return value

If the conversion succeeds, RtlUnicodeStringToAnsiString returns STATUS_SUCCESS. Otherwise, no storage was allocated, and no conversion was done.

Remarks

The translation is done in accord with the current system-locale information.

See also

ANSI_STRING

RtlAnsiStringToUnicodeString

RtlFreeAnsiString

UNICODE_STRING


Win32 API reference (nf-winternl-rtlunicodestringtoansistring)

RtlUnicodeStringToAnsiString function

Description

Converts the specified Unicode source string into an ANSI string.

Parameters

DestinationString [in, out]

A pointer to an ANSI_STRING structure to hold the converted ANSI string. If AllocateDestinationString is TRUE, the routine allocates a new buffer to hold the string data and updates the Buffer member of DestinationString to point to the new buffer. Otherwise, the routine uses the currently specified buffer to hold the string.

SourceString [in]

The UNICODE_STRING structure that contains the source string to be converted to ANSI.

AllocateDestinationString [in]

Controls allocation of the buffer space for the DestinationString.

TRUE

Buffer space is allocated for DestinationString. If set to TRUE, the buffer must be deallocated using RtlFreeAnsiString.

FALSE

Buffer space is not allocated for DestinationString.

Return value

The various NTSTATUS values are defined in NTSTATUS.H, which is distributed with the DDK.

Return code Description
STATUS_SUCCESS The Unicode string was converted to ANSI. Otherwise, no storage was allocated and no conversion was done.

Remarks

The translation is done with respect to the current system locale information.

Because there is no import library for this function, you must use GetProcAddress.