-1

I have a modem on COM44 and when I try to access it via C++ I end up receiving ERROR_SHARING_VIOLATION. The code I am using is and m_hFile ends up as -1:

void* m_hFile;
m_hFile = ::CreateFile( "\\\\.\\COM44",
  GENERIC_READ | GENERIC_WRITE,
  NULL,
  NULL,
  OPEN_EXISTING,
  NULL,
  NULL );

I have tested access to the modem via Putty and was able to open its comport and send AT commands to it without any problem so I know it works.

Ryland
  • 117
  • 1
  • 2
  • 14
  • 1
    Silly question maybe, but the Putty connection is closed right? Sometimes windows just thinks a resource is in use, have you tried rebooting? – Mark Stevens Oct 24 '12 at 20:34
  • Yes the putty connection is closed. I tried putty after spending an hour trying to get this to work including rebooting the machine. – Ryland Oct 25 '12 at 13:04

1 Answers1

0

The problem ends up not being with the CreateFile code but with the registry code I have above it which determines the com port number to use which I hadn't added because I didn't think it was relevant.

Ryland
  • 117
  • 1
  • 2
  • 14