大家新年好,我遇到了一个涉及到了平台调用的问题

jerry3832 2005-02-10 09:30:21
祝大家在新的一年里编出更好更多的代码,异常少少出这是我的代码请给看看

using System;
using System.Runtime.InteropServices;

class Class1
{
[DllImport("winmm.dll",CharSet = CharSet.Auto)]
private static extern IntPtr waveInGetDevCaps (int uDeviceID,ref WAVEINCAPS lpCaps, int uSize);
//这个函数的作用是根据设备ID得到音频设备的性能
public static void Main(string[] args)
{
WAVEINCAPS b = new WAVEINCAPS();
waveInGetDevCaps(0,ref b,Marshal.SizeOf(b));
Console.WriteLine(b.wChannels);
Console.ReadLine();
}

}
//这个结构的作将被传递给上面的函数以并被填充
[StructLayout(LayoutKind.Sequential,CharSet = CharSet.Unicode)]
public struct WAVEINCAPS
{
public short wMid;
public short wPid;
public long vDriverVersion;
public string szPname;
public uint dwFormate;
public short wChannels;
public short wReserved1;
}
这个到是能得到结果,但是不对比如输出应该是2或1但是在我的计算机上得到的是67请赐教
...全文
72 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Fu7iang 2005-04-04
  • 打赏
  • 举报
回复

 这个可能有用:
 
 ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconmarshalingclassesstructuresunions.htm
nga96 2005-02-13
  • 打赏
  • 举报
回复
偶顶 一下
doubon 2005-02-10
  • 打赏
  • 举报
回复
UP
xiongchen 2005-02-10
  • 打赏
  • 举报
回复
我改了一个,得到1
[DllImport("winmm.dll", EntryPoint="waveInGetDevCaps",CharSet = CharSet.Auto)]
public static extern int waveInGetDevCapsA(int uDeviceID, ref WAVEINCAPS lpCaps, int uSize);

110,570

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