wuhulahei_123 2015-06-29 14:03 采纳率: 0%
浏览 1552

“PlaySound.DllImportAttribute”不包含采用“1”个参数的

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

//引用新的命名空间,以调用windows系统自带的PlaySound函数
namespace PlaySound
{

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    //读者只需要知道使用这种方法使用PlaySound()就可以!
    //播放响应用户操作的声音和背景音乐,前者使用Windows系统自带的播放声音的函数PlaySound,而背景音乐的播放则使用Windows Media Play控件

    public DllImport



    [DllImport("winmm")]  

    public static extern bool PlaySound(string szSound,int hMod,int i);


    private void Play(string waveName)
    {
         PlaySound(Application.StartupPath +"\\"+waveName,0,1);
    }
     private void PlayMusic(string musicName)
     {
         this.axWindowsMediaPlayer1.URL ="";
         this.axWindowsMediaPlayer1.URL =Application.StartupPath+"\\"+musicName;
     }
    private void Button1_Click(object sender, EventArgs e)
    {
    this.Play("Shot.wav");        

    }
    private void Button2_Click(object sender, EventArgs e)
    {
        this.PlayMusic("town.mid");
    }
}   

}
错误 “PlaySound.DllImportAttribute”不包含采用“1”个参数的构造函数

  • 写回答

2条回答

  • danielinbiti 2015-06-29 14:10
    关注
     public const int SND_FILENAME = 0x00020000;
        public const int SND_ASYNC = 0x0001;
            PlaySound(Application.StartupPath +"\\"+waveName,0,SND_ASYNC|SND_FILENAME);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog