ImmGetCompositionString function

Retrieves information about the composition string.


LONG ImmGetCompositionString(
  _In_      HIMC   hIMC,
  _In_      DWORD  dwIndex,
  _Out_opt_ LPVOID lpBuf,
  _In_      DWORD  dwBufLen


hIMC [in]

Handle to the input context.

dwIndex [in]

Index of the information to retrieve, which is one of the values specified in IME Composition String Values. For each value except GCS_CURSORPOS and GCS_DELTASTART, the function copies the requested information to the output buffer. The function returns the cursor and delta position values in the low 16 bits of the return value.

lpBuf [out, optional]

Pointer to a buffer in which the function retrieves the composition string information.

dwBufLen [in]

Size, in bytes, of the output buffer, even if the output is a Unicode string. The application sets this parameter to 0 if the function is to return the size of the required output buffer.

Return value

Returns the number of bytes copied to the output buffer. If dwBufLen is set to 0, the function returns the buffer size, in bytes, required to receive all requested information, excluding the terminating null character. The return value is always the size, in bytes, even if the requested data is a Unicode string.

This function returns one of the following negative error codes if it does not succeed:

  • IMM_ERROR_NODATA. Composition data is not ready in the input context.
  • IMM_ERROR_GENERAL. General error detected by IME.


An application calls this function in response to the WM_IME_COMPOSITION or WM_IME_STARTCOMPOSITION message. The IMM removes the information when the application calls the ImmReleaseContext function.

Note  You must write code to handle both full-width Hiragana and half-width Katakana if your application is used with the Soft Input Panel (SIP).


Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]


East Asian language support installed.


Imm.h (include Windows.h)





Unicode and ANSI names

ImmGetCompositionStringW (Unicode) and ImmGetCompositionStringA (ANSI)

See also

Input Method Manager
Input Method Manager Functions