Hi VB Experts
Is it possible for a 'C' function to use a pointer to a char array to write to a VB array As Char?
I have tried this but the C function only fills the first element in the VB array.
C Code:
And in VBCode:EXPORT int __stdcall SocknetRecv (int nSocket, LPSTR *lpBuf, int nSize) { int nRecv, nLen; LPTSTR lpPtr; for (nLen = nSize, lpPtr = *lpBuf; nLen > 0;) { nRecv = recv(nSocket, lpPtr, nLen, 0); if (nRecv <= 0) { nResult = WSAGetLastError(); return nRecv; } lpPtr += nRecv; nLen -= nRecv; } nResult = 0; return nSize - nLen; }
If anyone can help me with this i will be most grateful, I do not know VB very wellCode:Public Declare Function SocknetRecv Lib "SocknetLib.dll" (ByVal nSocket As Integer, ByRef Buffer() As Char, ByVal Size As Integer) As Integer Dim RData(100) As Char 'Call it nBytes = SocknetRecv(Socket, RData, RData.Length)
Looking forward to your replies




Reply With Quote