[Whislly ]老大!快点来吧!
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct VideoCompressorInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string szName;
public Int32 dwHandle;
}
[DllImport("DSStream.dll")]
public extern static int DSStream_EnumVideoCompressor(IntPtr pInfo, ref int piVidCompNum);
private void SetVideoParams_Load(object sender, EventArgs e)
{
int num = 0;
XNStream.DSStream_EnumVideoCompressor(IntPtr.Zero, ref num);
int size = Marshal.SizeOf(typeof(XNStream.VideoCompressorInfo));
IntPtr structPtr = Marshal.AllocHGlobal(size * num);
XNStream.DSStream_EnumVideoCompressor(structPtr, ref num);
XNStream.VideoCompressorInfo[] infos = new XNStream.VideoCompressorInfo[num];
for (int i = 0; i < num; ++i)
{
infos[i] = (XNStream.VideoCompressorInfo)Marshal.PtrToStructure((IntPtr)((int)structPtr + i * size), typeof(XNStream.VideoCompressorInfo));
this.EncodeComBox.Items.Add(infos[i].szName);
//EncodeComBox为一个COMBox控件,第一项显示正确,之后的就是乱码
}
Marshal.FreeHGlobal(structPtr);
补充:.NET技术 , C#