求大神帮转换VBScript

自由de风 发布于 2015/02/02 17:27
阅读 426
收藏 0
Dim f1, f2, dirname
f1 = "0123456789ABCDEF"
f2 = "0123456789ABCDEF"
dirname = "ASP_DEMO"

dim results
Dim FileLen, DBU, DBP

dim tbuffer
tbuffer = "0123456789ABCDEF0123456789ABCDEF"

dim bErr
sub ShowErr(Msg)
	bErr = true
	MsgBox Msg
End Sub
function Init()
		On Error Resume Next
		Dim TheForm
		Set TheForm = Document.forms("InitInfoForm")
	
		'If Len(TheForm.DBSOPIN.Value) = 0 Then
		'	MsgBox "输入不能为空!"	
		'	TheForm.DBSOPIN.focus 
		'	Init = false
		'	Exit function
		'End If
		
		If Len(TheForm.SOPIN.Value) = 0 Then
			MsgBox "输入不能为空!"
			TheForm.SOPIN.focus 	 
			Init = false
			Exit function
		End If
	
		If Len(TheForm.USERNAME.Value) = 0 Then
			MsgBox "输入不能为空!"
			TheForm.USERNAME.focus	 
			Init = false
			Exit function
		End If
	
		If Len(TheForm.USERKEY.Value) = 0 Then
			MsgBox "输入不能为空!"
			TheForm.USERKEY.focus	 
			Init = false
			Exit function
		End If
		
			
		''''''初始化打开的设备'''''''''''''''''''''''''
		ePass.OpenDevice 1, ""
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "打开初始设备失败!"
			Init = false
			Exit function
		End If
	
		'results = "01234567890123456"
		'results = ePass.GetStrProperty(7, 0, 0)
		'msgbox results

		'验证SOPIN
		ePass.VerifyPIN 1, TheForm.SOPIN.Value
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "验证初始设备SOPIN失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If
		
		'更改USER PIN为1234
		ePass.ChangeCode 1,TheForm.SOPIN.Value,"1234"
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "修改USER PIN失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If

	
		'初始化
		ePass.SetProperty &H0A,0,0,0
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "清空初始设备失败!"
			Init = false
			ePass.CloseDevice
			Exit function		
		End If

		'创建目录
		ePass.CreateDir 0,dirname, 0, &Hff
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If


		'得到KEY文件1
		ePass.Soft_MD5HMAC 0,0,TheForm.USERKEY.Value,f1
		'f1 = Soft_MD5Hash("1234")
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If


		'得到KEY文件2
		ePass.Soft_MD5HMAC 1,0,TheForm.USERKEY.Value,f2
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If


		'创建文件1
		'第1个参数没有,要设为0
		'第2个参数为文件ID
   	'第3个参数为文件的长度
   	'第4个参数为文件类型,EPAS_FILETYPE_DATA为2
   	'第5个参数为读取权限,EPAS_ACCESS_ANYONE为0
   	'第6个参数为写入权限,EPAS_ACCESS_ANYONE为0
   	'第7个参数为加密计算权限,数据文件没计算权限,EPAS_ACCESS_NONE为7
   	'第8个参数为默认权限,EPAS_ACCESS_WRITE为2
		ePass.CreateFile 0,1,16,4,7,2,1,2 
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中创建文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If

		ePass.Write 1,0,0,f1,16
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中写文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If

		ePass.CloseFile
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中关闭文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If

		'创建文件2
		ePass.CreateFile 0,2,16,4,7,2,1,2
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中创建文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If
	
		ePass.Write 1,0,0,f2,16
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中写文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If
	
		ePass.CloseFile
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中关闭文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If

		'创建文件3,用户文件
		ePass.CreateFile 0,3,Len(TheForm.USERNAME.Value),2,0,0,7,2
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中创建文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If
	  
		ePass.Write 0,0,0,TheForm.USERNAME.Value,Len(TheForm.USERNAME.Value)
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中写文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If
	
		ePass.CloseFile
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "初始化过程中关闭文件失败!"
			Init = false
			ePass.CloseDevice
			Exit function
		End If	
	
	
		ePass.CloseDevice
		If Err Then
			'MsgBox hex(err.number)
			ShowErr "关闭初始设备失败!"
			Init = false
			Exit function
		End if
		
		MsgBox "初始成功"
		
		DBUser.innerHTML = "<input type='hidden' name='DBUser' Value='" & DBU & "'>"
		DBPass.innerHTML = "<input type='hidden' name='DBPass' Value='" & DBP & "'>"
				
	End function

这段是VBScript,不太懂写的什么,求大神帮忙转换成 javascript的格式 



加载中
0
北上广深
北上广深
求大神帮忙转换成C++的格式
自由de风
自由de风
别闹...
0
紅顏為君笑
紅顏為君笑
Windows脚本技术.CHM 你值得拥有
返回顶部
顶部