Going further on the Windows Metafile problematic from a previous post, I’ve created a sample code for illustration a pretty useful functionality from OLE.
What the OLE function implemented here does is to generate a metafile with the icon and label for a specific file:
The way to do this is:
1. Call SHGetFileInfo to get the HICON associated to a specific extension
2. Call OleMetafilePictFromIconAndLabel for generating a metafile from a label and an icon
3. Call CopyMetaFile to save the memory metafile to a WMF file
Attached you can find the CPP and EXE for this sample.
MSDN documentation for this function: