Solved

Turn Off Caps Lock (Dos C Program)

Posted on 1997-12-18
7
681 Views
Last Modified: 2008-03-17
I have a c DOS program running on an old 386 and need to turn off the caps lock. How do I do this? (C or Assembly)
0
Comment
Question by:mikeu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 

Author Comment

by:mikeu
ID: 1256732
Adjusted points to 200
0
 
LVL 10

Accepted Solution

by:
rbr earned 300 total points
ID: 1256733
To change the status of your keyboard you have the change to bios-values at 0x0040:0x0017

set_flag (int flag)
{
    char far *pflag;

    pflag = (char far *) (((unsigned long)0x40)<<16+(unsigned long) 0x17);

    *pflag |=flag
    _asm {
        mov ah,1
        int 16h
     }
}
clear_flag (int flag)
{
    char far *pflag;

    pflag = (char far *) (((unsigned long)0x40)<<16+(unsigned long) 0x17);

    *pflag &= ˜flag;
    _asm {
        mov ah,1
        int 16h
     }
}

flag = 16 Scroll lock
flag = 32 Num Lock
flag = 64 Caps Lock
0
 

Author Comment

by:mikeu
ID: 1256734
when I try your example in code view the value of the pointer pflag seems to be 0000:2000  not 0040:0017 ?!? am I just being stupid and missing something? Thanks for any Info
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mikeu
ID: 1256735
This works pflag = (char far *)0x00000417L

0
 

Author Comment

by:mikeu
ID: 1256736
Very strange behavior. Which compiler to you use?
0
 
LVL 10

Expert Comment

by:rbr
ID: 1256737
Sorry, was a mistake of my book. Use instead of "<< 16" "* 16L" or "<< 4". This should work.
0
 
LVL 10

Expert Comment

by:rbr
ID: 1256738
I use Microsoft vc++ 1.52 for my dos stuff and 5.0 for windows.
I tried the *16L and it seems to work.
Thanks for your help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question