im HexBuf As Object = My.Computer.Registry.GetValue(KeyPath, ValueName, 0) If HexBuf Is Nothing Then Return "N/A" Dim tmp As String = "" For l As Integer = LBound(HexBuf) To UBound(HexBuf) tmp = tmp & " " & Hex(HexBuf(l)) Next Dim StartOffset As Integer = 52 Dim EndOffset As Integer = 67 Dim Digits(24) As String Digits(0) = "B" : Digits(1) = "C" : Digits(2) = "D" : Digits(3) = "F" Digits(4) = "G" : Digits(5) = "H" : Digits(6) = "J" : Digits(7) = "K" Digits(8) = "M" : Digits(9) = "P" : Digits(10) = "Q" : Digits(11) = "R" Digits(12) = "T" : Digits(13) = "V" : Digits(14) = "W" : Digits(15) = "X" Digits(16) = "Y" : Digits(17) = "2" : Digits(18) = "3" : Digits(19) = "4" Digits(20) = "6" : Digits(21) = "7" : Digits(22) = "8" : Digits(23) = "9" Dim dLen As Integer = 29 Dim sLen As Integer = 15 Dim HexDigitalPID(15) As String Dim Des(30) As String Dim tmp2 As String = "" For i = StartOffset To EndOffset HexDigitalPID(i - StartOffset) = HexBuf(i) tmp2 = tmp2 & " " & Hex(HexDigitalPID(i - StartOffset)) Next Dim KEYSTRING As String = "" For i As Integer = dLen - 1 To 0 Step -1 If ((i + 1) Mod 6) = 0 Then Des(i) = "-" KEYSTRING = KEYSTRING & "-" Else Dim HN As Integer = 0 For N As Integer = (sLen - 1) To 0 Step -1 Dim Value As Integer = ((HN * 2 ^ 8) Or HexDigitalPID(N)) HexDigitalPID(N) = Value \ 24 HN = (Value Mod 24) Next Des(i) = Digits(HN) KEYSTRING = KEYSTRING & Digits(HN) End If Next Return StrReverse(KEYSTRING) End Function
Trying To Get Windows Product Key
Page 1 of 19 Replies - 7651 Views - Last Post: 30 June 2013 - 11:53 AM
#1
Trying To Get Windows Product Key
Posted 25 August 2012 - 02:10 PM
I am trying to get Windows Product Key for an app that gets general computer information for computer technicians who are working remotely or locally for any size corporation. I found this code online but have run into a snag. When I try and run it the hex buffer on the first loop in the code below states that I cannot cast an integer to an array. Any ideas on how to fix this given the code or is there a better way of getting the Windows Product Key? Thank you!
Replies To: Trying To Get Windows Product Key
#2
Re: Trying To Get Windows Product Key
Posted 25 August 2012 - 03:05 PM
Quote
I cannot cast an integer to an array.
You can't. Do you know what an array is? Its a COLLECTION of some type.
So you can't cast an int to an array, but you could store an individual int in one element of an int[]
In other words
int[] anIntegerArray = 5; // Doesn't make sense. anIntegerArray[4] = 5; // Makes sense. Element 4 of the array can be set equal to the value 5
This post has been edited by tlhIn`toq: 25 August 2012 - 03:05 PM
#3
Re: Trying To Get Windows Product Key
Posted 25 August 2012 - 03:26 PM
tlhIn`toq, on 25 August 2012 - 03:05 PM, said:
Quote
I cannot cast an integer to an array.
You can't. Do you know what an array is? Its a COLLECTION of some type.
So you can't cast an int to an array, but you could store an individual int in one element of an int[]
In other words
int[] anIntegerArray = 5; // Doesn't make sense. anIntegerArray[4] = 5; // Makes sense. Element 4 of the array can be set equal to the value 5
Can you apply that to my code and show me how it works? I am interested in learning but I am not sure how to apply the code to the code I found. Thanks!
#4
Re: Trying To Get Windows Product Key
Posted 25 August 2012 - 03:27 PM
No. It's your job to put in the effort to fix your code based on the suggestions given.
#5
Re: Trying To Get Windows Product Key
Posted 25 August 2012 - 03:47 PM
If you are THAT unfamiliar then you are jumping into the designing and building of your own application from scratch, WAY too early.
First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover. Do a couple hundred on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.
Then later you can start architecting your own simple stuff. Build a calculator. Build a DVD library program. Etc. Stuff that doesn't involve the complexity of a game. Then move up to games.
There are three routes people seem to take when learning programming.
For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.
You start by learning a coding language FIRST.
Learn to plan before you type.
THEN you start designing software with a purpose.
If this sounds like you
read this section
Otherwise, you can just jump to the resources here:
Some of the tutorials below are for C# or Java not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.
Resources, references and suggestions for new programmers. - Updated Mar 2012
First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover. Do a couple hundred on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.
Then later you can start architecting your own simple stuff. Build a calculator. Build a DVD library program. Etc. Stuff that doesn't involve the complexity of a game. Then move up to games.
There are three routes people seem to take when learning programming.
- Just start trying to create programs
- Start taking apart other programs and try to figure out the language by reverse engineering
- Follow a guided learning course (school or self-teaching books)
For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.
Quote
Where do I start?
You start by learning a coding language FIRST.
Learn to plan before you type.
THEN you start designing software with a purpose.
If this sounds like you
Newbie/Rookie said:
I have a little programming experience but I need to write ...
Spoiler
Otherwise, you can just jump to the resources here:
Some of the tutorials below are for C# or Java not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.
Resources, references and suggestions for new programmers. - Updated Mar 2012
Spoiler
#7
Re: Trying To Get Windows Product Key
Posted 30 August 2012 - 02:16 AM
lol.. the original poster had this in vb.. now hes going c# as per suggestion...
#8
Re: Trying To Get Windows Product Key
Posted 30 August 2012 - 05:15 AM
Thank you for all the suggestions. I do realize that having a structured learning environment is really helpful. I am currently going for my associate's degree in programming. It is not that I do not understand an array and how an array works, however, I was not sure how to fix the issue at hand. I found the code online for pulling a MS Product Key and noticed when I moved it to the IDE it was broken. I did not develop the code from scratch and therefore was not sure how to fix it. Visual Studio is notorious for giving minimal details on why something in the debugger is broken and you have to go on a rabbit trail sometimes to get to the real issue.
By the way, I do not have a problem with approaches 1 & 2 as well as 3. I have done all of them and they all have proven useful. You gain structural knowledge of programming through a school or book - however you gain a passion for programming because that is what you want to do and that is where I found myself.
By the way, I do not have a problem with approaches 1 & 2 as well as 3. I have done all of them and they all have proven useful. You gain structural knowledge of programming through a school or book - however you gain a passion for programming because that is what you want to do and that is where I found myself.
#9
Re: Trying To Get Windows Product Key
Posted 30 August 2012 - 07:20 AM
kyle_denney, on 30 August 2012 - 06:15 AM, said:
I am currently going for my associate's degree in programming. It is not that I do not understand an array and how an array works, however, I was not sure how to fix the issue at hand.
That you are *going for* your degree is one thing. But it doesn't tell us how far you have already gone. It sounds nice, but means little. For all we know you could be on your third day of going for that degree which means you know next to nothing.
You say you understand what an array is and how it works... yet you couldn't figure out how to fix your code when you were trying to shove something other than an array into an array. Let me put it in non-coding terms. You had an engine and you were trying to state that it was a truck. That wouldn't work, would it. An engine is only PART of a truck.
Quote
Visual Studio is notorious for giving minimal details on why something in the debugger is broken and you have to go on a rabbit trail sometimes to get to the real issue.
Really? Notorious amongst whom? Your fellow first year students? Because I find it tells you exactly what is wrong. It doesn't stand up and give a lecture about why and put it into context for you with an explanation about the 25 lines of code around it. It doesn't tell telepathically intuit what you MEANT and tell you how to fix it based on your INTENT. But it does tell you exactly what the error is. And in this case it did tell you the exact problem, stopped on the offending line and said "cannot cast an integer to an array". If you don't know how to use the IDE and don't know how to look at the values in the Autos and Locals pallet, you can't blame Visual Studio. If you look at the offending line and see that one value is an integer, one is an array... look at the error... use the knowledge you have about arrays... it should be fairly clear.
Perhaps you should stop coding for an hour and work these tutorials on debugging. An hour of learning will save hundreds in frustration.
FAQ (Frequently Asked Questions - Updated July 2012
- Q: I do x and y happens which I didn't expect but I don't know how to figure out why. How do I debug and find my problem?
A:- Debugging video 1: Breakpoints and Local variables
- Debugging video 2: Advanced breakpoints
- Debugging tutorial
- Debugging tips
- Debugging in detail
- Great debugging tips
- It still doesn't work, article
- Debugging tools survival guide
- Video: Tips & Tricks to use Visual Studio to the fullest
- 5 return dataset.Tables[tableName].Columns.Count;
A condensed line like this makes a lot of assuptions that everything goes right, and gives you nothing to check or debug.
If only for R&D / Debug purposes it can often be advantagous to break down the line
if (dataset != null) { if (datase.Tables != null) { if (!string.IsNullOrWhiteSpace(tableName) { if (dataset.Tables[tableName].Columns != null)
Now you can put a breakpoint on the top line and walk through it with F10 and check every object. You also don't try to manipulate a thing that doesn't yet exist.
- Debugging video 1: Breakpoints and Local variables
#10
Re: Trying To Get Windows Product Key
Posted 30 June 2013 - 11:53 AM
Does anyone know how to get the WIndows 8 product key? The digitalproductid in the registry no longer exists for Windows 8.
This post has been edited by JackOfAllTrades: 30 June 2013 - 12:23 PM
Reason for edit:: Removed unnecessary quote
Page 1 of 1