Ansi BSTR from dll, how to obtain in ASP.NET

E

Edwin Knoppert

I'm currently using a wrapper which converts an ANSI BSTR from a dll.
(Yes, singlebyte but BSTR ! )

This works fine and i'm aware BSTR's returned must be destroyed by the
caller, which i do.

I noticed that ASP.NET's 'AS STRING' doesn't return the BSTR having
char(0)'s.
So i must assume ASP.NET does not destroy the BSTR + i need the real data.

What i want is a marshalAs but i'm not sure this is available for return
values.

Is it possible to rewrite this:

<DllImport("MY.DLL", EntryPoint:="GetStuff",
CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Ansi)> _
Private Shared Function __GetStuff(ByVal szHello As String) As Int32
End Function

To (pseudocode of course):
<DllImport("MY.DLL", EntryPoint:="GetStuff",
CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Ansi)> _
Private Shared Function GetStuff(ByVal szHello As String) As <MarshalAs,
bstr) As BSTRTHINGY$
End Function

In my Dll it's declared like:
Function GetStuff Alias "GetStuff"( szHello As ASCIIZ ) EXPORT AS String
Function = szHello & "hello"
End Function

Note: VB6 does it fine..
 

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

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top