zoukankan      html  css  js  c++  java
  • C++/C#结构体转化-传string给C++

    此例是把C#结构传给C++

     

    C++:

    typedef struct VidyoClientInEventGroupChat_

    {

        /*! Message (contents) to be sent to all remote participants */

        char message[MAX_CHAT_MESSAGE_LEN];

    } VidyoClientInEventGroupChat;

     C#:

            [StructLayout(LayoutKind.Sequential)]

            public struct VidyoClientInEventGroupChat

            {

                unsafe fixed byte message[MAX_CHAT_MESSAGE_LEN];

                public unsafe bool SetMessage(string message)

                {

                    byte[] bytes = UnicodeStringToUtf8Array(message);

                    if (bytes.Length > MAX_CHAT_MESSAGE_LEN)

                    {

                        return false;

                    }

                    fixed (VidyoClientInEventGroupChat* p = &this)

                        for (int i = 0; i < bytes.Length; i++)

                        {

                            p->message[i] = bytes[i];

                        }

                    return true;

                }

            };

  • 相关阅读:
    Zabbix 3.0编译安装
    用Python发布自己的代码
    欧拉公式为世界上最完美的公式
    通过别人远端安装anaconda来说配置文件
    jupyter安装与使用
    make在latex中的妙用
    latex源码到PDF文件
    anconda配置国内源
    git命令速查
    一张色环图教你搞定配色(转)
  • 原文地址:https://www.cnblogs.com/acdyf/p/4953036.html
Copyright © 2011-2022 走看看