Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are "APPCOMMAND" variables used with P/Invoke?

I was searching right here on StackOverflow and found the answer to Mute Volume in C#. I don't understand what's going on with the answer. I've never gotten deep into Marshaling or P/Invoke. I've used them before but never understood what I was doing.

So here's what I'm confused about:

private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int WM_APPCOMMAND = 0x319;
  • When declaring these, does it matter what they are named, or are they just treated like any integer regardless of what they're called?

  • Where do the values 0x80000 and 0x319 come from?

like image 711
Frank Avatar asked Jun 04 '14 20:06

Frank


1 Answers

These values are defined in Winuser.h, which is included in the more common Windows.h.

The Winuser constants for WM_APPCOMMAND are documented on this MSDN page.

How you name these variables in your code, as with any variable, is technically up to you. However, it is common practice to keep naming consistent with that used by the library you are invoking (in this case Winuser.h). I see no reason to name them anything else.

like image 96
Dan Bechard Avatar answered Sep 27 '22 17:09

Dan Bechard