| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | detecting OS/2 and share support etc |
> How can I detect whether my program is running under a multitasker or if
> SHARE support is present etc?
Ralf Brown's interrupt list - INT 2Fh. There are calls there to detect the
presence of SHARE. Either that or attempt to lock a file - if file SHARE
support isn't present, you'll get a "bad system call" return
code.
Multitaskers are another ballgame, but it's all been done before. The
following is from Bob Stout's C_ECHO SNIPPETs at tasker.c & tasker.h -
it's reasonably complete. The whole SNIPPETs file may prove useful - AFAIK,
the latest issue is still 0494, usually available as SNIP0494.xxx.
--- tasker.txt ---
Multi-Tasker Detection Routines
by David Gibbs
FidoNet: 1:115/439.0
Internet: David.Gibbs{at}f439.n115.z1.fidonet.org
The following is a set of C routines that will enable a programmer to
detect a mutli-tasking environment and release the time slice when
desired. Currently DESQview, Windows, & OS/2 are the environments
supported.
Routines consist of two functions, two global int variables, one global
structure, and a table of character pointers.
void t_get_os(); This routines detects the operating environment, sets
on the appropriate bits in the t_os_type field, and sets the t_os field
to the dominant environment.
void t_slice(); This routine will release the remainder of the current
tasks time slice in the manner appropriate to the dominant envionment.
The following fields & structures are available...
int t_os_type; is a bit mapped integer that indicates the presence of
various operating envionments. If Bit 0 is on, DOS is present, Bit 1 =
OS2, bit 2 = DESQview, bit 3 = Windows standard, bit 4 = Windows 386
Enh. These bits can be tested by using logical operations with the
symbolic constants is_DOS, is_OS2, is_DV, is_WINS, and is_WIN3.
int t_os; represents the dominant environment. The dominant envionment
is defined as the multi-tasking system that takes precidence. For
instance, you can run Windows *UNDER* DESQview, but DESQview would be
dominant, the same goes true for OS/2 & Windows. This value can be
tested by comparing to the symbolic constants: DOS, OS2, DV, WINS, and
WIN3.
struct t_os_ver ts_os_ver[]; indicates the versions of the various
environments present. Major & minor versions are found in the
structure members 'maj' and 'min'. The structure is subscripted, so you
can access the version of envionments using the symbolic constants use
in 't_os'.
const char *t_os_name[]; contains the names of the environments
detectable. These too are subscripted and can be accessed using the
symbolic constants above.
A sample program that uses these routines follows:
#include
#include "tasker.h"
void main() {
get_os();
printf("%s %d.%d detected",t_os_name[t_os],
t_os_ver[t_os].maj,
t_os_ver[t_os].min);
while(!kbhit()) {
printf("Hit a key!\r\n");
t_slice();
}
}
Special thanks go to Geoffery Booher (1:2270/233) for assistance with
Windows & OS/2 detection & Time slicing.
This routine is released to the public as CommentWare - If you use it,
please send me a comment as to what you thought of it... oh yeah, you
might think of giving me credit for the routines.
Also, if you can think of a enhancement or correction, please let me
know. I can be reached at the above mentioned email addresses.
Copyrights: DESQview by Quarterdeck Office Systems
Windows by Microsoft
OS/2 by IBM
TurboC++ by Borland
--- tasker.h ---
/*
** Tasker.H
**
** public domain by David Gibbs
*/
#ifndef DG_TASKER
#define DG_TASKER
struct ts_os_ver {
int maj;
int min;
};
#define TOT_OS 5
#define DOS 0
#define OS2 1
#define DV 2
#define WINS 3
#define WIN3 4
/* 76543210 */
#define is_DOS 0x01 /* b'00000001' */
#define is_OS2 0x02 /* b'00000010' */
#define is_DV 0x04 /* b'00000100' */
#define is_WINS 0x08 /* b'00001000' */
#define is_WIN3 0x10 /* b'00010000' */
extern int t_os_type;
extern int t_os;
extern const char *t_os_name[TOT_OS];
extern struct ts_os_ver t_os_ver[TOT_OS];
/* Function prototypes */
int get_os();
void t_slice();
#endif /* DG_TASKER */
--- tasker.c ---
/*
** Tasker.C
**
** public domain by David Gibbs
*/
struct ts_os_ver t_os_ver[TOT_OS];
int t_os_type;
int t_os;
const char *t_os_name[TOT_OS] = {
"DOS",
"OS/2 DOS",
"DESQview",
"Windows Std",
"Windows 386"
};
int get_os (void)
{
union REGS t_regs;
t_os_type = 0;
t_os = 0;
/* test for DOS or OS/2 */
if (_osmajor < 10)
{
t_os_ver[DOS].maj = _osmajor;
t_os_ver[DOS].min = _osminor;
t_os_type = t_os_type | is_DOS;
}
else
{
t_os_type = t_os_type | is_OS2;
t_os_ver[OS2].maj = _osmajor/10;
t_os_ver[OS2].min = _osminor;
}
/* test for Windows */
t_regs.x.ax = 0x4680;
int86(0x2F, &t_regs, &t_regs);
if (t_regs.x.ax == 0x0000)
{
t_os_ver[WINS].maj = 3;
t_os_ver[WINS].min = 0;
t_os_type = t_os_type | is_WINS;
}
else
{
t_regs.x.ax = 0x1600 ;
int86(0x2F, &t_regs, &t_regs);
switch (t_regs.h.al)
{
case 0x00 :
case 0x80 :
case 0x01 :
case 0xFF :
break;
default :
t_os_type = t_os_type | is_WIN3;
t_os_ver[WIN3].maj = t_regs.h.al;
t_os_ver[WIN3].min = t_regs.h.ah;
break ;
} /* endswitch */
} /* endif */
/* Test for DESQview */
t_regs.x.cx = 0x4445; /* load incorrect date */
t_regs.x.dx = 0x5351;
t_regs.x.ax = 0x2B01; /* DV set up call */
intdos(&t_regs, &t_regs);
if (t_regs.h.al != 0xFF)
{
t_os_type = t_os_type | is_DV;
t_os_ver[DV].maj = t_regs.h.bh;
t_os_ver[DV].min = t_regs.h.bl;
}
if(t_os_type & is_DOS)
t_os = DOS;
if(t_os_type & is_WINS)
t_os = WINS;
if(t_os_type & is_WIN3)
t_os = WIN3;
if(t_os_type & is_DV)
t_os = DV;
if(t_os_type & is_OS2)
t_os = OS2;
return(t_os-1);
}
void t_slice(void)
{
union REGS t_regs;
switch (t_os)
{
case DOS :
break;
case OS2 :
case WIN3 :
case WINS :
t_regs.x.ax = 0x1680;
int86(0x2f,&t_regs,&t_regs);
break;
case DV :
t_regs.x.ax = 0x1000;
int86(0x15,&t_regs,&t_regs);
break;
} /* switch(t_os) */
}
--- Squish/386 v1.11
* Origin: Decadence BBS: It's a way of life ! (3:632/103)SEEN-BY: 50/99 54/54 620/243 623/630 624/50 632/103 301 348 386 998 633/371 SEEN-BY: 633/379 634/384 635/301 502 503 541 544 636/100 639/100 711/401 409 SEEN-BY: 711/410 430 510 807 808 809 932 934 942 712/623 713/888 714/906 SEEN-BY: 800/1 @PATH: 632/103 348 635/503 50/99 54/54 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.