// Normally you would only call CoInitialize/CoUninitialize
// once per thread. This sample calls CoInitialize in this
// draw function simply to illustrate that you must call
// CoInitialize before calling CoCreateInstance.
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// Create the imaging factory.
if (SUCCEEDED(CoCreateInstance (CLSID_ImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **)&pImgFactory)))
{
// Load the image from the JPG file.
if (SUCCEEDED(pImgFactory->CreateImageFromFile(
TEXT("\\Program Files\\Imaging\\flower.jpg"),
&pImage)))
{
// Draw the image.
pImage->Draw(hdc, &rc, &rc);
pImage->Release();
}