Home > Net >  Through the CLR encapsulate c interface Marshal: : PtrToStructure () a letter to the managed object
Through the CLR encapsulate c interface Marshal: : PtrToStructure () a letter to the managed object

Time:09-27

Through the CLR encapsulation in c + + interface Marshal: : PtrToStructure () a letter to the managed object type double attribute value error,

Void OnRspSubscribeQuote (const TapAPIQuoteWhole * info)
{
//from const non const first
TapAPIQuoteWhole * t=const_cast & lt; TapAPIQuoteWhole * & gt; (info);
//create a managed object
TapQuoteWhole ^ field=gcnew TapQuoteWhole ();
//marshaling unmanaged data to the host object
Marshal: : PtrToStructure (IntPtr (t), the field);

//by debugging saw, managed object, field - & gt; QPreClosingPrice=- 438866786677 + 76
//
//unmanaged structure: t - & gt; QPreClosingPrice=2430;
}
Conclusion: through Marshal: : PtrToStructure double sealed to the managed object, long value is wrong, the data type but the properties of the string type is right,

CodePudding user response:

There is no answer, I answer, because of asymmetric structure byte arrangement problem, pack=1 synchronization are sorted
  •  Tags:  
  • C#
  • Related