COM interfaces in Microsoft's Platform SDK are normally defined by .idl files and they generate .h files using midl from these. So to just look up the CLSID or IID values search the idl file. In this case imapi2.idl has the guid you need and this has been used to produce an imapi2.h file with:
class DECLSPEC_UUID("2735412E-7F64-5B0F-8F00-5D77AFBE261E")
MsftDiscMaster2;
The __uuidof extension in Microsoft's compilers reads the compiler specific data attached to the class or structure by a compiler specific declspec statement. You can do these using:
struct declspec(uuid("{......}")) IMyInterfaceType;
So the DECLSPEC_UUID line above is attaching that guid to the class.
The example code you give from mingw gives a template function that will return a uuid for a given type provided you set up the type using __CRT_UUID_DECL first. It may be that they have a system to call this automatically but that is not shown. Given what I see in your example, to get __uuidof to work for the given coclass you need to add:
__CRT_UUID_DECL(MsftDiscMaster2, 0x2735412e, 0x7f64, 0x5b0f, 0x8f, 0x00, 0x5d, 0x77, 0xaf, 0xbe, 0x26, 0x1e);
Following that statement, you will have a definition for __uuidof(MsftDiscMaster2)
that will return the correct uuid.