【实验】VBS播放控制WMP播放音乐

有点意思。看代码吧!

'播放音乐
Sub Play(url)
	Set oWMP = CreateObject("WMPlayer.OCX")
	oWMP.URL = url
	Do while oWMP.playState = 9 Or oWMP.playState = 3
		WScript.Sleep(1000)
	Loop
End Sub
 
Play("汤潮-那滋味.mp3")

还可以控制光驱

'弹出所有光驱
Sub EjectAllCDROM()
	Set oWMP = CreateObject("WMPlayer.OCX")
	Set colCDROMs = oWMP.cdromCollection
	If colCDROMs.Count >= 1 then
		For i = 0 to colCDROMs.Count - 1
			colCDROMs.Item(i).Eject
		Next
	End If
End Sub
EjectAllCDROM

关于Burgess Lee

人能常清静 天地悉皆归
此条目发表在技术相关分类目录,贴了, , 标签。将固定链接加入收藏夹。