GetKeyNameText

int GetKeyNameText(
  DWORD lParam, 
  LPSTR lpstr, 
  WORD wSize
 );

Retrieves a string that represents the name of a key.

lParam
Second parameter of the keyboard message (such as WM_KEYDOWN) to be processed. The function interprets the following portions of lParam:
Bits Meaning
16-23 Scan code.
24 Extended-key flag. Distinguishes some keys on an enhanced keyboard.
25 "Don't care" bit. Indicates the function should not distinguish between left and right CTRL and SHIFT keys, for example.

lpstr
Address of a buffer that receives the key name.
wSize
Maximum length, in characters, of the key name, not including the terminating null character (this parameter should be one less than the size of the buffer pointed to by the lpstr parameter).

The export ordinal for this function is 133.