home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.win32
- Path: sparky!uunet!franz.com!franz!jkf
- From: jkf@Franz.COM (Sean Foderaro)
- Subject: bug in SetKeyboardState?
- Message-ID: <JKF.92Sep6090948@frisky.Franz.COM>
- Sender: news@franz.com
- Nntp-Posting-Host: frisky
- Organization: Franz Inc., Berkeley, CA
- Date: Sun, 6 Sep 1992 17:09:48 GMT
- Lines: 49
-
-
- I've written a little program to switch the Caps Lock and Control keys for
- Windows 3.1 (which I'll be posting shortly). I tried to port it to NT without
- success. I've traced the bug down to the SetKeyboardState function which
- seems to have no effect in NT. Perhaps this is due to a misunderstanding on
- my part (or perhaps this just isn't implemented yet on NT).
- Here is a little test case. Try compiling and running
- this under Windows 3.1 and you'll see your Caps Lock light flashing
- when you run it. Try it under NT and the Caps Lock light doesn't even
- change once.
-
-
- /* test case to see if SetKeyboardState is working */
- #include <windows.h>
-
-
- int FAR PASCAL WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance,
- LPSTR cmdline, int cmdshow)
- {
- unsigned char keybuf[256];
- int i;
-
- GetKeyboardState(keybuf);
- for (i = 0; i < 100; i++) {
- keybuf[VK_CAPITAL] = 0;
- SetKeyboardState(keybuf);
- Sleep(500);
- keybuf[VK_CAPITAL] = 0x81;
- SetKeyboardState(keybuf);
- Sleep(500);
- }
- }
-
- #ifndef WIN32
- void delay2() {}
-
- Sleep(int msecs)
- {
- /* just try to delay a bit */
- int i;
- for (i = 0; i< 10000; i++) delay2();
- }
-
- #endif
-
-
-
-
-
-