Search code examples
c++guiduuiddeclspec

GUID explanation - C++


I use a sample from windows to learn DirectShow, and in a class I have this code in the header file:

struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}")) CLSID_TextureRenderer;

And this line in the cpp file:

CTextureRenderer::CTextureRenderer(LPUNKNOWN unk, HRESULT *hr): CBaseVideoRenderer(__uuidof(CLSID_TextureRenderer), "Texture Renderer", unk, hr)

Can you explain me how that all things work together?

Thank a lot.


Solution

  • This is Microsoft Visual C++ extension to C++, to aid COM programming. __declspec(uuid()) associates GUID structure with a class, and __uuidof yields GUID value of a given type/expression.