Solved

TSR

Posted on 1998-07-14
3
502 Views
Last Modified: 2008-02-26
I want to write a TSR utility program that would be invoked by a Hot Key. How do I replace the Interrupt 9 system function with my own function and how do I track wether the required key combination has been pressed.?

Is it only interrupt 9 that i have to deal with ?
can you give me a sample code.?
0
Comment
Question by:ravipal
3 Comments
 
LVL 3

Expert Comment

by:Norbert
Comment Utility
for a hot key I would suggest not to use Interrupt 9 because there you still have to communicate with the keyboard to get the Keycode (diffrent code for press and release the key) and so on.
so most time it is much easier to use int 16 to implement hot keys for a TSR program
0
 
LVL 4

Expert Comment

by:agreen
Comment Utility
If you'll increase your points to 100 i'll send you a sample.
0
 
LVL 1

Accepted Solution

by:
vladimir_12345 earned 0 total points
Comment Utility
This is a simple skeleton that works (I used Borland 4.5
Compiler, C). But TSR area is very difficult and from this
source to "true" TSR is a very long road.
==========================================================

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

typedef void interrupt (*INTERRUPT)(void);

void interrupt Int9(void);
void RemoveTSR(void);
void PrintScreen(void);

INTERRUPT OldInt9;

extern unsigned _heaplen = 1024;
extern unsigned _stklen  = 1024;

int main()
{
      unsigned TSR_Size = _SS + (_SP+15)/16 - _psp;

      OldInt9 = getvect(9);
      setvect(9, Int9);

      keep(0, TSR_Size);
      return 0;
}

void interrupt Int9(void)
{
      static char* pKbdStatus = (char*)0x00400017L;

      OldInt9();

      // if Ctrl is pressed - remove TSR from memory
      if(*pKbdStatus & 4)
      RemoveTSR();

      // if Shift+Alt are pressed print ...
      if((*pKbdStatus & 3) && (*pKbdStatus & 8))
            PrintScreen();
}

void RemoveTSR(void)
{
      setvect(9, OldInt9);

      freemem(_psp);
      freemem(*(unsigned _far*)MK_FP(_psp, 0x2C));
}

void PrintScreen(void)
{
      printf("Hello World !!!\n");
}

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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…
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.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now