C# Dsound 计算时长,或是别的控件啥的任何都行,只要能计算时长,只要返回一个值,希望大虾们帮个忙~~

解决方案 »

  1.   

    点开始的时候就开始计算咯, 到结束的时候 获取  时间就可以了。向窗体添加一个 Timer控件 输入代码 
    一个textbox控件        private void timer1_Tick(object sender, EventArgs e)
            {
                long curTickValue = Environment.TickCount;
                long difference = curTickValue - compuTime;
                long applicationHours, applicationMinutes, applicationSeconds;            applicationHours = (difference / (3600 * 999)) % 24;
                applicationMinutes = (difference / (60 * 999)) % 60;
                applicationSeconds = (difference / 999) % 60;            this.textbox1.Text = "录音时间:" + applicationHours + " 小时 " + applicationMinutes + " 分 " + applicationSeconds + " 秒 ";
            }
    点击开始录音输入代码             this.timer1.Interval = 1000;
                this.timer1.Start();
    记得结贴
      

  2.   

    结束是
    this.timer1.Stop();然后textbox1里的时间就是了。
      

  3.   

    你好,出现一个错误
     error CS0103: The name 'compuTime' does not exist in the current context这是为什么呢??
      

  4.   

    别沉了啊,,,谁帮帮忙啊 给个code啊。
      

  5.   

    我发的代码里有个名字叫 compuTime的吗?
      

  6.   

    果然有,随便在外面添加句“        long compuTime = 0;”
      

  7.   

    不好意思,误人子弟了,我这是程序启动时间。 SORRY。