小编给大家分享一下VB.NET如何复制读取音频文件到剪贴板,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
示例代码
Public Class Form1 'VB.Net复制读取音频文件并复制到剪贴板 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim MyData As Byte() MyMyData = My.Computer.FileSystem.ReadAllBytes("WindowsXP.wav") My.Computer.Clipboard.SetAudio(MyData) MessageBox.Show("已经成功将音频数据VB.Net复制到剪贴板!", "51cto提示", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show("将音频数据复制到剪贴板出现错误,请检查音频文件是否已经存在?", "51cto提示", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub '粘贴剪贴板音频数据并播放 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Try Dim MyData As Object MyMyData = My.Computer.Clipboard.GetData(DataFormats.WaveAudio) My.Computer.Audio.Play(MyData, AudioPlayMode.Background) Catch ex As Exception MessageBox.Show("剪贴板上不存在指定的音频数据!", "51cto提示", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub '清空剪贴板上的音频数据 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click My.Computer.Clipboard.Clear() End Sub End Class
看完了这篇文章,相信你对“VB.NET如何复制读取音频文件到剪贴板”有了一定的了解,如果想了解更多相关知识,欢迎关注编程网行业资讯频道,感谢各位的阅读!