• Welcome to Valhalla Legends Archive.
 

Win 32 Api constants

Started by FuZe, August 05, 2003, 10:14 PM

Previous topic - Next topic

FuZe

When I check on MSDN and other places, they always show the constants that API functions can return.  Where/How can I find these values?

Maddox

Go look in the header file that is required, or search google.
asdf.

Yoni

IMO, that's an important missing feature from MSDN (showing values as well as constant names). When I wrote the BNLS protocol specification I made sure to always write a value whenever a constant name appears, but Microsoft never learned this is sometimes important... Anyway, here are a few ways to find the constant values:

1) Check the appropriate header. For example, if you wanted to check what WM_SIZE is equal to, check Winuser.h.
The appropriate header is usually listed in MSDN, either in the documentation for the constant itself (if such exists), or the documentation for the function that uses it. For example, the WM_SIZE documentation says:
QuoteHeader: Declared in Winuser.h, include Windows.h
So Winuser.h is the correct header.

2) Write a quick program:
#include <windows.h>
#include <stdio.h>
int main()
{
 printf("0x%x\n", WM_SIZE);
 return 0;
}


3) Check the VB "API Text Viewer" program, which comes with VB 5 and VB 6, and maybe more (I don't know any more versions of VB). This gives you many of the Win32 declarations and constants in VB code style, and is more useful if you're intending to call the API from VB.

4) Just don't. In most cases, the values of the constants aren't important. If you still need one, refer to one of the 3 methods above.

Grok

I prefer VC++ IDE's "Find in Files" feature for looking up symbolic constants.

When I find the one value, it is usually in a list of related values, so I grab the whole range and convert to VB's Private Const Blah = &Hnnnnnn formatting.

Skywing

If you use Visual Assist with Visual C++, just typing the constant somewhere in an IDE editor window will often be enough for it to find the value for you and populate the top info bar.