home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / SNPD9404.ZIP / TASKER.TXT < prev    next >
Text File  |  1994-04-03  |  3KB  |  79 lines

  1.                     Multi-Tasker Detection Routines
  2.                              by David Gibbs
  3.                           FidoNet: 1:115/439.0
  4.              Internet: David.Gibbs@f439.n115.z1.fidonet.org
  5.  
  6. The following is a set of C routines that will enable a programmer to
  7. detect a mutli-tasking environment and release the time slice when
  8. desired.  Currently DESQview, Windows, & OS/2 are the environments
  9. supported.
  10.  
  11. Routines consist of two functions, two global int variables, one global
  12. structure, and a table of character pointers.
  13.  
  14. void t_get_os(); This routines detects the operating environment, sets
  15. on the appropriate bits in the t_os_type field, and sets the t_os field
  16. to the dominant environment.
  17.  
  18. void t_slice(); This routine will release the remainder of the current
  19. tasks time slice in the manner appropriate to the dominant envionment.
  20.  
  21. The following fields & structures are available...
  22.  
  23. int t_os_type; is a bit mapped integer that indicates the presence of
  24. various operating envionments.  If Bit 0 is on, DOS is present, Bit 1 =
  25. OS2, bit 2 = DESQview, bit 3 = Windows standard, bit 4 = Windows 386
  26. Enh.  These bits can be tested by using logical operations with the
  27. symbolic constants is_DOS, is_OS2, is_DV, is_WINS, and is_WIN3.
  28.  
  29. int t_os; represents the dominant environment.  The dominant envionment
  30. is defined as the multi-tasking system that takes precidence.  For
  31. instance, you can run Windows *UNDER* DESQview, but DESQview would be
  32. dominant, the same goes true for OS/2 & Windows.  This value can be
  33. tested by comparing to the symbolic constants: DOS, OS2, DV, WINS, and
  34. WIN3.
  35.  
  36. struct t_os_ver ts_os_ver[]; indicates the versions of the various
  37. environments present.  Major & minor versions are found in the
  38. structure members 'maj' and 'min'.  The structure is subscripted, so you
  39. can access the version of envionments using the symbolic constants use
  40. in 't_os'.
  41.  
  42. const char *t_os_name[]; contains the names of the environments
  43. detectable.  These too are subscripted and can be accessed using the
  44. symbolic constants above.
  45.  
  46. A sample program that uses these routines follows:
  47.  
  48. #include <stdio.h>
  49. #include "tasker.h"
  50.  
  51. void main() {
  52.         get_os();
  53.  
  54.         printf("%s %d.%d detected",t_os_name[t_os],
  55.                                    t_os_ver[t_os].maj,
  56.                                    t_os_ver[t_os].min);
  57.  
  58.         while(!kbhit()) {
  59.                 printf("Hit a key!\r\n");
  60.                 t_slice();
  61.         }
  62. }
  63.  
  64.  
  65. Special thanks go to Geoffery Booher (1:2270/233) for assistance with
  66. Windows & OS/2 detection & Time slicing.
  67.  
  68. This routine is released to the public as CommentWare - If you use it,
  69. please send me a comment as to what you thought of it... oh yeah, you
  70. might think of giving me credit for the routines.
  71.  
  72. Also, if you can think of a enhancement or correction, please let me
  73. know.  I can be reached at the above mentioned email addresses.
  74.  
  75. Copyrights: DESQview by Quarterdeck Office Systems
  76.             Windows by Microsoft
  77.             OS/2 by IBM
  78.             TurboC++ by Borland
  79.