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#结构体转换过程中,一定要注意内存大小一致
时间: 2024-11-01 13:34:15