AddCapabilityToFile example for Delphi

var
 hFile: HTWAINTEMPLATEFILE; 
procedure TForm1.btnAddCapabilityToFileClick(Sender: TObject); 
var
 nRet: L_INT; 
begin
 nRet:= LEADTwain1.OpenTemplateFile ( @hFile, 'c:\temp.ltt', LTWAIN_TEMPLATE_OPEN_WRITE ); 
   if ( nRet = SUCCESS ) then
   begin
    LEADTwain1.EnableEnumCapabilityEvent:= True; 
      LEADTwain1.EnumCapabilities ( LTWAIN_CAPABILITY_GETCURRENT ); 
      LEADTwain1.CloseTemplateFile ( hFile ); 
   end; 
end; 

Function TForm1.LEADTwain1EnumCapabilityEvent(uCap: Cardinal; 
  pCapability: pTW_CAPABILITY): Integer; 
begin
   Result:= LEADTwain1.AddCapabilityToFile ( hFile, pCapability ); 
end;