Windows metafile is a vector format. It consists of a header containing information about the file, followed by instructions for the Windows Graphics Device Interface (GDI). These instructions tell the operating system how to render the objects described by the file.
A metafile can also contain a bitmap file, but in that case, the metafile is just a "wrapper" for the bitmap. The operating system renders it just as though it were a normal bitmap, but it cannot be directly edited in Photoshop or the like--it must be extracted from the metafile first.
A compressed metafile is the same thing, except compressed with the same algorithm used in zip files, which is called DEFLATE. Unlike zip, though, a wmz or emz can contain only one compressed file.
That's about the extent of my knowledge on that subject. I don't do any Windows programming, so I don't know anything about the GDI or its functions.
Very interesting question!
edit: I just reread your question, and you'd asked about the structure of the header and data. Here's a summary of the contents of the header:
The header is 18 bytes in length and is structured as follows:
typedef struct _WindowsMetaHeader
WORD FileType; /* Type of metafile (1=memory, 2=disk) */
WORD HeaderSize; /* Size of header in WORDS (always 9) */
WORD Version; /* Version of Microsoft Windows used */
DWORD FileSize; /* Total size of the metafi+le in WORDs */
WORD NumOfObjects; /* Number of objects in the file */
DWORD MaxRecordSize; /* The size of largest record in WORDs */
WORD NoParameters; /* Not Used (always 0) */
That would be followed by a series of instructions to the GDI, like so:
typedef struct _WindowsMetaRecord
DWORD Size; /* Total size of the record in WORDs */
WORD Function; /* Function number (defined in WINDOWS.H) */
WORD Parmeters; /* Parameter values passed to function */
There may also be an additional header that allows the metafile to be used in an application other than the one it was created in. It has this format:
typedef struct _WmfSpecialHeader
DWORD Key; /* Magic number (always 9AC6CDD7h) */
WORD Handle; /* Metafile HANDLE number (always 0) */
SHORT Left; /* Left coordinate in metafile units */
SHORT Top; /* Top coordinate in metafile units */
SHORT Right; /* Right coordinate in metafile units */
SHORT Bottom; /* Bottom coordinate in metafile units */
WORD Inch; /* Number of metafile units per inch */
DWORD Reserved; /* Reserved (always 0) */
WORD Checksum; /* Checksum value for previous 10 WORDs */
This is all C code, so it would need to be compiled before it was useable. You could write the metafile in any programming language, of course.
There is lots more information in the article I linked to above, including what looks like a nearly comprehensive list of GDI functions.