I have a multithreaded application where i open a comport via
The read/write works ok, but when i close the port via CloseHandle(), the application crashes..
CreateFile(buf, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL).
I read in msn that you have to open it with the DELETE flag set, but read/write returns an error when i do that..I tried several combinations, but when i use the other combinations of flags, i can't read, or the app crashes when i close the port..
Does anyone have the right combination?
>> but when i close the port via CloseHandle(), the application crashes..
Probably a sign of memory corruption in general. May not be related to the handle at all.
>> I read in msdn that you have to open it with the DELETE flag set,
Not on a serial port - it's not a deletable "file".
>> Does anyone have the right combination?
For a serial port, I use GENERIC_READ | GENERIC_WRITE, OPEN_EXISTING, and either FILE_FLAG_OVERLAPPED or 0.
Thanks for the reply.
Guess it has to be a memeory issue then..The handle has the same value when i close the port as it had when it was opened..