C++/C# 转化 Marshal VS 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));

 

posted @ 2017-06-01 14:40  dyfisgod  阅读(339)  评论(0编辑  收藏  举报