Data type conversion COM dll in VB. Net

G

Guest

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
 
M

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
 

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

Top