WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sound and Media

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Find Sound Capabilities

Keywords: 	 sound	playmedia

Question:

I am in need of determining if a sound card or sound capability (able to play a wav file) is present in a client via Winbatch. I could not find a consistent registry entry nor could I get the playmidi and playwaveform to provide me with the information.

Thanks in advance.

Answer:

There is no real real good method. Even with all the correct hardware they may have the speakers turned off and won't hear anything anyway.

One trick is to....

	ErrorMode(@OFF)
	LastError()
	PlayMedia("Status WaveForm Ready")
	ErrorMode(@CANCEL)
	if LastError()!=1193
		Message("Sound","Windows multimedia extensions present.")
	else
		Message("Sound","No sound")
	endif

Or

Here's some code I wrote to determine if there is a sound device in the system.

It is a function that returns a false if there is no card, or a true if there is one and it's status is OK.

;Determine if the system has a sound card... 
#DefineFunction SoundPresent() 
        OriginalMode = ErrorMode(@OFF) 
        SoundPresentRet = @FALSE 
        Locator = ObjectOpen("WbemScripting.SWbemLocator") 
        Service = Locator.ConnectServer("","root/cimv2","","") 
        SoundCards = Service.InstancesOf("Win32_SoundDevice") 
        hEnum = ObjectCollectionOpen(SoundCards) 
        objSoundCard = ObjectCollectionNext(hEnum) 
        While objSoundCard != 0 
                If objSoundCard.Status == "OK" Then SoundPresentRet = @TRUE 
                objSoundCard = ObjectCollectionNext(hEnum) 
        EndWhile 
        ObjectCollectionClose(hEnum) 
        ObjectClose(Service) 
        ObjectClose(Locator) 
        ErrorMode(OriginalMode) 
        Return SoundPresentRet 
#EndFunction 

Article ID:   W13217
Filename:   Find Sound Capabilities.txt
File Created: 2003:10:21:12:53:08
Last Updated: 2003:10:21:12:53:08