Patrick,
In addition to Cor's comments relating to the display of strings in .NET
with embedded NULL chars.
I'm not sure if the following is your problem or not, as the following in in
relation to calling a Win32 API, not a COM object per se (VB6 would be
calling a COM object).
See Adam Nathan's book ".NET and COM - The Complete Interoperabilit y Guide"
by SAMS press for details.
Basically because of the way the Interop Marshaler works strings marshaled
from unmanaged code to managed code are terminated at the NULL char.
To "return" your null embedded string (from an API) you can use a
System.IntPtr.
Dim ptr As System.IntPtr
ptr = Marshal.AllocHG lobal(1024)
' call your API
Dim s As String
s = Marshal.PtrToST ringAnsi(ptr, length)
Marshal.FreeHGl obal(ptr)
Where the 1024 is the maximum size of string that can be returned & length
is the actual length of the string returned, its best if length was returned
by the API.
Can you change the VB6 DLL to be an Array of Bytes or Shorts (16 bit
integers) instead of a String?
Note Adam's book covers the interop marshaler in great detail, another
section may have insite into your problem.
Hope this helps
Jay
"DotNetJunk ies User" <User@-NOSPAM-DotNetJunkies.c om> wrote in message
news:O$******** *****@tk2msftng p13.phx.gbl...
I am calling a VB6 dll from a vb.net windows application that returns an
array of strings. My issue is it seems to truncate after a NULL character.
For Example VB 6 is returning a string with the HEX value of 4E 31 00 00 01
00 20 20 20 20 20 00 00 00 20 20 20 31 32 30. But when it gets back to
Vb.net all I have is 4E 31 or N1. Now I can return the same string as a
return value of a function and I get it all.
Please Help,
Patrick Horn
---
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup
engine supports Post Alerts, Ratings, and Searching.