Read Barcodes From Subfolder - Delphi
BarCode Reader SDK sample in Delphi demonstrating ‘Read Barcodes From Subfolder’
Project1.dpr
��/ / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 
 / /               B y t e S c o u t   B a r c o d e   R e a d e r   S D K 	 	                                                                           
 
 / /                                                                                                                                       
 
 / /               C o p y r i g h t   �   2 0 2 0   B y t e S c o u t   -   h t t p : / / w w w . b y t e s c o u t . c o m               
 
 / /               A L L   R I G H T S   R E S E R V E D                                                                                   
 
 / /                                                                                                                                       
 
 / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 
 
 
 { 
 
 
 
   I M P O R T A N T   N O T I C E   f o r   D E L P H I   2 0 0 7 ,   D e l p h i   2 0 0 6   o r   e a r l i e r   v e r s i o n s : 
 
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   U s u a l   a p p r o a c h   w i t h   t y p e   l i b r a r y   i m p o r t   ( s o   c a l l e d   " e a r l y   b i n d i n g " )   w i l l   c r a s h   w i t h   " s t a c k o v e r f l o w "   o r   " f l o a t i n g   p o i n t   e r r o r "   d u e   t o   i s s u e s   i n   t h i s   v e r s i o n s   o f   D e l p h i .   
 
   S O L U T I O N :   P l e a s e   u s e   s o   c a l l e d   " l a t e   b i n d i n g "   t h a t   r e q u i r e s   N O   t y p e   l i b r a r y   i m p o r t   a n d   w o r k s   b y   c r e a t i n g   o b j e c t s   a t   t h e   r u n t i m e   l i k e   t h i s :     
 
   / /   - - - - - - - - - - - - - - - - - 
 
   p r o g r a m   P r o j e c t 1 ; 
 
   u s e s 
 
       S y s U t i l s , 
 
       C o m O b j , 
 
       A c t i v e X ; 
 
   v a r 
 
   e x t r a c t o r :   V a r i a n t ; 
 
   b e g i n 
 
   C o I n i t i a l i z e ( n i l ) ; 
 
   / /   C r e a t e   a n d   i n i t i a l i z e   
 
   e x t r a c t o r   : =   C r e a t e O l e O b j e c t ( ' B y t e s c o u t . P D F E x t r a c t o r . C S V E x t r a c t o r ' )   ; 
 
   / /   a s   u s u a l   
 
   e x t r a c t o r . L o a d D o c u m e n t F r o m F i l e   ( ' . . / . . / s a m p l e 3 . p d f ' ) ; 
 
   / /   & 
 
   / /   d e s t r o y   t h e   o b j e c t   b y   s e t t i n g   t o   v a r E m p t y 
 
   e x t r a c t o r   : =   v a r E m p t y ;     
 
   e n d . 
 
   / /   - - - - - - - - - - - - - - - - -     
 
 
 
 } 
 
 
 
 p r o g r a m   P r o j e c t 1 ; 
 
 
 
 { $ A P P T Y P E   C O N S O L E } 
 
 
 
 { 
 
   S a m p l e   t h a t   s h o w s   r e a d i n g   o f   b a r c o d e s   f r o m   i m a g e s   i n   / I m a g e s /   s u b f o l d e r 
 
 } 
 
 
 
 u s e s 
 
     S y s U t i l s , 
 
     C o m O b j , 
 
     A c t i v e X ; 
 
 v a r 
 
   r e a d e r :   V a r i a n t ; 
 
   S R :   T S e a r c h R e c ; 
 
   a r r a y O u t p u t :   V a r i a n t ; 
 
   v a r I t e m :   V a r i a n t ; 
 
   i :   i n t e g e r ; 
 
   p a t h W i t h I m a g e s ,   i m a g e T y p e :   s t r i n g ; 
 
 b e g i n 
 
   C o I n i t i a l i z e ( n i l ) ; 
 
 
 
   / /   D i s a b l e   f l o a t i n g   p o i n t   e x c e p t i o n   t o   c o n f o r m   t o   . N E T   f l o a t i n g   p o i n t   o p e r a t i o n s   b e h a v i o r . 
 
   S y s t e m . S e t 8 0 8 7 C W ( $ 1 3 3 f ) ; 
 
 
 
   / /   C r e a t e   a n d   i n i t i a l i z e   B y t e s c o u t . B a r C o d e R e a d e r . R e a d e r   o b j e c t 
 
   r e a d e r   : =   C r e a t e O l e O b j e c t ( ' B y t e s c o u t . B a r C o d e R e a d e r . R e a d e r ' ) ; 
 
   r e a d e r . R e g i s t r a t i o n N a m e   : =   ' d e m o ' ; 
 
   r e a d e r . R e g i s t r a t i o n K e y   : =   ' d e m o ' ; 
 
 
 
   / /   E n a b l e   C o d e   3 9   d e c o d i n g ,   y o u   m a y   a l s o   e n a b l e   o t h e r   t y p e s   ( d o z e n s   o f   t y p e s   s u p p o r t e d ) 
 
   / /   s e e   . B a r C o d e T y p e s T o F i n d   f o r   m o r e   v a l u e s . 
 
   r e a d e r . B a r c o d e T y p e s T o F i n d . C o d e 3 9   : =   t r u e ; 
 
 
 
   / /   F o r   e x a m p l e   t o   e n a b l e   C o d e 1 2 8   u n c o m m e n t   l i n e   b e l o w 
 
   / /   r e a d e r . B a r c o d e T y p e s T o F i n d . C o d e 1 2 8   : =   t r u e ; 
 
 
 
   / /   F o r   e x a m p l e   t o   e n a b l e   Q R   C o d e   u n c o m m e n t   l i n e   b e l o w 
 
   / /   r e a d e r . B a r c o d e T y p e s T o F i n d . Q R C o d e   : =   t r u e ; 
 
 
 
   / /   S e t u p   p o s s i b l e   b a r c o d e   o r i e n t a t i o n s   (   a t o   s u p p o r t   r o t a t e d   i m a g e s ) 
 
   / /   s e e   B a r C o d e   R e a d e r   S D K   -   O r i e n t a t i o n T y p e   e n u m   f o r   m o r e   v a r i a t i o n s 
 
   / /   u n c o m m e n t   t o   s u p p o r t   m o r e   o r i e n t a t i o n s   l i k e   r i g h t   t o   l e f t   
 
   { 
 
   r e a d e r . O r i e n t a t i o n   : = 
 
 	 	 	 	 	 1   o r   / / O r i e n t a t i o n T y p e . H o r i z o n t a l F r o m L e f t T o R i g h t 
 
 	 	 	 	 	 1 6   o r   / /   O r i e n t a t i o n T y p e . H o r i z o n t a l F r o m R i g h t T o L e f t 
 
 	 	 	 	 	 3 2 7 6 8   o r   / /   O r i e n t a t i o n T y p e . V e r t i c a l F r o m B o t t o m T o T o p 
 
 	 	 	 	 	 2 ;   / /   O r i e n t a t i o n T y p e . V e r t i c a l F r o m T o p T o B o t t o m ; 
 
   } 
 
 
 
   / /   u n c o m m e n t   t o   e n a b l e   p r o c e s s i n g   o f   n e g a t i v e   b a r c o d e s   ( w h i t e   b a r s   o n   d a r k   b a c k g r o u n d ) 
 
   / /   r e a d e r . S e a r c h N e g a t i v e   : =   t r u e ; 
 
 
 
   / /   u n c o m m e n t   t o   E n a b l e   H e u r i s t i c   M o d e   ( t r y   d i f f e r e n t   i m a g e   p r o c e s s i n g   m o d e s   i f   t h e   d e f a u l t   f a i l e d ) . 
 
   / /   H e l p s   o n   p h o t o s   w i t h   p o o r   l i g h t i n g   c o n d i t i o n s . 
 
   / / r e a d e r . H e u r i s t i c M o d e   : =   t r u e ; 
 
 
 
   / /   d e f i n e   s u b f o l d e r   w h e r e   w e   h a v e   i m a g e s   
 
   p a t h W i t h I m a g e s   : =   ' . \ I m a g e s \ ' ; 
 
   i m a g e T y p e   : =   ' * . j p g ' ;   / /   c a n   a l s o   b e   * . p n g ,   * . t i f f ,   * . b m p ,   * . P D F 
 
 
 
   / /   n o w   s e a r c h   f o r   f i l e s   w i t h   i m a g e s   a n d   p r o c e s s i n g   t h e m   o n e   b y   o n e 
 
   i f   F i n d F i r s t ( p a t h W i t h I m a g e s   +   i m a g e T y p e ,   f a A n y F i l e ,   S R )   =   0   t h e n   b e g i n 
 
         r e p e a t 
 
             i f   ( S R . A t t r   <