C++/C#结构体转化-二维数组
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#结构体转化-二维数组的更多相关文章
- C++/C#结构体转化-二维数组-bytes To Strings
C++结构体 typedef struct VidyoClientRequestGetWindowsAndDesktops_ { /*! The number of application windo ...
- C语言一维数组、二维数组、结构体的初始化
C语言数组的初始化表示方法 一.C语言一维数组初始化: (1)在定义数组时对数组元素赋以初值.如: static int a[10]={0,1,2,3,4,5,6,7,8,9}; 经过上面的定义和初始 ...
- 用C语言关于学生管理系统的几种实现方法(一位数组,二维数组,指针,结构体)
一位数组: #include <stdio.h> #include<string.h> #define N 5 void luru(float s[],int n); void ...
- 【原创】只学到二维数组和结构体,不用链表也能写一个C贪食蛇?(四)
全系列Index: [原创]只学到二维数组和结构体,不用链表也能写一个C贪食蛇?(一) [原创]只学到二维数组和结构体,不用链表也能写一个C贪食蛇?(二) [原创]只学到二维数组和结构体,不用链表也能 ...
- C语言语法笔记 – 高级用法 指针数组 指针的指针 二维数组指针 结构体指针 链表 | IT宅.com
原文:C语言语法笔记 – 高级用法 指针数组 指针的指针 二维数组指针 结构体指针 链表 | IT宅.com C语言语法笔记 – 高级用法 指针数组 指针的指针 二维数组指针 结构体指针 链表 | I ...
- c动态分配结构体二维数组
这个问题我纠结了蛮久了,因为前面一直忙(自己也懒了点),所以没有能好好研究这个.希望这篇文章能够帮助你们. #include <stdio.h> #include <stdlib.h ...
- JAVA之旅(三)——数组,堆栈内存结构,静态初始化,遍历,最值,选择/冒泡排序,二维数组,面向对象思想
JAVA之旅(三)--数组,堆栈内存结构,静态初始化,遍历,最值,选择/冒泡排序,二维数组,面向对象思想 我们继续JAVA之旅 一.数组 1.概念 数组就是同一种类型数据的集合,就是一个容器 数组的好 ...
- js将一维数组转化为二维数组
遇到的问题: 后端返回的是一组一维数组,但是需要展示的格式是二维数组,常见的场景举例:后台返回10个长度的数组,需要分成3个一组展示在banner上. 例:[1,2,3,4,5,6,7,8,9,10] ...
- 二维数组转化为一维数组 contact 与apply 的结合
将多维数组(尤其是二维数组)转化为一维数组是业务开发中的常用逻辑,除了使用朴素的循环转换以外,我们还可以利用Javascript的语言特性实现更为简洁优雅的转换.本文将从朴素的循环转换开始,逐一介绍三 ...
随机推荐
- AIX中逻辑卷管理
1.逻辑卷管理 逻辑卷的大小确定: 逻辑卷大小(MB)=PP的大小(MB)*LV包含的LP的个数 LV占用的物理空间(MB)=PP的大小(MB)*LV包含的LP的个数*LV拷贝的副本数 逻辑卷控制 ...
- mysql5.7.26做主主配置
一.首先两台服务器安装好mysql数据库环境 参照linux rpm方式安装mysql5.1 https://www.cnblogs.com/sky-cheng/p/10564604.html 二.在 ...
- Web Api 接口测试工具:Swagger
前言:WebApi接口开发完毕后,交付给前端人员或手机端开发者时接口说明文档是必不可少的配套设备,如果公司流程不规范大家使用口口相传的交接方式,而且没有改进的欲望,那你可以到此为止了.Swagger是 ...
- ActiveMQ与Spring / SpringBoot 整合(四)
1. 对 Spring 的整合 1.1 所需jar 包 <!-- activeMQ jms 的支持 --> <dependency> <groupId>org.sp ...
- 对浏览器如何计算CSS的研究---------------引用
1. 加载CSS 在构建DOM的过程中,如果遇到link的标签,当把它插到DOM里面之后,就会触发资源加载——根据href指明的链接: 上面的rel指明了它是一个样式文件.这个加载是异步,不会影响DO ...
- Send Email
private string SendEmail(string mailTo, string body, ref int sendresult) { string errorEmailAddress ...
- Devexpress MVC GridView / CardView (持续更新)
//获取gridview里面的combo box 显示的文本 //获取某个column在gridview的 index RightGridView.GetColumnByField("Fun ...
- (74)c++再回顾一继承和派生
一:继承和派生 0.默认构造函数即不带参数的构造函数或者是系统自动生成的构造函数.每一个类的构造函数可以有多个,但是析构函数只能有一个. 1.采用公用public继承方式,则基类的公有成员变量和成员函 ...
- MariaDB(Mysql)-主从搭建
卸载过程: 停止服务:systemctl stop mariadb 查询安装包:rpm -qa | grep mariadb 卸载: rpm -e mariadb-server rpm -e mari ...
- 南京网络赛C
分段打表大法好!!! 打表40min,A题1s https://nanti.jisuanke.com/t/41300 #include<bits/stdc++.h> #define int ...