cfoughty@digi.lonestar.org (Cy Foughty) (01/18/91)
The function "DosMonReg()" returns an "8" (ERROR_NOT_ENOUGHT_MEMORY)
in the following following program. I'm running OS/2 1.2 WR4098 and
compiling under Microsoft "C" 6.0 running PWB. It compiles and links
fine. The machine I'm using is an IBM PS/2 Model 80 with 8 megabytes
of ram and 330 megabyte winchester. No other processes, other than the
standard OS/2 processes, were running. What am I doing wrong?
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define INCL_BASE
#include <os2.h>
MONIN moninOutput ;
MONIN moninInput ;
#define MAXBUFF 0x7fff
VOID main(int argc,char **argv)
{
USHORT usFlag ;
USHORT usRtnCode ;
HMONITOR hmonDevice ;
BYTE bCom = 0 ;
PUCHAR pucInBuff ;
USHORT usMax = MAXBUFF ;
USHORT usIndex ;
usRtnCode = DosMonOpen(argv[1],&hmonDevice) ;
if(usRtnCode){
printf("Error:could not open %s\n",argv[1]) ;
exit(-1) ;
}
usRtnCode = DosDevIOCtl(0L,&bCom,0x0060,0x000b,hmonDevice) ;
if(usRtnCode){
printf("Error:%s dos not support monitors\n",argv[1]) ;
usRtnCode = DosMonClose(hmonDevice) ;
exit(-1) ;
}
pucInBuff = (PUCHAR)calloc(1,MAXBUFF) ;
usIndex = 0 ;
usRtnCode = DosMonReg( hmonDevice,
(PBYTE)&moninInput,
(PBYTE)&moninOutput,
MONITOR_BEGIN,
usIndex) ;
if( usRtnCode ){
printf("Error:DosMonReg returned %d\n",usRtnCode) ;
usRtnCode = DosMonClose(hmonDevice) ;
exit(-1) ;
}
usFlag = TRUE ;
while(usFlag){
usRtnCode = DosMonRead((PBYTE)&moninInput,DCWW_WAIT,(PBYTE)pucInBuff,&usMax) ;
if(usRtnCode){
usRtnCode = DosMonClose(hmonDevice) ;
usFlag = FALSE ;
}
printf(":%s:\n",pucInBuff) ;
}
usRtnCode = DosMonClose(hmonDevice) ;
if(usRtnCode){
printf("Error:could not close %s\n",argv[1]) ;
exit(-1) ;
}
exit(0) ;
}
--
Cy Foughty
DSC Communications, Inc. 1000 Coit Rd., Plano,TX 75075
Work:214.519.4237 La Casa:214.578.8837
Don't compromise your compromises.ballard@cheddar.ucs.ubc.ca (Alan Ballard) (01/23/91)
In article <1544@digi.lonestar.org> cfoughty@digi.lonestar.org (Cy Foughty) writes: > >The function "DosMonReg()" returns an "8" (ERROR_NOT_ENOUGHT_MEMORY) >in the following following program. I haven't seen a reply to this, so I'll try a couple of suggestions. Looks like the error code is unreasonable, but there is a bug or two... >MONIN moninOutput ; This should really be MONOUT monoutput though it doesn't really matter. > usIndex = 0 ; > usRtnCode = DosMonReg( hmonDevice, > (PBYTE)&moninInput, > (PBYTE)&moninOutput, > MONITOR_BEGIN, > usIndex) ; moninInput and moninOutput need to be initialized as in moninInput.cb = sizeof(MONIN); moninOutput.cb = sizeof(MONOUT); before registering. I suspect this is what is causing the problem. Also, what device were you trying to monitor? usIndex = 0 may be invalid. For the keyboard, it needs to be the screen group. Alan Ballard | Internet: ballard@ucs.ubc.ca University Computing Services | Bitnet: USERAB1@UBCMTSG University of British Columbia | Phone: 604-228-3074 Vancouver B.C. Canada V6R 1W5 | Fax: 604-228-5116