Solved

Muting and UnMuting the Windows Volume using Visual Basic 6

Posted on 2004-04-14
4
1,713 Views
Last Modified: 2013-11-25
Is there an API or simple set of commands I can use to Mute all of the audio output from a MS Windows PC system, and then easily UnMute?

I would like a command set or API which has the same effect as clicking the "Mute" Checkbox within the windows volume control displayed in the taskbar.

I have tried the "auxSetVolume" function from the winmm.dll file, to set the volume to zero, however it does not appear to work. I may however have been using incorrect syntax.

Ideally it would be nice if there was a simple API or command such as "auxMuteVolume" and "auxUnMuteVolume", but alas things rarely work out that easily.

Example code for Visual Basic 6 would be useful...

Thankyou.
0
Comment
Question by:Loquerion
  • 2
  • 2
4 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Take a look at the Accepted Answer I posted here: http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20923876.html

Regards,

Idle_Mind
0
 

Author Comment

by:Loquerion
Comment Utility
I have had a look at those links, and the ones that link from there... although I feel I am now closer to the answer, it still eludes me:

Am I right in thinking that I should be declaring two DLL proceedures from "winmm.dll" in a module something like:

----------
Public Declare Function OpenMixer Lib "winmm.dll" (ByVal MixerNumber As Long) As Long

Public Declare Function SetMute Lib "winmm.dll" (Control As MUTE_CONTROL, ByVal MuteState As Boolean) As Boolean
----------

then just calling them where I need them as:

----------
Public Sub MuteVolume()

     OpenMixer(0)
     SetMute(SPEAKER_MUTE, True)

End Sub
----------

because that doesnt work... I get an error "Cannot find DLL entry point OpenMixer in winmm.dll" on calling the open mixer, and I then get an error of "User-defined type not defined" on trying to compile from the SetMute...

...

I believe the code that you pointed to:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20923876.html

...has the ability to do what I need, but I may be Hamming up the module declarations as they are not actually set out word for word in code.


** I do not understand what the "Control As MUTE_CONTROL" actually does... i think that my problem my lie there...
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 50 total points
Comment Utility
The API's make use of custom type structures.  Your best off just copying and pasting everything below the

' ----------------------------------------------------------------------
' Module Code
' ----------------------------------------------------------------------

mark into a module even if you are not going to use all of it.  Try creating the project as I described it to see how it works and then try paring it down to the bare minimum after that.

Idle_Mind
0
 

Author Comment

by:Loquerion
Comment Utility
right... i will try that, but is it not possible to just reference that API, including its custom structures straight from the DLL? It just seems, (and maybe this is just how it is), a little silly to have to include a large WHACK of a DLL file in your project instead of referencing it...

lol... i think i know what you mean though... and i recall that there were some errors in VB when it comes to parsing DLL files... i will give it a go and get back to you.

**

ok, i lied... i tried it there now, and it works... so worst case scenario i will have a slightly larger source code printout than i would have liked, but it does work... i would however like to try and get it working with just a few DLL referencesinstead of a cut/paste job of the whole of "winmm.dll"...

Thanks again, will be in touch...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now