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
Solved

Turn Off Caps Lock (Dos C Program)

Posted on 1997-12-18
7
669 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
  • 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures 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.

839 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