You are on page 1of 1

// Copiar y pegar este codigo en el archivo principal de tu proyecto

typedef short _stdcall (*inpfuncPtr)(short portaddr);


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

HINSTANCE hLib;
inpfuncPtr inp32;
oupfuncPtr oup32;

int initLibrary()
{
/* Load the library */
hLib = LoadLibrary("inpout32.dll");

if (hLib == NULL) {
//printf("LoadLibrary Failed.\n");
return -1;
}

/* get the address of the function */

inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");

if (inp32 == NULL) {
//printf("GetProcAddress for Inp32 Failed.\n");
return -1;
}

oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");

if (oup32 == NULL) {
//printf("GetProcAddress for Oup32 Failed.\n");
return -1;
}
return 0;
}

void outportb(short portAddress, short data)


{
(oup32)(portAddress, data);
}

short inportb(short portAddress)


{
return (inp32)(portAddress);
}

void closeLibrary()
{
FreeLibrary(hLib);
}

You might also like