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);
    
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站