HOME | CONTACT | chat | TIPS |

search engine by freefind

 

C#-SOURCE-CODE

THIS POST IS FOR THE C# PROGRAMMERS... IT DEFINES THE PEEK COMMAND WHICH CAN BE USED TO DETECT WHETHER YOUR CAPS-LOCK, NUM-LOCK, SCROLL-LOCK, ALT OR CTRL KEY IS ON OR OFF.... HERE IS ITS SOURCE CODE :::

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

int main(void)
{
int value = 0;

clrscr();
printf("The current status of your keyboard is:\n");
value = peek(0x0040, 0x0017);
if (value & 1)
printf("Right shift on\n");
else
printf("Right shift off\n");

if (value & 2)
printf("Left shift on\n");
else
printf("Left shift off\n");

if (value & 4)
printf("Control key on\n");
else
printf("Control key off\n");

if (value & 8)
printf("Alt key on\n");
else
printf("Alt key off\n");

if (value & 16)
printf("Scroll lock on\n");
else
printf("Scroll lock off\n");

if (value & 32)
printf("Num lock on\n");
else
printf("Num lock off\n");

if (value & 64)
printf("Caps lock on\n");
else
printf("Caps lock off\n");

getch();
return 0;
}
 

ABOUT THE PEEK COMMAND :

Syntax:
int peek(unsigned segment, unsigned offset);

Prototype in:
dos.h

Remarks:
peek returns the word at the memory location segment:offset.

If peek is called when dos.h has been
included, it is treated as a macro that expands to inline code.

If you don't include dos.h, or if you do
include it and #undef peek, you'll get the function rather than the macro.

Return Value:
peek returns the word of data stored at the memory location segment:offset.

 

HOW TO COMPILE THIS CODE::

  • 1> DOWNLOAD THE SOUCE CODE <PEEK.C> AND OPEN IT WITH TURBO C OR BORLAND C++....

  • COMPILE IT BY PRESSING CTRL+F9 AND ITS DONE...

  • IT WILL GIVE YOU A PEEK.EXE FILE......

  • YOU CAN DOWNLOAD THE .EXE FILE DIRECTLY FROM HERE.......

   

 



 

 

 
Free Web Hosting