Step Two: Generate GUIDs

There's no getting around it—to create a file viewer, you must create a globally unique identifier (GUID) for it. You can run UUIDGEN (from the Win32 SDK) to create a GUID, or you can let MFC do it for you and use a defined macro to get one each time you need one. Guess which option I chose?

I created both the GUIDS.CPP file, which includes the standard header files I needed, and the INITGUID.H file, an OLE header file which ensures that the GUIDs are unique and are built only once. Here is the entire source for the GUIDS.CPP file; the GUID for the object class is stored in the last file, VIEWERID.H.

#include "stdafx.h"
#include <initguid.h>

// Include the definition for the file viewer object.
#include "ViewerID.h"