Thread: Comport problem

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    329

    Comport problem

    Hi.
    I have a multithreaded application where i open a comport via
    Code:
    CreateFile(buf, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL).
    The read/write works ok, but when i close the port via CloseHandle(), the application crashes..
    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?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> 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.

    gg

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    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..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM