EndSession Example for Visual FoxPro 6

#define L_TWON_ONEVALUE 5
#define L_LTWAIN_CAPABILITY_SET 1
#define L_LTWAIN_SHOW_USER_INTERFACE 1
#define L_TWTY_UINT16 4
#define L_ICAP_XFERMECH 259
#define L_TWSX_NATIVE 0

objRasterTwain = CreateObject("LEADRasterTwain.LEADRasterTwain.145")
objRasterTwain.InitSession(ThisForm.RasterView1.Window)
objTwainCap = CreateObject("LEADTwainCapability.LEADTwainCapability.145") 
objTwainCap.EnableMethodErrors = .F.
objTwainCap.CapInfo.Capability = L_ICAP_XFERMECH
objTwainCap.CapInfo.ConType = L_TWON_ONEVALUE
objTwainCap.CapOneValue.OneValItemType = L_TWTY_UINT16
#define VALUE_USHORT 4 
CapVal = CreateObject("LEADRasterVariant.LEADRasterVariant.145")
CapVal.Type = VALUE_USHORT
CapVal.LongValue = L_TWSX_NATIVE

objTwainCap.CapOneValue.OneValCapValue = CapVal

objRasterTwain.SetCapability2(objTwainCap, L_LTWAIN_CAPABILITY_SET)

objRasterTwain.Acquire(L_LTWAIN_SHOW_USER_INTERFACE)
objRasterTwain.EndSession()