Solved

Control Master Volume From App..

Posted on 1998-08-18
8
382 Views
Last Modified: 2012-08-13
How can I control the system volume from within my app using API? I found sample code for controlling the wav volumes, but I would like to control ALL output. The master volume I guess it could be called...

Thanks

Gary
0
Comment
Question by:garymace
  • 4
  • 2
  • 2
8 Comments
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429751
Well, I really do not want points for this, but Dr. GUI had an answer a while ago. I think copying the text here would not be legal, but it should be available online... Lemme see... Oops, MS's MSDN site is incompatible with ie3...  Nah, can't find it. It was in MSDN news (the big newsletter coming with a MSDN subscription) March/april 1998 (Vol. 7 Number 2), page 3, bottom of 1st column. You got access to that? The article mentions "There is no simple API", the function names "mixerGetNumDevs", "mixerGetLineInfo", "mixerGetLineControls" and "mixerGetControlDetails", and bugs in win32api.txt...

Have fun!
0
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429752
0
 

Author Comment

by:garymace
ID: 1429753
No, I do not have access to MSDN. Thanks anyway..

Gary

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:kuk010998
ID: 1429754
Didn't they offer MSDN online free? Might be worth a try. On the other hand, the 'premium' in the URL above might exclude you again... In any case, that article did not offer a complete solution anyway, so you'd search the MSDN library for those keywords I gave. The MSDN library is a must anyway.
0
 
LVL 1

Accepted Solution

by:
nilos earned 20 total points
ID: 1429755
Dr. GUI is gratified that you're concerned for your users' hearing. It speaks volumes for your intelligence and compassion. There are few things more annoying than an application that's just too noisy. It's almost as bad as stealing focus from the foreground application.

Unfortunately, there is no simple API call to get or set the volume. It requires iterating through four layers of functions and structures to get or set the system volume.

First, call mixerGetNumDevs to locate the correct mixer device. Next, call mixerGetLineInfo to determine which line of the device controls the volume to the speakers. Then, call mixerGetLineControls to determine which control on that line lets you change the volume. Finally, call mixerGetControlDetails to obtain the structure containing the volume setting.

To actually change the volume you must work around Visual Basic's limited ability to handle pointers. (Or you could write a COM object in Visual C++ to do this.) The availability of the VarPtr() function in Visual Basic 5.0 smooths the way considerably. Note that you'll have to declare some of the structures and functions yourself because of bugs in the WIN32API.TXT file that shipped with Visual Basic.

By the way, it would probably be a good idea to put the volume back when your application exits—changing it permanently for the user is kinda rude.


0
 
LVL 1

Expert Comment

by:kuk010998
ID: 1429756
That's the text I meant. Just I do not republish copyrighted information...
0
 
LVL 1

Expert Comment

by:nilos
ID: 1429757
I was concerned about to publish copyrighted info but, in this case I did not break any copyright law because:

a) Dr. Guy is a public information
b) I do not publish his text pretending it was mine
c) This place is not a public, in the strict sense, place

d) garymace needs this information to do a better usage of a Microsoft product.

Based on that I don't think that Microsoft will sue me.





0
 

Author Comment

by:garymace
ID: 1429758
Thank you nilos for the post.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to add contact name to VBA code to automate emails in outlook using a Template 11 90
MS Access - Capture pressed key onclick 4 42
MsgBox 4 69
Excel Automation VBA 19 91
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

830 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