LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows/CVI ReadFile to read usb pipe?

Hello,
I'm new to cvi and I have a small problem. I'm developing a system and need to use Usb, but I can't use ReadFile/WriteFile to read from a Pipe because that function is redefined in cvi sdk. The execution error says that handle type is incorrect. I've no problem opening pipe but I can't read from it. How can I use ReadFile function from windows sdk? When I include cvi sdk the old function is redefined, isn't it? Cvi suports read from Pipe? I don't want to use ControlIoDevice.

Also I had so many problems trying to copy the device path from SP_INTERFACE_DEVICE_DETAIL_DATA (Null terminated string). Why I couldn't use strcpy? I only paste the DDK example in the code, that is in C. The problem didn't exist in C++, nor in the D
DK sample for DOS console. At last I used CopyStream() (Why?)

Thanks.
0 Kudos
Message 1 of 2
(3,134 Views)
Hello

CVI names some of its function in the same way as the Windows SDK, they are the following:

OpenFile, ReadFile, WriteFile, GetSystemTime, SetSystemTime, Beep, CopyFile, DeleteFile, GetFileTime, SetFileTime, GetFileSize

In order to use them, you must include either the widows header or the CVI header for the function. Placing the window,h after the cvi header will give you re-definition errors.
If you include the CVI header after the windows header, the function will automatically default to the CVI ReadFile function. If you need to have both the windows and the CVI headers included, you should undef the particular function like the following if to use the SDK's definition of the function:

#include
#include
#undef ReadFile


This will make the compiler use the SDK function, without the undef, the compiler would use the CVI ReadFile function.

So whenever you use the windows sdk functions, make sure that the include windows.h statement is always the very first one.

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(3,134 Views)