N
news.microsoft.com
In the Pinvoke example, I find the following example:
unmanaged code:
extern "C" PINVOKELIB_API char* TestStringAsResult()
{
char* result = (char*)CoTaskMemAlloc( 64 );
strcpy( result, "This is return value" );
return result;
}
managed code:
public class LibWrap{
[ DllImport( "..\\LIB\\PinvokeLib.dll" )]
public static extern String TestStringAsResult();
}
String str = LibWrap.TestStringAsResult();
the memory is allocated in unmanaged code, need I free the memory allocated
in managed code? if so, how to free it?
thanks in advance!
unmanaged code:
extern "C" PINVOKELIB_API char* TestStringAsResult()
{
char* result = (char*)CoTaskMemAlloc( 64 );
strcpy( result, "This is return value" );
return result;
}
managed code:
public class LibWrap{
[ DllImport( "..\\LIB\\PinvokeLib.dll" )]
public static extern String TestStringAsResult();
}
String str = LibWrap.TestStringAsResult();
the memory is allocated in unmanaged code, need I free the memory allocated
in managed code? if so, how to free it?
thanks in advance!