Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - peek http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   peek

   Usage
   #include <dos.h>
   void peek(unsigned seg,unsigned offset,void *buf, int numbytes);

   Description
   Moves  numbytes from the memory specified by seg:offset to the  buffer
   pointed to by buf.

   Example
   /* this program will accept as command line arguments
   ON or OFF - to turn numlock on or off. */
   #include <stdio.h>
   #include <dos.h>
   #include <string.h>

   main(int argc,char *argv[])
   {
   char state1,state2;
   int i;
        for( i = 0; i < argc; i++)
             strupr(argv[i]);

        if( (strcmp(argv[1],"ON") == 0))
        {
             printf("Numlock is on\n");
             peek(0,0x417,&state1,1);
             state1 |= 0x20;
             poke(0,0x417,&state1,1);
        }
        else
        {
             if( (strcmp(argv[1],"OFF") == 0 ))
             {
                  printf("Numlock is off\n");
                  peek(0,0x417,&state1,1);
                  state1 &= ~0x20;
                  poke(0,0x417,&state1,1);
             }
             else
             {
                  printf("\nEnter ON or OFF as command line argument\n");
                  exit(1);
             }
        }
   }

See Also: poke

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson