Random Wav Player
No attachments for this post
I was really bored today, so I made a completely useless little program that selects a random .wav from a specified folder, plays it and then closes. It could be put in the startup folder and used to play a random .wav sound when Windows starts (as a replacement for the Windows sounds), or any other event.
Original Author: Andy T.
If you use this at Windows Startup, disable the "Start Windows" sound in the Control Panel > Sounds utility. Put this code on a blank form named "Form1" and change the folder that it searches.
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
' If you use this at Windows Startup, disable the "Start Windows" sound in the Control Panel > Sounds utility.
Dim fsoFileSystem, fsoFolder, fsoFile, fsoFolderFiles
Dim strWavs(0 To 50) As String
Dim intCounter As Integer
Dim strFileName As String
intCounter = 0
Set fsoFileSystem = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fsoFileSystem.GetFolder("c:winntmedia") '<< OR WHATEVER FOLDER YOU WANT
Set fsoFolderFiles = fsoFolder.Files
For Each fsoFile In fsoFolderFiles
If Right(fsoFile.Name, 4) = ".wav" Then
strWavs(intCounter) = fsoFile.Name
intCounter = intCounter + 1
strFileName = strWavs(Int(Rnd * intCounter))
Call sndPlaySound32(fsoFolder & "" & strFileName, 0)
Private Sub Form_Load()
Form1.Visible = False
'(pretty simple, huh?)
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.