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..
(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..