The GetCommTimeouts function retrieves the time-out parameters for all read and write operations on a specified communications device.
BOOL GetCommTimeouts( HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts )
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
EX1
#include <Origin.h> #include <mscomm.h> BOOL Get_Comm_Timeouts() { file ff; //Open comm port if (!ff.Open("COM1:", file::modeReadWrite )) { ASSERT(FALSE); return FALSE; } UINT hCom = ff.GetHandle(); if ( hCom == file::hFileNull ) { ASSERT(FALSE); return FALSE; } COMMTIMEOUTS tTimeout; // get the timeout if( !GetCommTimeouts((HANDLE)hCom,&tTimeout) ) { ASSERT(FALSE); return FALSE; } //... if( !ff.Close() ) // Close() function will happen automatically by the file class destructor. { ASSERT(FALSE); return FALSE; } }
file::Open, file::GetHandle, SetCommTimeouts
mscomm.h