GetKeyNameText

3.0

  int GetKeyNameText(lParam, lpszBuffer, cbMaxKey)    
  LONG lParam; /* 32-bit parameter of keyboard message */
  LPSTR lpszBuffer; /* address of a buffer for key name */
  int cbMaxKey; /* specifies maximum key string length */

The GetKeyNameText function retrieves a string that represents the name of a key.

Parameters

lParam

Specifies the 32-bit parameter of the keyboard message (such as WM_KEYDOWN) to be processed. The GetKeyNameText function interprets the following portions of lParam:

Bits Meaning

16–23 Character scan code.
24 Extended bit. Distinguishes some keys on an enhanced keyboard.
25 “Don't care” bit. The application calling this function sets this bit to indicate that the function should not distinguish between left and right CTRL and SHIFT keys, for example.

lpszBuffer

Points to a buffer that will receive the key name.

cbMaxKey

Specifies the maximum length, in bytes, of the key name, not including the terminating null character (this parameter should one less than the size of the buffer pointed to by the lpszBuffer parameter).

Return Value

The return value is the length, in bytes, of the string copied to the specified buffer, if the function is successful. Otherwise, it is zero.

Comments

The format of the key-name string depends on the current keyboard driver. This driver maintains a list of names in the form of character strings for keys with names longer than a single character. The key name is translated, according to the layout of the currently installed keyboard, into the principal language supported by the keyboard driver.