42
Chapter 6: Programming Examples
6.2 Function SglSearchLock
6.2.1 C/C++
# i n c l u d e
"SGLW32 . h "
/ /
I n t h e c a s e a SG
−
L o c k u s e r
p r o t e c t s more t h a n 1
/ /
a p p l i c a t i o n / p r o d u c t , h e s h o u l d g i v e e a c h o f
i t a u n i q u e
/ /
p r o d u c t ID . Then
i t s
v e r y e a s y t o
d i s t i n g u i s h
t h e SG
−
L o c k s
/ /
f o r e a c h p r o d u c t
# d e f i n e MY_PRODUCT_ABC_ID 1
# d e f i n e MY_PRODUCT_XYZ_ID 2
u n s i g n e d i n t R e t u r n C o d e ;
/ /
S e a r c h SG
−
L o c k w i t h
p r o d u c t ABC
R e t u r n C o d e = S g l S e a r c h L o c k ( MY_PRODUCT_ABC_ID ) ;
i f ( R e t u r n C o d e ! = SGL_SUCCESS ) {
/ / no SG
−
L o c k f o u n d ! !
p r i n t f ( " S g l S e a r c h L o c k :
E r r o r ! ( c o d e : 0 x%X ) \ n " ,
R e t u r n C o d e
) ;
}
/ / SG
−
L o c k f o u n d !
. . . do t h e
n e x t
r e g u l a r
t h i n g . . .
6.2.2 Delphi
i n t e r f a c e
u s e s
{ $INCLUDE ’ SGLW32IF . PAS ’ }
i m p l e m e n t a t i o n
{ $INCLUDE ’ SGLW32IP . PAS ’ }
{ I n t h e c a s e a SG
−
L o c k u s e r
p r o t e c t s more t h a n 1 a p p l i c a t i o n /
p r o d u c t , h e s h o u l d g i v e e a c h o f
i t a u n i q u e
p r o d u c t ID . Then
i t s
v e r y e a s y t o
d i s t i n g u i s h
t h e SG
−
L o c k s
f o r e a c h p r o d u c t }
c o n s t MY_PRODUCT_ABC_ID = 1 ;
MY_PRODUCT_XYZ_ID = 2 ;
p r o c e d u r e TForm1 . B u t t o n 1 C l i c k ( S e n d e r : T O b j e c t ) ;
v a r R e t u r n C o d e : LongWord ;
{ S e a r c h SG
−
L o c k f o r p r o d u c t ABC }
R e t u r n C o d e : = S g l S e a r c h L o c k ( MY_PRODUCT_ABC_ID ) ;
i f ( R e t u r n C o d e <> SGL_SUCCESS ) t h e n
b e g i n
{ no SG
−
L o c k f o u n d ! ! }
Summary of Contents for SG-Lock
Page 2: ......
Page 22: ......
Page 60: ......
Page 62: ...56 Chapter 7 Technical Data Notes ...
Page 63: ...Chapter 7 Technical Data 57 ...