String To bytes

 typedef struct VidyoClientInEventGroupChat_
{
/*! Message (contents) to be sent to all remote participants */
char message[MAX_CHAT_MESSAGE_LEN];
} VidyoClientInEventGroupChat;
    [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 = ; i < bytes.Length; i++)
{
p->message[i] = bytes[i];
}
return true;
}
};

bytes To String

 typedef struct VidyoClientRequestGetWindowsAndDesktops_
{
/*! The number of application windows currently open */
VidyoSizeT numApplicationWindows;
/*! List of open application window names (UTF-8) (Localized) */
char appWindowName[MAX_NUM_APP_WINDOWS][MAX_URI_LEN];
/*! List of open application window application names (UTF-8) (Localized) */
char appWindowAppName[MAX_NUM_APP_WINDOWS][MAX_URI_LEN];
/*! List of open application window handles */
VidyoWindowCapturerWindowId appWindowId[MAX_NUM_APP_WINDOWS];
/*! List of open application window geometries */
VidyoRect appWindowRect[MAX_NUM_APP_WINDOWS];
/*! The number of system desktops currently available */
VidyoSizeT numSystemDesktops;
/*! List of available system desktop names (UTF-8) (Not localized) */
char sysDesktopName[MAX_SHARE_DISPLAY_DEVICE][MAX_URI_LEN];
/*! List of available system desktop handles */
VidyoWindowCapturerWindowId sysDesktopId[MAX_SHARE_DISPLAY_DEVICE];
/*! List of available system desktop geometries */
VidyoRect sysDesktopRect[MAX_SHARE_DISPLAY_DEVICE];
} VidyoClientRequestGetWindowsAndDesktops;
 static public string UnicodeStringFromUtf8Array(byte[] bytUTF8)
{
byte[] bytUnicode = Encoding.Convert(Encoding.UTF8, Encoding.Unicode, bytUTF8);
int cntUnicode = Encoding.Unicode.GetCharCount(bytUnicode);
char[] charUnicode = Encoding.Unicode.GetChars(bytUnicode);
int j = ;
for (; j < cntUnicode; j++)
{
if (charUnicode[j] == )
break;
}
string strUnicode = Encoding.Unicode.GetString(bytUnicode, , j * );
return strUnicode;
} [Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
unsafe public struct VidyoClientRequestGetWindowsAndDesktops
{
public uint numApplicationWindows; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NUM_APP_WINDOWS * MAX_URI_LEN)]
public byte[] appWindowName; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NUM_APP_WINDOWS * MAX_URI_LEN)]
public byte[] appWindowAppName; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NUM_APP_WINDOWS)]
public uint[] appWindowId; [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = MAX_NUM_APP_WINDOWS)]
public VidyoRect[] appWindowRect; public uint numSystemDesktops; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_SHARE_DISPLAY_DEVICE * MAX_URI_LEN)]
public byte[] sysDesktopName; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_SHARE_DISPLAY_DEVICE)]
public uint[] sysDesktopId; [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = MAX_SHARE_DISPLAY_DEVICE)]
public VidyoRect[] sysDesktopRect; public string[] GetappWindowList()
{
int numApp = (int)(numApplicationWindows);
string[] appWindowList = new string[numApp];
byte[] bytUTF8 = new byte[MAX_URI_LEN];
for (int i = ; i < numApplicationWindows; i++)
{
for (int j = ; j < MAX_URI_LEN; j++)
{
bytUTF8[j] = appWindowName[j + i * Vidyo32.MAX_URI_LEN];
}
if (bytUTF8[] != )
{ appWindowList[i] = UnicodeStringFromUtf8Array(bytUTF8); }
else
{ appWindowList[i] = ""; }
} return appWindowList;
}
public string[] GetappWindowAppList()
{
int numApp = (int)(numApplicationWindows);
string[] appWindowList = new string[numApp];
byte[] bytUTF8 = new byte[MAX_URI_LEN];
for (int i = ; i < numApplicationWindows; i++)
{
for (int j = ; j < MAX_URI_LEN; j++)
{
bytUTF8[j] = appWindowAppName[j + i * Vidyo32.MAX_URI_LEN];
}
if (bytUTF8[] != )
{ appWindowList[i] = UnicodeStringFromUtf8Array(bytUTF8); }
else
{ appWindowList[i] = ""; }
} return appWindowList;
}
public string[] GetDesktopList()
{
int numApp = (int)(numSystemDesktops);
string[] appWindowList = new string[numApp];
byte[] bytUTF8 = new byte[MAX_URI_LEN];
for (int i = ; i < numSystemDesktops; i++)
{
for (int j = ; j < MAX_URI_LEN; j++)
{
bytUTF8[j] = sysDesktopName[j + i * Vidyo32.MAX_URI_LEN];
}
if (bytUTF8[] != )
{ appWindowList[i] = UnicodeStringFromUtf8Array(bytUTF8); }
else
{ appWindowList[i] = ""; }
} return appWindowList;
}

