uo_fingerprint.sru 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. $PBExportHeader$uo_fingerprint.sru
  2. forward
  3. global type uo_fingerprint from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_fingerprint from nonvisualobject autoinstantiate
  7. end type
  8. type prototypes
  9. FUNCTION long InitializeFg() LIBRARY "AdvFgSdk1.dll"
  10. FUNCTION long UnInitializeFg() LIBRARY "AdvFgSdk1.dll"
  11. FUNCTION long OpenDevice( BLOB pbuf,int size ) LIBRARY "AdvFgSdk1.dll"
  12. function long BeginReadDevice(boolean bvfy) library "advfgsdk1.dll"
  13. function long ReadDevice(boolean bvfy) library "advfgsdk1.dll"
  14. function long EndReadDevice(boolean bVfy, REF BLOB pDib,int dibSize ) library "advfgsdk1.dll"
  15. // 不需要回传DIB 图像数据 可用 EndRead 代替 EndReadDevice
  16. function long EndRead(boolean bvfy ) library "advfgsdk1.dll"
  17. function long EnrollFingerPrintEx( ref BLOB pbuf ,int size) library "advfgsdk1.dll"
  18. function long VerifyFingerPrintEx( BLOB pbuf ,int size) library "advfgsdk1.dll"
  19. //测试
  20. function long EndTest(ref BLOB buf ) library "advfgsdk1.dll"
  21. // 检测设备
  22. Function long CheckDevice () library "AdvFgSdk1.dll"
  23. Function long AbortReadDevice() library "AdvFgSdk1.dll"
  24. Function long RemoteVerify(ref Blob pbuf, ref Blob pvfy, int size) library "AdvFgSdk1.dll"
  25. Function long CopyvfyBuf(ref Blob pbuf, int size) library "AdvFgSdk1.dll"
  26. end prototypes
  27. type variables
  28. private boolean ib_abort = false
  29. protectedwrite boolean ib_reading = false
  30. end variables
  31. forward prototypes
  32. public function integer uf_regfingerprint (ref blob arg_buf, ref string arg_msg)
  33. public function integer uf_verifyfingerprint (blob arg_ident, ref string arg_msg)
  34. public function integer uf_remoteverify (blob arg_idents, blob arg_finger, ref string arg_msg)
  35. public subroutine uf_abort ()
  36. end prototypes
  37. public function integer uf_regfingerprint (ref blob arg_buf, ref string arg_msg);//////////////////////////////////////////////////
  38. // 读指纹三次,获取指纹特征blob{521} arg_buf
  39. // 读取指纹时,不阻塞其它消息
  40. ib_reading = true
  41. int rslt = 1
  42. Blob{64} pt ;
  43. // KEY 验证 数据
  44. BlobEdit(pt,1, (8))
  45. BlobEdit(pt,2, (4))
  46. BlobEdit(pt,3, (55))
  47. BlobEdit(pt,4, (27))
  48. BlobEdit(pt,5, (2))
  49. BlobEdit(pt,6, (9))
  50. BlobEdit(pt,7, (33))
  51. BlobEdit(pt,8, (61))
  52. BlobEdit(pt,9, (29))
  53. BlobEdit(pt,10, (50))
  54. BlobEdit(pt,11, (49))
  55. BlobEdit(pt,12, (34))
  56. BlobEdit(pt,13, (29))
  57. BlobEdit(pt,14, (32))
  58. BlobEdit(pt,15, (33))
  59. BlobEdit(pt,16, (30))
  60. BlobEdit(pt,17, (24))
  61. BlobEdit(pt,18, (14))
  62. BlobEdit(pt,19, (168))
  63. BlobEdit(pt,20, (83))
  64. BlobEdit(pt,21, (7))
  65. BlobEdit(pt,22, (27))
  66. BlobEdit(pt,23, (101))
  67. BlobEdit(pt,24, (184))
  68. BlobEdit(pt,25, (90))
  69. BlobEdit(pt,26, (152))
  70. BlobEdit(pt,27, (150))
  71. BlobEdit(pt,28, (103))
  72. BlobEdit(pt,29, (87))
  73. BlobEdit(pt,30, (98))
  74. BlobEdit(pt,31, (100))
  75. BlobEdit(pt,32, (93))
  76. if InitializeFg() <> 1 then
  77. rslt = 0
  78. arg_msg = '指纹API初始化失败'
  79. goto ext
  80. end if
  81. if CheckDevice() <> 1 then
  82. rslt = 0
  83. arg_msg = "指纹设备没有连接正确"
  84. goto ext
  85. end if
  86. if OpenDevice( pt ,32) <> 1 then
  87. rslt = 0
  88. arg_msg = '打开指纹设备失败'
  89. goto ext
  90. end if
  91. if BeginReadDevice(FALSE) <> 1 then
  92. rslt = 0
  93. arg_msg = '开始读指纹失败'
  94. goto ext
  95. end if
  96. long count = 3
  97. do
  98. Int bw = 1
  99. do
  100. bw = ReadDevice(FALSE)
  101. if ib_abort then
  102. rslt = 0
  103. arg_msg = '用户中断'
  104. goto ext
  105. end if
  106. loop while (bw <= 0)
  107. if EndRead(FALSE) = 1 then
  108. count = count - 1
  109. end if
  110. loop while (count > 0)
  111. blob{512} lb_buf
  112. long ret
  113. ret = EnrollFingerPrintEx(REF lb_buf,512 )
  114. if ret <> 1 then
  115. rslt = 0
  116. arg_msg = '获取指纹信息失败' + ',请重试!错误码:' + string(ret)
  117. goto ext
  118. end if
  119. arg_buf = lb_buf
  120. ext:
  121. UnInitializeFg()
  122. ib_abort = false
  123. ib_reading = false
  124. return rslt
  125. end function
  126. public function integer uf_verifyfingerprint (blob arg_ident, ref string arg_msg);////////////////////////////////////////////
  127. // 读取指纹,与指纹特征(arg_ident)比较
  128. //
  129. ib_reading = true
  130. int rslt = 1
  131. Blob{64} pt ;
  132. // KEY 验证 数据
  133. BlobEdit(pt,1, (8))
  134. BlobEdit(pt,2, (4))
  135. BlobEdit(pt,3, (55))
  136. BlobEdit(pt,4, (27))
  137. BlobEdit(pt,5, (2))
  138. BlobEdit(pt,6, (9))
  139. BlobEdit(pt,7, (33))
  140. BlobEdit(pt,8, (61))
  141. BlobEdit(pt,9, (29))
  142. BlobEdit(pt,10, (50))
  143. BlobEdit(pt,11, (49))
  144. BlobEdit(pt,12, (34))
  145. BlobEdit(pt,13, (29))
  146. BlobEdit(pt,14, (32))
  147. BlobEdit(pt,15, (33))
  148. BlobEdit(pt,16, (30))
  149. BlobEdit(pt,17, (24))
  150. BlobEdit(pt,18, (14))
  151. BlobEdit(pt,19, (168))
  152. BlobEdit(pt,20, (83))
  153. BlobEdit(pt,21, (7))
  154. BlobEdit(pt,22, (27))
  155. BlobEdit(pt,23, (101))
  156. BlobEdit(pt,24, (184))
  157. BlobEdit(pt,25, (90))
  158. BlobEdit(pt,26, (152))
  159. BlobEdit(pt,27, (150))
  160. BlobEdit(pt,28, (103))
  161. BlobEdit(pt,29, (87))
  162. BlobEdit(pt,30, (98))
  163. BlobEdit(pt,31, (100))
  164. BlobEdit(pt,32, (93))
  165. if InitializeFg() <> 1 then
  166. rslt = 0
  167. arg_msg = '指纹API初始化失败'
  168. goto ext
  169. end if
  170. if CheckDevice() <> 1 then
  171. rslt = 0
  172. arg_msg = "指纹设备没有连接正确"
  173. goto ext
  174. end if
  175. if OpenDevice( pt ,32) <> 1 then
  176. rslt = 0
  177. arg_msg = '打开指纹设备失败'
  178. goto ext
  179. end if
  180. if BeginReadDevice(TRUE) <> 1 then
  181. rslt = 0
  182. arg_msg = '开始读指纹失败'
  183. goto ext
  184. end if
  185. Int bw = 1
  186. do
  187. bw = ReadDevice(TRUE)
  188. if ib_abort then
  189. rslt = 0
  190. arg_msg = '用户中断'
  191. goto ext
  192. end if
  193. loop while (bw <= 0)
  194. if EndRead(TRUE) <> 1 then
  195. rslt = 0
  196. arg_msg = '读取指纹失败'
  197. goto ext
  198. end if
  199. long ret
  200. ret = VerifyFingerPrintEx(REF arg_ident,len(arg_ident))
  201. if ret <= 0 then
  202. rslt = 0
  203. arg_msg = '验证失败' + ',请重试!错误码:' + string(ret)
  204. goto ext
  205. end if
  206. ext:
  207. UnInitializeFg()
  208. ib_abort = false
  209. ib_reading = false
  210. return rslt
  211. end function
  212. public function integer uf_remoteverify (blob arg_idents, blob arg_finger, ref string arg_msg);int rslt = 1
  213. Blob{64} pt ;
  214. // KEY 验证 数据
  215. BlobEdit(pt,1, (8))
  216. BlobEdit(pt,2, (4))
  217. BlobEdit(pt,3, (55))
  218. BlobEdit(pt,4, (27))
  219. BlobEdit(pt,5, (2))
  220. BlobEdit(pt,6, (9))
  221. BlobEdit(pt,7, (33))
  222. BlobEdit(pt,8, (61))
  223. BlobEdit(pt,9, (29))
  224. BlobEdit(pt,10, (50))
  225. BlobEdit(pt,11, (49))
  226. BlobEdit(pt,12, (34))
  227. BlobEdit(pt,13, (29))
  228. BlobEdit(pt,14, (32))
  229. BlobEdit(pt,15, (33))
  230. BlobEdit(pt,16, (30))
  231. BlobEdit(pt,17, (24))
  232. BlobEdit(pt,18, (14))
  233. BlobEdit(pt,19, (168))
  234. BlobEdit(pt,20, (83))
  235. BlobEdit(pt,21, (7))
  236. BlobEdit(pt,22, (27))
  237. BlobEdit(pt,23, (101))
  238. BlobEdit(pt,24, (184))
  239. BlobEdit(pt,25, (90))
  240. BlobEdit(pt,26, (152))
  241. BlobEdit(pt,27, (150))
  242. BlobEdit(pt,28, (103))
  243. BlobEdit(pt,29, (87))
  244. BlobEdit(pt,30, (98))
  245. BlobEdit(pt,31, (100))
  246. BlobEdit(pt,32, (93))
  247. if InitializeFg() <> 1 then
  248. rslt = 0
  249. arg_msg = '指纹API初始化失败'
  250. goto ext
  251. end if
  252. long ret
  253. ret = RemoteVerify(REF arg_idents, ref arg_finger, len(arg_idents))
  254. if ret <= 0 then
  255. rslt = 0
  256. arg_msg = '验证失败' + ',请重试!错误码:' + string(ret)
  257. goto ext
  258. end if
  259. ext:
  260. UnInitializeFg()
  261. return rslt
  262. end function
  263. public subroutine uf_abort ();if ib_reading then
  264. AbortReadDevice()
  265. ib_abort = true
  266. end if
  267. end subroutine
  268. on uo_fingerprint.create
  269. call super::create
  270. TriggerEvent( this, "constructor" )
  271. end on
  272. on uo_fingerprint.destroy
  273. TriggerEvent( this, "destructor" )
  274. call super::destroy
  275. end on