Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 858
  • Last Modified:

Turn Off Caps Lock (Dos C Program)

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
mikeu
Asked:
mikeu
  • 4
  • 3
1 Solution
 
mikeuAuthor Commented:
Adjusted points to 200
0
 
rbrCommented:
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
 
mikeuAuthor Commented:
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
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
mikeuAuthor Commented:
This works pflag = (char far *)0x00000417L

0
 
mikeuAuthor Commented:
Very strange behavior. Which compiler to you use?
0
 
rbrCommented:
Sorry, was a mistake of my book. Use instead of "<< 16" "* 16L" or "<< 4". This should work.
0
 
rbrCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now