Getting CreateFile handle in managed code

  • Thread starter Thread starter Steve N.
  • Start date Start date
S

Steve N.

I'm having trouble getting a handle returned from the following code
within a managed class:

HANDLE m_hSerialComm = CreateFile("\\\\.\\COM1\0\0\0",
GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING,
FILE_FLAG_NO_BUFFERING, 0);

It works fine in non-managed code but I get a '{void}' returned when run
within managed code. I'm wondering if that's actually the problem or if
there is something else I'm missing... If it is the problem, then what's
the best solution?

Thanks
Steve
 
Steve,
I'm having trouble getting a handle returned from the following code
within a managed class:

HANDLE m_hSerialComm = CreateFile("\\\\.\\COM1\0\0\0",
GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING,
FILE_FLAG_NO_BUFFERING, 0);

It works fine in non-managed code but I get a '{void}' returned when run
within managed code. I'm wondering if that's actually the problem or if
there is something else I'm missing... If it is the problem, then what's
the best solution?

There shouldn't be a problem. I believe what you're seeing is that when
working in the mixed mode debugger it has "issues" displaying the values of
certain things (like handle values, which are just void* in essence).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top