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的语言特性实现更为简洁优雅的转换.本文将从朴素的循环转换开始,逐一介绍三 ...
随机推荐
- Linux Shell交互式自动化运维程序
Expect是Linux操作系统下的一个用来处理交互操作,系统默认是没有安装expect库,所以执行expect会提示找不到命令,需要手动安装,其它安装也比较简单,可以通过二进制源码包编译配置进行安装 ...
- zencart 显示Deprecated: Assigning the return value of new by reference is deprecated
很多朋友的php程序当php的版本升级到5.3以后,会出现"Deprecated: Assigning the return value of new by reference is dep ...
- Codeforces 964 等比数列逆元处理 贪心删偶数度节点
A B C 注意sum要在mod范围内 且不能用/a*b来推 #include<bits/stdc++.h> using namespace std; typedef long long ...
- 清北学堂清华大学钟皓曦神仙讲课day3摘要
---恢复内容开始--- 今天全是DP awsl,真的好难 先从斐波那契开始: dp:满足有一个状态边界条件(f[0]=0,f[1]=1) 边界条件:不需要计算其他状态的值而可以直接得出的状态或者最底 ...
- mapper映射文件配置之insert、update、delete(转载)
原文地址:http://www.cnblogs.com/dongying/p/4048828.html 在mapper文件中,以mapper作为根节点,其下面可以配置的元素节点有: select, i ...
- 在python里使用WriteProcessMemory修改内存地址上的值
import os import sys from ctypes import * windll.kernel32.WriteProcessMemory.argtypes = [c_void_p, c ...
- MongoDB实现增删查方法
1.添加信息 public void addInfo(Infomation infomation) { try{ // TODO Auto-generated method stub //连接Mong ...
- NOIP提高组2016总结
前言 大翻车! 300--: day1 8:30~9:00, 照常看题,思考. 9:00~9:15, 搞定第一题,很水. 9:15~9:45, 思考第二题,我考虑用分深度来处理,想出个个玄学暴力,但刚 ...
- UFUN函数 UF_TRNS(平移 变换)( uf5943 , uf5947)
//设置class_dialog选择过滤 static int init_proc(UF_UI_selection_p_t select,void* user_data) { ; //实体 片体 UF ...
- windows下 申请免费ssl证书的方法 (letsencrypt)
Let's Encrypt,官网是https://letsencrypt.org/,它是一个由各大公司赞助的公益组织: 有趋势有需求,自然也有免费可用.免费的SSL证书中,首推就是Let's Encr ...