Sign in to follow this  
Followers 0
Nova

DllCall - need clarity

15 posts in this topic

#1 ·  Posted (edited)

Im trying to set the volume level on my pc

I took all infomation from these 2 sites Reference 1 and Reference 2

Ive tryed many varations of the following but nothing seems to change the volume level.

Ive manually set the volume to 0 in Volume Control, and then called the dll like so

DllCall ( "Winmm.dll", "int", "auxSetVolume", "int", 0 , "int", 0x80008000)

Then I closed and reopened volume control but the volume is still at zero.

What am I doing wrong ?

Edit: Id like to point out that neither reference says which dll to use.So how do I figure it out ?

The second reference MSDN however says

Library = Use Winmm.lib

correct me if im wrong, I just assumed the dll to use is Winmm.dll ? Edited by Nova

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

http://www.mentalis.org/apilist/auxSetVolume.shtml

You are correct on the winmm part, but the call is generating a return value of 2, which means the device number is out of range.

$x = DllCall ( "Winmm.dll", "int", "auxSetVolume", "int", 0 , "int", 0x80008000)
msgbox(0,"",$x[0])

EDIT: this returns 0 on my pc, even though I have an aux in the volume properties:

$y = DllCall ( "Winmm.dll", "int", "auxGetNumDevs")
msgbox(0,"",$y[0])

MSDN Docs (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_auxgetnumdevs.asp):

A return value of zero means that no devices are present or that an error occurred.

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks this-is-me,

So I actually got the dllcall right ,well thats a start anyway.

I also get a return value of 0 from auxGetNumDevs on my computer !

Damit dose that mean I cant change the volume on my computer using dllcall ?

I dont understand why it cant find my audio device, it is obviously present (Ive been listening to Green Day all morning :idiot:)

Edited by Nova

Share this post


Link to post
Share on other sites

Anyone know of a way I can make this work ?

Ive been searching for a few hours now and I cant find anything

Share this post


Link to post
Share on other sites

Anyone know of a way I can make this work ?

Ive been searching for a few hours now and I cant find anything

Don't think you'll have any joy with that, just did a google and you need to do lots of other things as well - some of which needs structures and other things that you won't be able to do.

Whenever I have trouble with programming/API I go to groups.google.com (not the web, groups) and search for "apiname win32 programmer". Usually you'll find an answer there (I did for this problem in about 2 seconds :idiot: )

Share this post


Link to post
Share on other sites

Full Volume

DllCall ( "Winmm.dll", "int", "waveOutSetVolume", "int", 0 , "int", 0xFFFF)

No Volume

DllCall ( "Winmm.dll", "int", "waveOutSetVolume", "int", 0 , "int", 0x0000)

Share this post


Link to post
Share on other sites

The actuall auxSetVolume should work as long as you know which device id is correct - but I think it changes from machine to machine and that's when you have to start enumerating all the devices on a system to work out which is which...

Share this post


Link to post
Share on other sites

Check my last post :idiot:

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

@Jon thats for the good info,im sure that will come in very useful in the future.

@MHz that works perfectly, how did u know 0xFFFF was 100% and that 0x0000 was 0% ?

How do I figure out all the precentages inbetween ?

Edited by Nova

Share this post


Link to post
Share on other sites

Check my last post  :idiot:

<{POST_SNAPBACK}>

The waveOutSetVolume only sets the Wave playback volume and not the master volume.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

The waveOutSetVolume only sets the Wave playback volume and not the master volume.

That would probly suit my needs better anyway.

Edit:One other thing, how come I dont have to place winmm.dll in the script directory like I would have to with Larrys dll ?

Edited by Nova

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

wave is better than aux though. :idiot:

MSDN Ofcouse. The info is there.

Edit: Because it is in your system directory. Which is a global evvironmental path.

Edited by MHz

Share this post


Link to post
Share on other sites

Check my last post  :idiot:

There is nothing in the docs to suggest that a value of 0 for the device ID is correct in all cases. I imagine that if you have 2 soundcards (common, one on the motherboard and then a "proper" one in a pci slot) then 0 won't be correct. :D

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

@MHz, SoundSetWaveVolume :idiot::D

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

@Jon, I guess you are right there. Maybe script to find the correct device if unknown?

How do I figure out all the precentages inbetween ?

<{POST_SNAPBACK}>

Some approx percentages for the volume.

0x0000 = 5%

0x1111 = 15%

0x2222 = 20%

0x3333 = 25%

0x4444 = 35%

0x5555 = 40%

0x6666 = 50%

0x7777 = 55%

0x8888 = 60%

0xaaaa = 70%

0xbbbb = 75%

0xcccc = 85%

0xdddd = 90%

0xeeee = 95%

0xffff = 100%

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0