Solved

Control Master Volume From App..

Posted on 1998-08-18
8
378 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 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