SaveTemplate 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->InitSession((long)GetSafeHwnd()); 
pRasterTwain->SelectSource();

CString strTemplateFile = TEXT("");
CFileDialog TemplateFile (FALSE, TEXT("ltt"), NULL, OFN_CREATEPROMPT, TEXT("Template Files (*.ltt)|*.ltt|All Files (*.*)|*.*||"));

if (TemplateFile.DoModal() == IDOK) 
{
	strTemplateFile = TemplateFile.GetPathName();
	pRasterTwain->EnableSaveTemplateEvent = FALSE;
	pRasterTwain->SaveTemplate (strTemplateFile.AllocSysString());
}