Solved

Turn Off Caps Lock (Dos C Program)

Posted on 1997-12-18
7
663 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use pointers 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.

770 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