home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / OS_ID.TXT < prev    next >
Text File  |  1997-07-05  |  3KB  |  81 lines

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