C # call Win32API code is as follows:
1, connect equipment
PCIeHandle=HardwareOperation. CreateFile (
DevicePathName,//device path
HardwareOperation. GENERIC_READ | HardwareOperation GENERIC_WRITE,//access
0,//Shared schema
0,//to attribute structure completely
HardwareOperation OPEN_EXISTING,//file does not exist when return failure
0,//(in an asynchronous mode open)
0);
2, writing method
Public bool Write (byte [] m_wr_data, int count, ref int writeCount)
{
Try
{
Uint written=0;
Bool res=HardwareOperation. WriteFile (PCIeHandle m_wr_data, (uint) m_wr_data. Length, ref written, IntPtr. Zero).
Console. WriteLine (" the number of actual writing is: "+ written);
WriteCount=(Int32) written;
if (! Res | | writeCount!=m_wr_data. Length)
{
Console. WriteLine (" [Write] GetLastError: "+ Marshal. GetLastWin32Error ());
}
Return res;
}
The catch (Exception ex)
{
Console. WriteLine (" [Write] ex "+ ex. Message);
return false;
}
}
Returns the correct connection equipment, call write method returns false, and GetLastWin32Error results back 87, don't know is which parameter error, seek counsel ahhh!!!!!!!!!!