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. Zabbix监控Dell服务器相关硬件资源

    一.安装dell服务器硬件监控工具OMSA 1.安装dell的yum源 [root@push-- ~]# wget -q -O - http://linux.dell.com/repo/hardwar ...

  2. hash_table

    #include <ext/pb_ds/hash_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using name ...

  3. 【NOIP2012模拟10.25】单元格

    题目 在一个R行C列的表格里,我们要选出3个不同的单元格.但要满足如下的两个条件: (1)选中的任意两个单元格都不在同一行. (2)选中的任意两个单元格都不在同一列. 假设我们选中的单元格分别是:A, ...

  4. elasticsearch基本Restful操作

    1.添加数据curl -H "Content-Type: application/json" -XPUT 'http://localhost:9200/megacorp/emplo ...

  5. The Preliminary Contest for ICPC Asia Shanghai 2019 L. Digit sum

    题目:https://nanti.jisuanke.com/t/41422 思路:预处理 #include<bits/stdc++.h> using namespace std; ][]= ...

  6. EF大数据插入

    _April给出代码: using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotati ...

  7. VSCode支持jsx自动补全

    点击settings.json中编辑, 把这段话加上去就可以了 "emmet.includeLanguages": { "javascript": " ...

  8. BZOJ 4769: 超级贞鱼 逆序对 + 归并排序

    手画几下序列的变换后发现逆序对数是恒定的,故只需对第 $0$ 年求逆序对即可. 树状数组会 $TLE$ 的很惨,需要用到归并排序来求逆序对. 其实就是省掉了一个离散化的时间,估计能比树状数组快一半的时 ...

  9. 【Leetcode】二进制求和

    解题思路: 1. 首先在两个字符串前面补‘0’,使它们等长.否则要一直监督操作是否超出两个字符串的索引. 2. 从后向前遍历所有位数,同位相加.字符相加,利用ASCII码,字符在内部都用数字表示,我们 ...

  10. Tensorflow视频教程&Pytorch视频教程

    基于tensorflow做研究和基于pytorch做研究哪个好?哪个更容易复制代码,工业上更易用.Keras和tensorflow.pytorch的关系. Keras:Keras是一个由Python编 ...