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;

                }

            };

  • 相关阅读:
    osg编译日志
    MFC加载大型osg模型
    osg gdal加载tif数据文件
    osg创建灯光
    ubuntu挂载新硬盘
    MFC加载osg模型
    nginx中Geoip_module模块的使用
    centos中释放缓存的方法
    python连接kafka生产者,消费者脚本
    python初始化环境记录
  • 原文地址:https://www.cnblogs.com/acdyf/p/4953036.html
Copyright © 2011-2022 走看看