InitSession Example for C++ 5.0 and later

ILEADRasterTwain_U * pRasterTwain;

HRESULT hr = ::CoCreateInstance(CLSID_LEADRasterTwain_U, NULL, CLSCTX_ALL, IID_ILEADRasterTwain_U, (void **)&pRasterTwain);
if (FAILED(hr) || !pRasterTwain)
{
  ::MessageBox (NULL, _TEXT("Failed to create a Raster Twain Object"), _TEXT("Error"), MB_OK);
  return;
}

pRasterTwain->put_ManName (CString("LEAD Technologies, Inc.").AllocSysString ());
pRasterTwain->put_ProdFamily (CString("LEAD Twain COM Object").AllocSysString ());
pRasterTwain->put_Version (CString("Version 16").AllocSysString ());
pRasterTwain->put_AppName (CString("LEADTools Twain test sample").AllocSysString ());

short iRet = pRasterTwain-> InitSession ((long)GetSafeHwnd()); 
if (iRet != 0) 
	MessageBox (TEXT("Error Initializing Twain"));