hi i ll go straight to the point
the general idea is to
find hasp
1.open hasp
2.send seed that generates the userid (this action takes place in the hasp)
3.close hasp
step 2 is RY2_GenUID function
retcode = call dll(12,"RY2_GenUID",handle,*uid,seed$,0)
it takes handle,uid and seed$ and write protection off
I manage to pass my seed$ to to the function and write the generated uid inside hasps memory all done and is working perfect
the problem is that *uid has the generated userid and i must somehow read it - pass it to a string variable while calling the ry2_genuid
i cant figure out the way....
there is no other function than this to open hasp and read the uid*
i did
global retcode,handle,block_index
global uid as double integer
global urid as double integer
global hid as double integer
global buffer$
global seed$
global ab
global stra$
uid = make memory(64)
hid = make memory(64)
load dll "rockey2.dll",12
retcode = call dll(12,"RY2_Find")
// retcode = RY2_Find()
If retcode < 0
additem gadget1,"NO Find rockey2 : "+Hex$(retcode)
EndIf
If retcode = 0
additem gadget1,"NO Find rockey2 : "+Hex$(retcode)
else
additem gadget1,"Find rockey2 : "+Hex$(retcode)
EndIf
// retcode = RY2_OPEN()
retcode = call dll(12,"RY2_Open",AUTO_MODE, 0, hid)
If retcode < 0
additem gadget1,"CANT OPEN rockey2 "+Hex$(retcode)
Else
additem gadget1,"OPEN OK rockey2 "+Hex$(retcode)
endif
handle=retcode
seed$ = "11111"
retcode = call dll(12,"RY2_GenUID",handle,*uid,seed$,0)
If retcode < 0
additem gadget1,"Gnuid_error "+Hex$(retcode)
Else
additem gadget1,"GunUID OK "+str$(*uid)
EndIf
a=call dll(12,"RY2_Close",handle)
additem gadget1,"closed OK rockey2 "+Hex$(a)
endif
set cursor 10,220
print urid
visual basic example
Declare Function RY2_Find Lib "ROCKEY2.DLL" () As Long
Declare Function RY2_Open Lib "ROCKEY2.DLL" (ByVal mode As Long, ByVal uid As Long, ByRef hid As Long) As Long
Declare Function RY2_GenUID Lib "ROCKEY2.DLL" (ByVal handle As Long, ByRef uid As Long, ByVal seed As Any, ByVal isProtect As Long) As Long
Global Const ROCKEY2_DISABLE_WRITE_PROTECT = 0
Global Const ROCKEY2_ENSABLE_WRITE_PROTECT = 1
Dim retcode, handle, block_index As Integer
Dim uid As Long, hid As Long
Dim buffer As String
Dim seed As String
Dim str As String
Dim curline As Integer
Private Sub Command1_Click()
'Dim retcode, handle, block_index As Integer
'Dim uid As Long, hid As Long
'Dim buffer As String
'Dim seed As String
'Dim str As String
'Dim curline As Integer
'
curline = 0
' generate UID
' There must be one dongle pluging in computer when generating UID,so we don't care the UID and
' HID of it .We only use the first dongle.
retcode = RY2_Find()
If (retcode < 0) Then
'Text1 = Text1 + "No Find rockey2" & vbNewLine
List1.List(curline) = "No Find rockey2 " & Hex(retcode)
curline = curline + 1
End If
If (retcode = 0) Then
'Text1 = Text1 + "No Find rockey2" & vbNewLine
List1.List(curline) = "No find rockey2: " & Hex(retcode)
curline = curline + 1
Exit Sub
Else
'Text1 = Text1 + "find rockey2" & vbNewLine
List1.List(curline) = "Find rockey2 :" & Hex(retcode)
curline = curline + 1
End If
retcode = RY2_Open(AUTO_MODE, 0, hid)
If (retcode < 0) Then
'Text1 = Text1 + "No Open rockey2" & vbNewLine
List1.List(curline) = "No Open rockey2 :" & Hex(retcode)
curline = curline + 1
Exit Sub
Else
'Text1 = Text1 + "Open rockey2" & vbNewLine
List1.List(curline) = "Open rockey2: " & Hex(retcode)
curline = curline + 1
End If
handle = retcode
seed = InputBox("Input,Please input seed :(eg:12345)")
retcode = RY2_GenUID(handle, uid, seed, ROCKEY2_DISABLE_WRITE_PROTECT)
If (retcode < 0) Then
'Text1 = Text1 + "GunUID Error" & vbNewLine
List1.List(curline) = "GunUID Error " & Hex(retcode)
curline = curline + 1
Exit Sub
Else
'Text1 = Text1 + "GunUID OK" & vbNewLine
List1.List(curline) = "GunUID OK :" & (uid)
curline = curline + 1
End If
RY2_Close handle
List1.List(curline) = "You must plug out Rockey2 and re-plug to enable new uid."
curline = curline + 1
End Sub
thanks in advance
all os break