C++结构体
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;
C# 翻译
[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 = 0; i < numApplicationWindows; i++)
{
for (int j = 0; j < MAX_URI_LEN; j++)
{
bytUTF8[j] = appWindowName[j + i * Vidyo32.MAX_URI_LEN];
}
if (bytUTF8[0] != 0)
{ 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 = 0; i < numApplicationWindows; i++)
{
for (int j = 0; j < MAX_URI_LEN; j++)
{
bytUTF8[j] = appWindowAppName[j + i * Vidyo32.MAX_URI_LEN];
}
if (bytUTF8[0] != 0)
{ 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 = 0; i < numSystemDesktops; i++)
{
for (int j = 0; j < MAX_URI_LEN; j++)
{
bytUTF8[j] = sysDesktopName[j + i * Vidyo32.MAX_URI_LEN];
}
if (bytUTF8[0] != 0)
{ appWindowList[i] = UnicodeStringFromUtf8Array(bytUTF8); }
else
{ appWindowList[i] = ""; }
}
return appWindowList;
}
};
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 = 0;
for (; j < cntUnicode; j++)
{
if (charUnicode[j] == 0)
break;
}
string strUnicode = Encoding.Unicode.GetString(bytUnicode, 0, j * 2);
return strUnicode;
}