Here's a quick overview of how to use the EIO1: driver (set/get the direction mask, read/write port):
// Open the driver
HANDLE hEIO = CreateFile( TEXT("EIO1:"),
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
//
// Set direction mask so bits 0-3 are outputs, others are inputs
//
DWORD NumberOfBytes;
DWORD mask = 0x000F;
DeviceIoControl ( hEIO,
IOCTL_EIO_CONFIG_PORTS,
&mask,
sizeof(DWORD),
NULL,
0,
&NumberOfBytes,
NULL );
//
// Read the direction mask currently set
//
DeviceIoControl ( hEIO,
IOCTL_EIO_READ_CONFIG,
NULL,
0,
&mask,
sizeof(DWORD),
&NumberOfBytes,
NULL );
//
// Write to the port
//
DWORD state = 0x0000; // all off
WriteFile(hEIO, &state, sizeof(DWORD), &NumberOfBytes, NULL))
//
//
// Read from the port
//
ReadFile(hEIO, state, sizeof(DWORD), &NumberOfBytes, NULL))