MIDIHDR 问题
我正在尝试在 WinMM.dll 中为 MIDI 函数编写一个包装库,但我在处理 MIDI 长消息时遇到了问题。我在 PIvnoke.net 中找到了这个(我自己添加了第一行):
[StructLayout(LayoutKind.Sequential)]
public struct MIDIHDR
{
IntPtr lpData;
int dwBufferLength;
int dwBytesRecorded;
IntPtr dwUser;
int dwFlags;
MIDIHDR lpNext;
IntPtr reserved;
int dwOffset;
IntPtr dwReserved;
}
但是编译时出现错误:
错误 1 类型为“WinMMM.MidiWrapper.MIDIHDR”的结构成员“WinMMM.MidiWrapper.MIDIHDR.lpNext”导致结构布局中发生循环 C:\Users\Alex\Documents\Visual Studio 2010\Projects\WinMMM\WinMMM \MidiWrapper.cs 219 21 WinMMM
我正在使用 Visual Studio Ultimate 2010,我正在制作一个 C# 类库,任何帮助将不胜感激!
I am trying to write a wrapper library for MIDI functions in WinMM.dll, but I am having trouble with MIDI long messages. I found this in PIvnoke.net (I added the first line myself):
[StructLayout(LayoutKind.Sequential)]
public struct MIDIHDR
{
IntPtr lpData;
int dwBufferLength;
int dwBytesRecorded;
IntPtr dwUser;
int dwFlags;
MIDIHDR lpNext;
IntPtr reserved;
int dwOffset;
IntPtr dwReserved;
}
But I get an error while compiling:
Error 1 Struct member 'WinMMM.MidiWrapper.MIDIHDR.lpNext' of type 'WinMMM.MidiWrapper.MIDIHDR' causes a cycle in the struct layout C:\Users\Alex\Documents\Visual Studio 2010\Projects\WinMMM\WinMMM\MidiWrapper.cs 219 21 WinMMM
I am using Visual Studio Ultimate 2010, I am making a C# class library, and any help will be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将: 更改
为:
来解决您眼前的问题。
MIDL 编译器无法取消引用这些结构链,但如果 API 调用将一个结构作为参数,则通过此更改,到下一个结构的链接将被解码为原始指针,就像第一个字段 lpData 一样代码>.
You can change:
to:
to solve your immediate problem.
The MIDL compiler can't dereference a chain of these structures but if an API call takes one as an argument, with this change the link to the next one will be decoded as a raw pointer, just like first field
lpData
.我不确定你正确的最后一点是否正确。 dwReserved 是一个由四个 DWORD_PTR 组成的数组(请参阅 MIDIHDR MSDN)。你可以使用这样的东西:
I'm not sure the final bit of your correct is right. dwReserved is an array of four DWORD_PTRs (see MIDIHDR on MSDN). You could use something like this:
您还可以将 MIDIHDR 的声明从结构类型更改为类类型。
You could also change the declaration of MIDIHDR from a struct to a class type.