Hi,
I want to convert a vbscript to vb.net
when i turn off Option script and explicit i run into these errors:
Code first:
Error:
'Array' is a type and cannot be used as an expression.
'Array' is a type and cannot be used as an expression.
On lines 18 and 25 respectively.
I tried to declare as in vb.net (maybe i did it wrong cause i don't do much work with arrays...
I want to convert a vbscript to vb.net
when i turn off Option script and explicit i run into these errors:
Code first:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueName = "DigitalProductId"
strComputer = "."
Dim iValues()
oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
oReg.GetBinaryValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, iValues)
Dim arrDPID
arrDPID = Array()
For i = 52 To 66
ReDim Preserve arrDPID(UBound(arrDPID) + 1)
arrDPID(UBound(arrDPID)) = iValues(i)
Next
Dim arrChars As Array
arrChars = Array("B", "C", "D", "F", "G", "H", "J", "K", "M", "P", "Q", "R", "T", "V", "W", "X", "Y", "2", "3", "4", "6", "7", "8", "9")
For i = 24 To 0 Step -1
k = 0
For j = 14 To 0 Step -1
k = k * 256 Xor arrDPID(j)
arrDPID(j) = Int(k / 24)
k = k Mod 24
Next
strProductKey = arrChars(k) & strProductKey
' <------- add the "-" between the groups of 5 Char -------->
If i Mod 5 = 0 And i <> 0 Then strProductKey = "-" & strProductKey
Next
strFinalKey = strProductKey
'
strComputer = "."
objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
strOS = objOperatingSystem.Caption
strBuild = objOperatingSystem.BuildNumber
strSerial = objOperatingSystem.SerialNumber
strRegistered = objOperatingSystem.RegisteredUser
Next
wshShell = CreateObject("wscript.shell")
strPopupMsg = strOS & vbNewLine & vbNewLine
strPopupMsg = strPopupMsg & "Build Number: " & strBuild & vbNewLine
strPopupMsg = strPopupMsg & "PID: " & strSerial & vbNewLine & vbNewLine
strPopupMsg = strPopupMsg & "Registered to: " & strRegistered & vbNewLine & vbNewLine & vbNewLine
strPopupMsg = strPopupMsg & "Your Windows Product Key is:" & vbNewLine & vbNewLine & strFinalKey
strPopupTitle = "Microsoft Windows License Information"
wshShell.Popup(strPopupMsg, , strPopupTitle, vbCancelOnly + vbInformation)
End Sub
Error:
'Array' is a type and cannot be used as an expression.
'Array' is a type and cannot be used as an expression.
On lines 18 and 25 respectively.
I tried to declare as in vb.net (maybe i did it wrong cause i don't do much work with arrays...