Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

TSR

Posted on 1998-07-14
3
507 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
ID: 1251685
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
ID: 1251686
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
ID: 1251687
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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.

808 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