Solved

TSR

Posted on 1998-07-14
3
503 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Way to improve it 16 61
Detect CR LF to each line 12 153
C++ finding a sting in a char* string from a text file 3 99
Using popen() and gunzip() to open file in HTTPServer 6 48
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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

920 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

13 Experts available now in Live!

Get 1:1 Help Now