PC Review


Reply
Thread Tools Rate Thread

How do I use a char array in an API?

 
 
=?Utf-8?B?UGl4aWU=?=
Guest
Posts: n/a
 
      14th Jul 2004
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.
 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      14th Jul 2004

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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring an array of char and reading char from Binary Stream nick.stefanov@gmail.com Microsoft C# .NET 5 15th Oct 2005 05:02 PM
how to convert managed char array to unmanaged char*? joye Microsoft VC .NET 1 16th Aug 2005 09:48 PM
How to convert managed char array to unmanaged char*? joye Microsoft VC .NET 0 10th Aug 2005 03:58 AM
How to convert managed char array to unmanaged char*? joye Microsoft VC .NET 5 2nd Aug 2005 11:02 PM
Conversion from managed String to char * or unmanaged char array Jonathan Beck Microsoft VC .NET 0 26th Aug 2003 01:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:47 PM.