10-23-2008 09:56 AM
Hello,
I am attempting to use a USB device that maps to a virtual com port in my LabView CVI (8,5) application. I get the following error:
Windows Readfile: http://msdn.microsoft.com/en-us/library/aa365467(VS.85).aspx
Solved! Go to Solution.
10-23-2008 10:12 AM - edited 10-23-2008 10:21 AM
sure, your call to ReadFile is wrong.
parameter 4 is of type LPDWORD, that means a pointer to a DWORD: ReadFile() will store the number of bytes read there. (in other words: this is an "out" parameter).
you passed only the DWORD... the line should be:
if (ReadFile(fhandle, tr, 15, &numBytesRead, NULL)==0)
as a side note, here is some of the Windows SDK conventions for type prefixes:
- "LP" is a "long pointer", where "long" means "far" and is historical.
- "C" is constant.
- "W" is wide, for string it means unicode,
- "T" for string types means either ANSI or UNICODE depending on the compilation flags
now you should be able to determine what "LPCTSTR" is...
10-23-2008 10:50 AM
Thank you for your explanation. I believe your correct - documentation says a pointer is necessary.
The only problem when I try to make it a pointer is that, I get a compiler error:
520, 63 Type error in argument 4 to `ReadFile'; found 'pointer to LPDWORD' expected 'LPDWORD'.
The compiler is not looking for a pointer. I have also tried the following:
LPDWORD *numBytesRead = 0;
if (ReadFile(fhandle, tr, 15, numBytesRead, NULL)==0) .....
and I still get the same error. How do which Windows.h file it is getting its definition from?
10-23-2008 11:13 AM - edited 10-23-2008 11:13 AM
10-23-2008 11:22 AM
Thank you to both dummy_decoy & Mert A. You both clearly explained the problem - I just have to read what you say and not rush.
I now have my project compiling & running. I'm able to talk with my USB device over the vitual com port. I'm getting some other errors but I should be able to figure those out.
Thanks again for your quick & helpful response!