EndSession Example for C++ 5.0 and later
ILEADRasterTwain * pltRasTwain;
ICapability * pCapability = NULL;
ICapabilityOneValue * pCapOV = NULL;
ILEADRasterVariant * CapVal = NULL;
CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL,
IID_ILEADRasterVariant, (void **)&CapVal);
::CoCreateInstance (CLSID_LEADRasterTwainCapability, NULL, CLSCTX_ALL, IID_ICapability, (void **)&pCapability);
pCapability->QueryInterface (IID_ICapabilityOneValue, (void **)&pCapOV);
pltRasTwain->InitSession((long)m_hWnd);
pCapability->EnableMethodErrors = FALSE;
pCapability->Capability = L_ICAP_XFERMECH;
pCapability->ConType = L_TWON_ONEVALUE;
CapVal->Type = VALUE_USHORT;
CapVal->LongValue = L_TWSX_FILE;
pCapOV->put_OneValItemType (L_TWTY_UINT16);
pCapOV->put_OneValCapValue (CapVal);
pltRasTwain->SetCapability (pCapability, L_LTWAIN_CAPABILITY_SET);
pltRasTwain->Acquire(L_LTWAIN_SHOW_USER_INTERFACE);
pltRasTwain->EndSession();
CapVal->Release ();