hi,

i want to write into parallel port and i have done this. it doesn't work but i don't know why.
Any idea?

HANDLE hPuerto;
DCB m_dcb;
BOOL m_PuertoPreparado;
BYTE dato;
DWORD iBytesEscritos;
bool error=false;

hPuerto=CreateFile("LPT1", // pointer to name of the file
GENERIC_READ|GENERIC_WRITE, // access (read-write) mode
0, // share mode
0, // pointer to security attributes
OPEN_EXISTING, // how to create
FILE_ATTRIBUTE_NORMAL, // file attributes
0); // handle to file with attributes to copy

//// the handle seems to be ok.

if (hPuerto==INVALID_HANDLE_VALUE)
{
error=true;
}


//// GetCommState gives an error : error 87 Invalid parameters

m_PuertoPreparado = GetCommState(hPuerto,&m_dcb);

///////////////////////////////////////////////////////////////////////




if(m_PuertoPreparado ==0) error=true;

// here i have modified the settings of the parallel port
m_dcb.BaudRate = 9600;
m_dcb.ByteSize = 8;
m_dcb.Parity = NOPARITY;
m_dcb.StopBits = ONESTOPBIT;

m_PuertoPreparado = SetCommState(hPuerto, &m_dcb);

if(m_PuertoPreparado ==0) error=true;


//// now we write into the port
dato=1;

//// WriteFile gives this error : error 6 The handle is invalid

if ( WriteFile(hPuerto,&dato,1,&iBytesEscritos,NULL)==0) error=true;

//////////////////////////////////////////

CloseHandle(hComm);


Thanks. (sorry for my english)