J
Jacob Gladish
In the following code snippet, I am calling into an unmanaged static .lib
file from a managed class. I belive that I have to pin the pointer before
making the call into the unmanaged code, but I don't completely understand
when a pin is required. Any thoughts?
void p4dn::ClientUser::OutputError( System::String* errString )
{
System::IntPtr ptr = Marshal::StringToHGlobalAnsi( errString );
// does this need to be pinned?
char __pin* str = static_cast< char * >( ptr.ToPointer() );
// unmanged code from static .lib
_clientUser->OutputError( str );
Marshal::FreeHGlobal( ptr );
}
file from a managed class. I belive that I have to pin the pointer before
making the call into the unmanaged code, but I don't completely understand
when a pin is required. Any thoughts?
void p4dn::ClientUser::OutputError( System::String* errString )
{
System::IntPtr ptr = Marshal::StringToHGlobalAnsi( errString );
// does this need to be pinned?
char __pin* str = static_cast< char * >( ptr.ToPointer() );
// unmanged code from static .lib
_clientUser->OutputError( str );
Marshal::FreeHGlobal( ptr );
}