You should paste the contents of your DCB structure so I can take a look at it. There are some combinations of values that do not work. If you are also setting the COMMTIMEOUTS structure please paste that here as well.
DCBLength = 28
BaudRate = 38400
fBinary = 1
fParity = 0
fOutxCtsFlow = 0
fOutxDsrFlow = 0
fDtrControl = 1
fDsrSensitivity = 0
fTXContinueOnXoff = 1
fOutX = 0
fInX = 0
fErrorChar = 0
fNull = 0
fRtsControl = 1
fDummy2 = 0 (this one is not used but added for the complete structure)
wReserved = 0 (this one is not used but added for the complete structure)
XonLim = 2048
XoffLim = 512
ByteSize = 7
Parity = 0
StopBits = 0
XonChar = 17
XoffChar = 19
ErrorChar = 0
EvtChar = 0
wReserved1 = 0 (this one is not used but added for the complete structure)
The current settings for the Barcode reader are:
BaudRate = 38400 (default value)
DataBits = 7
Parity = NONE
StopBits = 1
RTS/CTS HardwareFlowcontrol = Off
Xon/Xoff SoftWareFlowControl = Off
Ack/Nak SoftwareFlowControl = Off
As for the COMMTIMEOUTS structure: I don't know if I am using this structure. I defined a constant (#define READ_TIMEOUT 5000) and use that in "WaitForSingleObject"
I hope you can send my in the right direction on solving this problem. Please explain any recommended changes in these settings so I can learn from it and avoid this in the future.
I am almost positive that you should change FILE_FLAG_OVERLAPPED to NULL when you open the COM port. I highly doubt that you need to do overlapped I/O with a barcode reader. Don't worry about the COMMTIMEOUTS for now, I was asking this question with the assumption that you were possibly performing overlapped i/o and the timeout structure would effect this.
Here is a good MSDN containing the explanation for the DCB fields. It looks like you just need to match what the barcode scanner is expecting.
No problem with the delay, by opening and closing the connection with hyperterminal I can solve the problem for a while (until I shutdown or reboot my computer) so it not stopping me in the development of the app.
I've tested our proposed settings of the DCB structure, but unfortunatly it doesn't solve the problem.
I've found the suggested MSDN already, but thanks for the suggestion.
Is there a possibility to check the settings of the HyperTerminal programm in a DCB-structure, so I can see what settings this programm uses and copy them?
Or when I start Hyperterminal and close it again and then use the GetCommState command, do I get the settings Hyperterminal used?
Maybe HyperTerminal sends some activating code to any connected device?
I have a application that allow to run multiple instances. If at same time two instances are runnining and I want to close one with another exe throgh ProcessTreminate() command then how can I differentiate these two instances which is to be close.