Consultor Eletrônico



Kbase 17192: How to Call WIN32 API Function: GetKeyState
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
How to Call WIN32 API Function: GetKeyState

DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.

INTRODUCTION:
=============
The following sample code shows how to call the Win32 API function
called GetKeyState. This function retrieves the status of the
specified virtual key. The status specifies whether the key is up,
down, or toggled. You normally use GetKeyState() to check the status
of the toggled keys: "CAPS LOCK", "SCROLL LOCK", AND "NUM LOCK".

This code has been tested on Windows NT 4.0 Workstation only.


&GLOBAL-DEFINE VK_SCROLL 145
&GLOBAL-DEFINE VK_NUMLOCK 144
&GLOBAL-DEFINE VK_CAPITAL 20

DEFINE VARIABLE intResult AS INTEGER NO-UNDO.

PROCEDURE GetKeyState EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER intVirtKey AS LONG.
DEFINE RETURN PARAMETER intResult AS SHORT.
END PROCEDURE.

RUN GetKeyState (INPUT {&VK_NUMLOCK}, OUTPUT intResult).

IF intResult = 1 THEN
MESSAGE "Key is Toggled 'ON'" VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Key is Toggled 'OFF'" VIEW-AS ALERT-BOX.

Progress Software Technical Support Note # 17192