zoukankan      html  css  js  c++  java
  • C++/C# 最基本的Marshal和Ptr

    Vidyo32.VidyoClientInEventLogin Login = new Vidyo32.VidyoClientInEventLogin();

     

                Login.portalUri = this.tbxIP.Text.Trim(); //"http://kaunas.vidyo.scandihealth.net";

                Login.userName = this.tbxID.Text.Trim(); //"test-sa3";

                Login.userPass = this.tbxPwd.Text.Trim(); //"test-sa3";

     

     

     

                int size = Marshal.SizeOf(Login);

                IntPtr ptr = Marshal.AllocCoTaskMem(size);

                Marshal.StructureToPtr(Login, ptr, false);

     

                Int32 test = Vidyo32.VidyoClientSendEvent(Vidyo32.VidyoClientInEvent.VIDYO_CLIENT_IN_EVENT_LOGIN, ptr, size);

                Login = (Vidyo32.VidyoClientInEventLogin)Marshal.PtrToStructure(ptr, typeof(Vidyo32.VidyoClientInEventLogin));

     

     

    在此总结一句,C++结构体和C#结构体转换过程中,一定要注意内存大小一致

  • 相关阅读:
    codeforce1028A Find Square
    2018ccpc网络赛 Buy and Resell
    差分约束
    Lost Cows
    动态查询区间第k大
    疫情控制
    天天爱跑步
    次小生成树
    树上差分闇の連锁
    Stars in Your Window
  • 原文地址:https://www.cnblogs.com/acdyf/p/4953048.html
Copyright © 2011-2022 走看看