Re: Need a method to send byte arrays from Unmanaged C DLL to VB



Assuming you are in .NET and calling a C dll, you actually have a
number of options.

If you want bytes, then declare it as a ByVal byte array. Just be sure
you allocate the space (using redim for example) in the .NET side
before calling the C routine.

For text data, you can use a StringBuffer instead of a byte array.

HTH,
Tom

PS - The interop group is probably a better fit for this kind of
question in the future

Vince Castellano wrote:
Hello,

What is the proper way to send byte arrays (or strings for that
matter), from a C DLL to VB? I have tried by prototyping the call in VB
with ByRef Byte[] as a parameter, then treating it in C as a pointer to
unsigned char, and then I tried a memcpy, as well as using pointer
arithmetic to copy over byte per byte.

However, everything I try causes a runtime error regarding the stack
being unbalanced. I am sure I am doing this all wrong, however there
has to be a way to get a piece of memory from C into VB, and I just
can't find it, nor any information on it.

If this is not the proper group, please point me in the right
direction.

Thanks for any help,
Vince

.



Relevant Pages

  • Re: Call C DLL from VB.net-problem..array gains 4 bytes!
    ... Remember the DLL declaration... ... I still have not found where it says a byte array ... > array layout before calling to C, and a size-independent declaration for the ...
    (microsoft.public.windowsce.app.development)
  • Re: C# - Problem to receive data from a C++ Dll
    ... I'm asking me something else also: the dll I'm using is a dll which was ... created by embedded Visual C++ 3.0 and I want to use it on a Pocket PC 2003 ... > array to a single char array? ... > (pointer to a pointer to a pointer to a character....) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Array setup Question
    ... struct cm8linkstruc **cm8link; ... If I want to allocate 50 occurrences of this array then if the ... As soon as you say `dll', it's either irrelevant -- or off topic in this newsgroup. ... Since mallocreturns a pointer to void and such pointer is convertible to any pointer to object the cast is unnecessary -- and should be avoided (it can hide, for example, the failure to include. ...
    (comp.lang.c)
  • Re: Array Pointers in C#, calling C++ DLL
    ... > array in my calling function after use. ... > But I can fix the deallocation problem in the dll. ... public static extern int dll_dbl_read( ... The dll function sets this null pointer into a valid pointer by allocating ...
    (microsoft.public.dotnet.languages.csharp)
  • Cant pass simple array to a C++ DLL
    ... I am having some problems with passing an array to a C++ dll. ... get a pointer and store the first 3 int16's pointed to by the ... Here is my test code: ...
    (microsoft.public.dotnet.framework.interop)