我在 C++ 中有以下结构。我想在 C# 中定义它。怎么做。任何人都有一些想法
typedef struct AccessibleTableInfoTag {
JOBJECT64 caption; // AccesibleContext
JOBJECT64 summary; // AccessibleContext
jint rowCount;
jint columnCount;
JOBJECT64 accessibleContext;
JOBJECT64 accessibleTable;
} AccessibleTableInfo;
我尝试了以下方法来转换 C# 中的 AccessibleTableInfo 标记。但它不起作用。
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct AccessibleTableInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string caption;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string summary;
[MarshalAs(UnmanagedType.I4)]
public int rowCount;
[MarshalAs(UnmanagedType.I4)]
public int columnCount;
[MarshalAs(UnmanagedType.LPStruct)]
public AccessibleContextInfo accessibleContext;
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPStruct)]
public AccessibleContextInfo accessibleTable;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct AccessibleContextInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
public string name; // the AccessibleName of the object
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
public string description; // the AccessibleDescription of the object
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string role; // localized AccesibleRole string
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string role_en_US; // AccesibleRole string in the en_US locale
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string states; // localized AccesibleStateSet string (comma separated)
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string states_en_US; // AccesibleStateSet string in the en_US locale (comma separated)
public Int32 indexInParent; // index of object in parent
public Int32 childrenCount; // # of children, if any
public Int32 x; // screen coords in pixels
public Int32 y; // "
public Int32 width; // pixel width of object
public Int32 height; // pixel height of object
public Boolean accessibleComponent; // flags for various additional
public Boolean accessibleAction; // Java Accessibility interfaces
public Boolean accessibleSelection; // FALSE if this object doesn't
public Boolean accessibleText; // implement the additional interface
// in question
// BOOL accessibleValue; // old BOOL indicating whether AccessibleValue is supported
public Boolean accessibleInterfaces; // new bitfield containing additional interface flags
}
但它不起作用。