S
sanu
Hi,
Need your help,
parameter byref. Below code sample.
Do we have to take care in .net for the memory allocated in the c++ dll
(SysAllocStringByteLen ?). Or does .net on exiting handles this. How
does we release the memory allocated.. Please..
Thanks
saish (Developer)
Vb.net code:
---------------
Declare Function fnstrOutput Lib "C:\net\dlls\xmlref.dll" _
Alias "STR_OUTPUT" (ByRef outString As String) As Integer
...
...
<WebMethod()> _
Public Function Teststring() As String
Dim outstr as string
rc = fnstrOutput(outstr)
return "return : " + ctype(rc,string)
End Function
C++ win32 dll code:
---------------------------
extern "C"
{
extern int WINAPI fnOutput(BSTR *poutputDoc);
}
//******* Test passing Output string ByRef *****************
int WINAPI fnOutput(BSTR *poutDoc)
{
SysFreeString(*poutDoc);
// SysAllocStringByteLen() function takes ANSI string and returns
// a BSTR.
// poutXML is a DOMDOCUMENTPTR type ...
*poutDoc = SysAllocStringByteLen(poutXML->xml, poutXML->xml.length()
-1);
return 90;
}
Need your help,
function. The dll function takes a string (consists of huge data)From our vb.net web service we are calling a unmanaged C++ win32 dll
parameter byref. Below code sample.
Do we have to take care in .net for the memory allocated in the c++ dll
(SysAllocStringByteLen ?). Or does .net on exiting handles this. How
does we release the memory allocated.. Please..
Thanks
saish (Developer)
Vb.net code:
---------------
Declare Function fnstrOutput Lib "C:\net\dlls\xmlref.dll" _
Alias "STR_OUTPUT" (ByRef outString As String) As Integer
...
...
<WebMethod()> _
Public Function Teststring() As String
Dim outstr as string
rc = fnstrOutput(outstr)
return "return : " + ctype(rc,string)
End Function
C++ win32 dll code:
---------------------------
extern "C"
{
extern int WINAPI fnOutput(BSTR *poutputDoc);
}
//******* Test passing Output string ByRef *****************
int WINAPI fnOutput(BSTR *poutDoc)
{
SysFreeString(*poutDoc);
// SysAllocStringByteLen() function takes ANSI string and returns
// a BSTR.
// poutXML is a DOMDOCUMENTPTR type ...
*poutDoc = SysAllocStringByteLen(poutXML->xml, poutXML->xml.length()
-1);
return 90;
}