あなたは正確な詳細を提供しなかったので、これはあなたの情報に基づく推測です。ここに例があります。関連する部分を引用(および簡略化)します。
// C/C++
int ncWrite(unsigned long DataSize, void* DataPtr)
// C#
[DllImport("Nican.dll")]
unsafe static extern int ncWrite(uint DataSize, byte[] DataPtr);
byte[] DataWrite = {0x23, 0x23, 0x30, 0x03, 0x78, 0xEC, 0xFF, 0xFF };
int status = ncWrite(Marshal.SizeOf(DataWrite), DataWrite);
編集:あなたの情報で:
// .ocx
Public Function WriteData(ByVal devIndex As Long, ByVal lpOutData As Long, ByVal cntData As Long) As Long
// C#
[DllImport("TheOcxControl.dll")]
static extern int WriteData(int index, byte[] outputData, int outputDataLength);
byte[] DataToWrite = {0x23, 0x23, 0x30, 0x03, 0x78, 0xEC, 0xFF, 0xFF };
int status = WriteData(index, DataToWrite, Marshal.SizeOf(DataToWrite));
到着イベントについて:
// the e variable have devIndex, lenDataBufer, lpDataBufer properties.
// lenDataBufer is size of buffer, lpDataBufer is pointer to data array.
byte[] destination;
Marshal.Copy(lpDataBufer, destination, 0, lenDataBufer);