Lookup CreatFile(), ReadFile() and WriteFile(), for example:
Code:
char Data[1]; // ? a byte or what ever size you need etc...
int BytesWritten, BytesRead;
HANDLE hComPortHandle;
// To read from the COM1 port:
hComPortHandle = CreateFile("COM1", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
while(1)
{
ReadFile(hComPortHandle, &Data, sizeof(data), (unsigned long*)&BytesRead, NULL);
//Do something with Data
}
// To write to the COM1 port:
ComPortHandle = CreateFile("COM1", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
while(1)
{
// setup Data then write to port...
WriteFile(hComPortHandle, Data, sizeof(Data), (unsigned long*)&BytesWritten, NULL);
}