Saturday, 9 August 2014

Hardware program to inverse the status of caps, num and scroll lock

This is a hardware program to inverse the status of the caps, num and scroll lock. If you have any doubts please let me know.

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>

int main()
{
int c,n,s;
int far *p=(int far *)0x417;
int far *q=(int far *)0x418;
char text[50];
union REGS in, out;
clrscr();

c=*p&0x40;
s=*p&0x10;
n=*p&0x20;

if (c==0x40)
                        printf("\nCaps lock is ON");
else
                        printf("\nCaps lock is OFF");

if(n==0x20)
                        printf("\nNum lock is OFF");
else
                        printf("\nNum lock is ON");

if(s==0x10)
                        printf("\nScroll lock is ON");
else
                        printf("\nScroll lock is OFF");
printf("\nText before toggle: ");
gets(text);

*p=*p^0x70;
*q=*q^0x70;

printf("\nTOGGLE\n");

c=*p&0x40;
s=*p&0x10;
n=*p&0x20;

if (c==0x40)
                        printf("\nCaps lock is ON");
else
                        printf("\nCaps lock is OFF");

if(n==0x20)
                        printf("\nNum lock is OFF");
else
                        printf("\nNum lock is ON");

if(s==0x10)
                        printf("\nScroll lock is ON");
else
                        printf("\nScroll lock is OFF");

printf("\nText after toggle: ");
gets(text);
printf("\n Press any key to exit");
getch();

return 0;

}

No comments:

Post a Comment