Home All Groups Group Topic Archive Search About

Data type conversion COM dll in VB. Net

Author
6 Mar 2007 2:59 PM
Nicol
Hi,

I created ATL dll in vc++. One of the function has datatype as WCHAR*.

I am rferring this dll in .net, .net automatically converts this to interop
dll and the signature for the method WCHAR* is changed to ushort.

I actually have a string in WCHAR* variable. since it is ushort in .net i am
getting some integer value when made a call.

My code:
VC++
idl file
HRESULT fun1([in]ULONG nVen,[out,retval] WCHAR* retval);

and the functions signature are same as above.

When refeered the dll in .net, the interop dll method is shown as

fun1(ByVal nVen As UInteger, ByRef retval As UShort)

Kindly help me how to get string in .net signature.

Tx in advance

Author
6 Mar 2007 8:01 PM
Mattias Sjögren
>I am rferring this dll in .net, .net automatically converts this to interop
>dll and the signature for the method WCHAR* is changed to ushort.

>I actually have a string in WCHAR* variable. since it is ushort in .net i am
>getting some integer value when made a call.

You can't return a string with a WCHAR* retval parameter. You need an
extra level of indirection for that, WCHAR**. You should also mark it
with the string attribute. The following should be imported correctly
by Tlbimp

HRESULT fun1([in]ULONG nVen,[string,out,retval] WCHAR** retval);


Mattias

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

AddThis Social Bookmark Button