
/*******************************************************/
/*                                                     */
/*                                                     */
/*                                                     */
/*                                                     */
/*******************************************************/
/***   version 20090914 ***/

#include <stdio.h>
#include <conio.h>
#include <windows.h>

    typedef short _stdcall (*inpfuncPtr)(short portaddr);
    typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);

     static HINSTANCE hLib;
     static inpfuncPtr inp32;
     static oupfuncPtr oup32;
	 static Printer;

int Open_InOut(char Print)
 {
 	Printer=Print;
     hLib = LoadLibrary("inpout32.dll"); 
        if (hLib == NULL) return -1;
        inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
        if (inp32 == NULL) {FreeLibrary(hLib); return -1; }
        oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");
        if (oup32 == NULL) {FreeLibrary(hLib); return -1; }
        return 0;
 }
 
int Close_InOut()
        {FreeLibrary(hLib); return 0;   }

/*defaut Priner=0  */
void ParaOutData (int Val) {if (Printer)(oup32)(0x278,Val); else (oup32)(0x378,Val); }
int  ParaInData () { if (Printer) return ((inp32)(0x278)); else return ((inp32)(0x378));  }

void ParaOutCtrl (int Val) {if (Printer)(oup32)(0x27a,Val); else(oup32)(0x37a,Val); }
int  ParaInStatus () {if (Printer) return ((inp32)(0x279)); else return ((inp32)(0x379)); }

 
