Where to find WinAPI constant values for P/Invoke?

Tag: pinvoke , constants Author: jaydi85 Date: 2012-12-26

I'm trying to follow an MSDN magazine article about using PInvoke to do COM reflection. One of the early snippets (just below figure 2) uses CoCreateInstance to create a WebBrowser control. The code snippet references two constants, CLSID_WebBrowser and IID_IUnkown, but doesn't define either of them:

Dim b = CoCreateInstance(CLSID_WebBrowser, Nothing, 1, IID_IUnknown)

Naturally these are not automatically defined and it produces an error. Maybe for people more familiar with P/Invoke these are just known, but I cannot find the values listed anywhere. I have the Windows SDK and searched all the header files in the Include directory but couldn't find them there, either.

So, how does one find the values of such constants to use with P/Invoke?

They are definitely in the SDK. Unknwn.idl and ExDisp.idl declare them. Don't just search *.h
I usually open up VS and write a short extract of code that uses the desired symbol. Then I right click on the symbol and select "Go To Definition". Very lazy I know!