By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,017 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,017 IT Pros & Developers. It's quick & easy.

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

P: n/a
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..
Dec 7 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.