C++/C#结构体转化-二维数组的更多相关文章

  1. C++/C#结构体转化-二维数组-bytes To Strings

    C++结构体 typedef struct VidyoClientRequestGetWindowsAndDesktops_ { /*! The number of application windo ...

  2. C语言一维数组、二维数组、结构体的初始化

    C语言数组的初始化表示方法 一.C语言一维数组初始化: (1)在定义数组时对数组元素赋以初值.如: static int a[10]={0,1,2,3,4,5,6,7,8,9}; 经过上面的定义和初始 ...

  3. 用C语言关于学生管理系统的几种实现方法(一位数组,二维数组,指针,结构体)

    一位数组: #include <stdio.h> #include<string.h> #define N 5 void luru(float s[],int n); void ...

  4. 【原创】只学到二维数组和结构体,不用链表也能写一个C贪食蛇?(四)

    全系列Index: [原创]只学到二维数组和结构体,不用链表也能写一个C贪食蛇?(一) [原创]只学到二维数组和结构体,不用链表也能写一个C贪食蛇?(二) [原创]只学到二维数组和结构体,不用链表也能 ...

  5. C语言语法笔记 – 高级用法 指针数组 指针的指针 二维数组指针 结构体指针 链表 | IT宅.com

    原文:C语言语法笔记 – 高级用法 指针数组 指针的指针 二维数组指针 结构体指针 链表 | IT宅.com C语言语法笔记 – 高级用法 指针数组 指针的指针 二维数组指针 结构体指针 链表 | I ...

  6. c动态分配结构体二维数组

    这个问题我纠结了蛮久了,因为前面一直忙(自己也懒了点),所以没有能好好研究这个.希望这篇文章能够帮助你们. #include <stdio.h> #include <stdlib.h ...

  7. JAVA之旅(三)——数组,堆栈内存结构,静态初始化,遍历,最值,选择/冒泡排序,二维数组,面向对象思想

    JAVA之旅(三)--数组,堆栈内存结构,静态初始化,遍历,最值,选择/冒泡排序,二维数组,面向对象思想 我们继续JAVA之旅 一.数组 1.概念 数组就是同一种类型数据的集合,就是一个容器 数组的好 ...

  8. js将一维数组转化为二维数组

    遇到的问题: 后端返回的是一组一维数组,但是需要展示的格式是二维数组,常见的场景举例:后台返回10个长度的数组,需要分成3个一组展示在banner上. 例:[1,2,3,4,5,6,7,8,9,10] ...

  9. 二维数组转化为一维数组 contact 与apply 的结合

    将多维数组(尤其是二维数组)转化为一维数组是业务开发中的常用逻辑,除了使用朴素的循环转换以外,我们还可以利用Javascript的语言特性实现更为简洁优雅的转换.本文将从朴素的循环转换开始,逐一介绍三 ...

随机推荐

  1. postman 请求

    1.设置File ->setting -> General 2.设置header 3.填写参数body

  2. Qt Creator 4.9 发布

    Qt Creator 4.8中引入了语言服务器协议支持,允许Qt Creator通过利用此标准轻松支持更多编程语言,使IDE和其他编程工具可以轻松地获得通用编程语言支持的交换格式.使用Qt Creat ...

  3. C语言:标准IO_fopen( )、fclose() ①

    思前想后一个月,我终于敲下了我的第一篇开山之作. 博客千千万,我的博客首先记录的是学习时候的理解,用于给自己翻阅查找,现在主要研究的是C语言和STM32.如果能帮到你,那是最好的,假如我写的东西有错误 ...

  4. JDK的动态代理深入解析(Proxy,InvocationHandler)(转)

    JDK的动态代理深入解析(Proxy,InvocationHandler)(转) 一.什么是动态代理 动态代理可以提供对另一个对象的访问,同时隐藏实际对象的具体事实.代理一般会实现它所表示的实际对象的 ...

  5. 集合综合练习<三>

    package com.JiHeTotal; import java.util.Comparator; import java.util.Map; import java.util.Map.Entry ...

  6. 【leetcode】1185. Day of the Week

    题目如下: Given a date, return the corresponding day of the week for that date. The input is given as th ...

  7. 【mysql】全文索引match多列报错

    表结构如下: CREATE TABLE `T` ( .... FULLTEXT KEY `title_fc` (`titleindex`), FULLTEXT KEY `shortname_fc` ( ...

  8. 对TypeScript进行研究

    1.npm install -g typescript 在编辑器,将下面的代码输入到greeter.ts文件里: function greeter(person) { return "Hel ...

  9. Vue.js 动态为img的src赋值

    在vue中动态给src赋值绑定图片会显示不出来 动态添加src被当做静态资源处理了,没有进行编译 解决方法: 1.用网络地址 把图片放在cdn或自己的服务器上,把网络地址存在imgUrl里,然后直接& ...

  10. UML——概述

    1. 静态视图(类图)      静态视图不描述与时间相关的系统行为,这种行为在其他视图中描述,因此称之为静态试图.      静态视图用类图来实现,正因为它以类图为中心,因此也称之为类图.     ...