R
RGarg06
Hi,
I am trying to read a buffer from a file and then pass that buffer to a
C++ dll as follows. While debugging it tells me that byte array
received is a Bad Ptr. Any help will be appreciated.
VB code:
Dim bytes(511) As Byte
Dim stream As Stream
Dim bytesReadFromStream As Integer
stream = New FileStream("C:\abc.bak", FileMode.Open,
FileAccess.Read)
bytesReadFromStream = stream.Read(bytes, 0, 512)
While bytesReadFromStream > 0
SendBytesToFn(bytesReadFromStream , bytes)
bytesReadFromStream = stream.Read(bytes, 0, 512)
End While
stream.Close()
<System.Runtime.InteropServices.DllImport("MyDll.dll",
CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
Private Sub SendBytesToFn(ByVal bytesTransferred As Int64, ByVal
bytes() As Byte)
End Sub
C++ Code:
extern "C" MYDLL_API void SendBytesToFn(DWORD bytesTransferred, BYTE*
bytes)
{
// bytes here come as Bad Ptr
}
I am trying to read a buffer from a file and then pass that buffer to a
C++ dll as follows. While debugging it tells me that byte array
received is a Bad Ptr. Any help will be appreciated.
VB code:
Dim bytes(511) As Byte
Dim stream As Stream
Dim bytesReadFromStream As Integer
stream = New FileStream("C:\abc.bak", FileMode.Open,
FileAccess.Read)
bytesReadFromStream = stream.Read(bytes, 0, 512)
While bytesReadFromStream > 0
SendBytesToFn(bytesReadFromStream , bytes)
bytesReadFromStream = stream.Read(bytes, 0, 512)
End While
stream.Close()
<System.Runtime.InteropServices.DllImport("MyDll.dll",
CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
Private Sub SendBytesToFn(ByVal bytesTransferred As Int64, ByVal
bytes() As Byte)
End Sub
C++ Code:
extern "C" MYDLL_API void SendBytesToFn(DWORD bytesTransferred, BYTE*
bytes)
{
// bytes here come as Bad Ptr
}