home *** CD-ROM | disk | FTP | other *** search
- /*
- Module name.
- sharefor.c - works with sharetsr.c
- This program will access the shared structure in sharetsr.c
- and print the system time as built by sharetsr.
-
- It will access the structure two ways, first by using findsig()
- and second by using tsrshare().
-
- It prompts for a 'F' to free the TSR to show that data can be
- passed back the other way. If a 'F' is hit on the keyboard
- the TSR will free itself on the next timer tick that it can.
-
- --) NOTICE: Copyright (C) 1988 South Mountain Software, Inc.
- */
-
- #include "stdio.h"
- #include "conio.h"
- #include "tsr.h"
- #include "resproto.h"
- #include "dos.h"
-
- struct share{ /* structure to share with foreground program */
- unsigned my_sig; /* signature placed here for find_sig() example */
- char time_str[30]; /* time of day string placed here */
- long a_key_hit; /* count of key presses and releases */
- long dos_calls; /* count of int 21H calls */
- long chars_printed; /* number of characters printed */
- } ;
-
- void main(void)
- {
- struct share far *share_ptr; /* struct pointer found by findsig() */
- struct share far *retptr; /* struct pointer returned by tsrshare() */
- unsigned sig = 0xdcba; /* signature to search for */
- int i,j;
- char far *temp_ptr;
- char local_str[30]; /* local string space */
-
- i = find_sig(0x60,0x67,sig,(void far *)&share_ptr);
- if(i)
- {
- printf("Found signature at %xHEX. Ptr = <%p>\n",i,share_ptr);
- temp_ptr = (char far *) share_ptr;
- temp_ptr += 2; /* point to struct time string */
- j=0;
- while(*temp_ptr++ != '\0') /* copy time string to local_str */
- {
- local_str[j++] = *temp_ptr;
- }
- local_str[j] = '\0';
- printf("String time in sharetsr = <%s> \n",local_str);
- }
- else
- {
- printf("Signature not found!");
- }
-
-
- i = tsrshare(0x5272,(void far *)&retptr);
- printf("return from tsrshare() = %d far pointer retptr = <%p>\n",i,retptr);
- printf("retptr->my_sig = %x\n", retptr->my_sig);
- printf("retptr->time_str = %Fs\n",retptr->time_str);
- printf("retptr->a_key_hit = %ld\n",retptr->a_key_hit);
- printf("retptr->dos_cd_calls = %ld\n",retptr->dos_calls);
- printf("retptr->chars_printed = %ld\n",retptr->chars_printed);
-
-
-
- printf("\n\n enter 'F' to free the tsr or anything else not to free it\n");
- j = getch();
- if(j == 'F' || j == 'f')
- {
- j = tsrfree(0x5272,1);
- if(j != 0)
- printf("error in tsrfree = %d\n",j);
- }
-
- }
-