How do I use a char array in an API?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

We have some C++ code that we need to convert to VB.net. It calls the DeviceIOControl API and uses a char array as the output buffer. We think we need to use marshalling to do this but don't know exactly how. For example if we use
Dim outputBuffer(1000) as char
anObject = DeviceIoControl(aHandle, FSCTL_ENUM_USN_DATA, EnumDataBufferIn, Marshal.SizeOf(EnumDataBufferIn), outputbuffer, Marshal.SizeOf(outputbuffer), byteBack, 0)

It tells us that outputbuffer cannot be marshalled as a meaningful structure, no meaningul size or offset can be computed. We have tried all kinds of things to try and get around this and get different errors with everything we try.
 
How did you declare DeviceIoControl? If the C++ code used a char
array, you should probably use a byte array in VB (.NET Char != C++
char). And the parameter type should therefore also be a Byte().



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top