FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 2024
→
(WD19) : Reading New Belgian EID March 2014 : Conversion VB.Net to Windev
(WD19) : Reading New Belgian EID March 2014 : Conversion VB.Net to Windev
Débuté par Andy Declerck, 18 fév. 2015 10:44 - 2 réponses
Connectez-vous…
Andy Declerck
#1
Posté le 18 février 2015 - 10:44
Since there is a new version of the Belgian EID, it is more difficult to read the EID.
I have found the VB.Net code and wanted to convert it to Windev code.
When I try to run the procedure he gives an error.
Original VB Code
PUBLIC FUNCTION
GetData
(
ByVal label As
string
)
Dim m As Net.Sf.Pkcs11.Module
=
Nothing
Dim valueb As
byte
(
)
Dim value As
string
=
""
Dim labelchar As
string
=
""
Dim mFileName As
string
=
"beidpkcs11.dll"
Dim slotlist
(
)
As Net.Sf.Pkcs11.Slot
Try
m
=
Net.Sf.Pkcs11.Module.GetInstance
(
mFileName
)
slotlist
=
m.GetSlotList
(
True
)
IF
(
slotlist.Length
>
0
)
THEN
Dim session As Net.Sf.Pkcs11.Session
Dim slot As Net.Sf.Pkcs11.Slot
slot
=
slotlist
(
0
)
session
=
slot.Token.OpenSession
(
True
)
Dim classAttribute As
new
ByteArrayAttribute
(
Net.Sf.Pkcs11.Wrapper.CKO.DATA
)
classAttribute.Value
=
BitConverter.GetBytes
(
Convert.ToUInt32
(
Net.Sf.Pkcs11.Wrapper.CKO.DATA
)
)
Dim labelAttribute As
new
ByteArrayAttribute
(
Net.Sf.Pkcs11.Wrapper.CKA.LABEL
)
labelAttribute.Value
=
System.Text.Encoding.UTF8.GetBytes
(
label
)
Dim p11a
(
)
As P11Attribute
= {
classAttribute
,
labelAttribute
}
session.FindObjectsInit
(
p11a
)
Dim foundObjects
(
)
As P11Object
=
session.FindObjects
(
50
)
Dim counter As Integer
=
foundObjects.Length
Dim
Data
As
new Data
WHILE
(
counter
>
0
)
Data
=
foundObjects
(
counter
-
1
)
IF
Not
Data
.
Label.Value
=
Nothing
THEN
IF
Not label
=
"PHOTO_FILE"
THEN
value
=
System.Text.Encoding.UTF8.GetString
(
Data
.
Value.Value
)
ELSE
valueb
=
Data
.
Value.Value
END IF
System.Diagnostics.Trace.WriteLine
(
"mijne label: "
+
value
)
END IF
counter
=
counter
-
1
END WHILE
IF
Not label
=
"PHOTO_FILE"
THEN
RETURN
value
ELSE
RETURN
valueb
END IF
session.FindObjectsFinal
(
)
ELSE
'
MsgBox
(
"no card found"
)
RETURN
"nocard"
END IF
Catch ex As
EXCEPTION
MsgBox
(
ex.Message
)
Finally
m.Dispose
(
)
END
Try
END FUNCTION
Translated to WINDEV
Procedure
GetData
(
label
)
m is
"Net.Sf.Pkcs11.Module"
dynamic
valueb is
array of byte
value is
string
=
""
s
Labelchar is
string
=
""
mFileName is
string
=
"beidpkcs11.dll"
slotlist is
array of
Net.Sf.Pkcs11.Slot
(
)
m
=
new
"Net.Sf.Pkcs11.Module.GetInstance"
(
mFileName
)
*
*
*
Error
IN
EXECUTION AT THIS LINE
*
*
*
slotlist
=
m.GetSlotList
(
True
)
IF
ArrayCount
(
slotlist
) >
0
THEN
session is
"Net.Sf.Pkcs11.Session"
dynamic
slot is
"Net.Sf.Pkcs11.Slot"
dynamic
slot
=
slotlist
[
0
]
session
=
slot.Token.OpenSession
(
True
)
classAttribute is ByteArrayAttribute
(
Net.Sf.Pkcs11.Wrapper.CKO.DATA
)
dynamic
classAttribute.Value
=
BitConverter.GetBytes
(
Convert.ToUInt32
(
"Net.Sf.Pkcs11.Wrapper.CKO.DATA"
)
)
labelattribute is ByteArrayAttribute
(
Net.Sf.Pkcs11.Wrapper.CKA.LABEL
)
dynamic
labelattribute.Value
=
System.Text.Encoding.UTF8.GetBytes
(
label
)
p11a is
array of
P11Attribute
(
classAttribute
,
labelattribute
)
session.FindObjectsInit
(
p11a
)
Foundobjects is
array of
P11Object
Foundobjects
=
session.FindObjects
(
50
)
Counter is
int
=
ArrayCount
(
Foundobjects
)
objdata is Net.Sf.Pkcs11.objects.Data dynamic
WHILE
Counter
>
0
objdata
=
Foundobjects
[
Counter
-
1
]
IF
NOT objdata.Label.Value
=
Null
THEN
IF
NOT label
=
"PHOTO_FILE"
THEN
value
=
System.Text.Encoding.UTF8.GetString
(
objdata.Value.Value
)
ELSE
valueb
=
objdata.Value.Value
END
END
Counter
--
END
session.FindObjectsFinal
(
)
IF
NOT label
=
"PHOTO_FILE"
THEN
m.Dispose
(
)
RESULT
value
ELSE
m.Dispose
(
)
RESULT
valueb
END
ELSE
m.Dispose
(
)
RESULT
"nocard"
END
While running the procedure he gives an error on this line of code :
m = new "Net.Sf.Pkcs11.Module.GetInstance"(mFileName)
ERROR CODE 0: Level: no error
Does someone has any ideas on how to solve this ?
Signaler
0
0
mike
#2
Posté le 25 mars 2020 - 08:56
Managed to solve this error? I'm looking for a way to read the eid aswell.
Signaler
0
0
mike
#3
Posté le 25 mars 2020 - 08:56
Managed to solve this error? I'm looking for a way to read the eid aswell.
Signaler
0
0
→ Revenir à WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte