hello,
I am searching for an code who gets the HD Serial Number.
Maybe that it iwll display in a textbox.
I g2g for now, thank you and good bye
Printable View
hello,
I am searching for an code who gets the HD Serial Number.
Maybe that it iwll display in a textbox.
I g2g for now, thank you and good bye
Try sample below:
Detailed Drive Info
It looks like it only returns the volume serial number. This number is changed each time the hd is formatted. I couldnt get the example to run as it has a typeo with the StripNulls but now the image list isnt initialized. Really unexpected code example from that site as its usually very good. No time to see what else is missingwrong. Maybe you have time RB?
I will check it later and post the "fix".
First I wanna say, thanks for the reactions.
S2cnd, I think the Hard Disk has a static serialnumber?
So you have 2 things, the Volume Serial Number(dynamic) and Static Serial Number, how to get the static one?
Account :)
Its the physical HD serial number that is the static number you are referring to. I havent found a solution that actually works but in .NET there is. Have you looked at using WMI for this?
Hope this helps...
http://www.vbforums.com/showthread.php?t=375146
The typo is just an 's'. Either add it to the function or delete it from the function call. (StripNull and StripNulls)Quote:
Originally Posted by RobDog888
Yes, I did mention that but there is still another error with the imagelist not being initialized and I didnt have time to go through it. ;)
I downloaded the http://vbnet.mvps.org/files/projects/windriveinfo.zip base (code bare) Project, and Cut 'n' Pasted the Module and Form Code.
Besides the 's' in the Function Call, I only had 2 other (small) issues. Replace the Command1 with 'cmdLoadAll' (whos Caption is being prematurly changed by the Combo Event - but that can be fixed), and finally, replace the 'Check1' with 'chkExpandNodes'.
You didnt get an Imagelist error?
Other than what was mentioned with Function/Controls names I had no issues - project ran just fine after making those minor changes.
When I read you had that problem, I delibratley used the code bare Project to ensure I had the required Components (ImageList, TreeView etc) (and the fact I'm lazy ;))Quote:
Originally Posted by RobDog888
RB, did you use the downloadable Project aswell?
It must Vista Rob :)
I sure did so it must be tha Vista thing :p - I forgot Rob has it.Quote:
Originally Posted by Bruce Fox
No, I created a new project, added the cmd buttons, lables, and cbo and treeview. Then pasted in the form code, added a module and pasted in the module code.
So the images that were loaded (assumption), TreeView ImageList association at build etc won't be available to you in this case.Quote:
Originally Posted by RobDog888
Nope, but if I add my own it should be all good then.
Bugger!
I just checked the source code and the ImageList is assigned to the TreView at RunTime. So, strike that out.
[hands in the air] It must be Vista [/hands in the air]
No its not lol.
I didnt add any images. Guess I didnt phrase it clearly in my previous post :D
You should also be able to get the physical HD serial number using WMI too. ;)
use follow code :
VB Code:
Option Explicit Private Sub Command1_Click() Label1.Caption = SerNum("C") 'C is the standard harddisk End Sub Public Function SerNum(Drive$) As Long Dim No&, s As String * MAX_FILENAME_LEN Call GetVolumeInformation(Drive + ":\", s, MAX_FILENAME_LEN, _ No, 0&, 0&, s, MAX_FILENAME_LEN) SerNum = No End Function
Doesnt that get the (dynamic) Volume Serial Number?
Yes, it does. This is the info that changes each time you reformat your hd. We want to get the physical hard drive serial number like the manufacturer uses.
see attachment ...
and create Product Key from HDD Serial.
http://www.vbforums.com/showpost.php...5&postcount=11
Note:
This will not get a serial number if the user of the program is logged in as a Limited user; they have to be logged in as an Administrator.
ok that works :)
Now I have other problem:
I have this:
VB Code:
Private Sub Form_Load() Text1 = getHDD If Text1.Text = "AA-ABCD12345678" Then Exit Sub Else MsgBox "Wrong!" Unload Me End If End Sub
I get this error:
I thought everything is ok?Quote:
Else without if
your error is that Exit Sub would need to be on its own line ..
otherwise ...
VB Code:
Private Sub Form_Load() Text1 = getHDD If Not Text1 = "AA-ABCD12345678" Then MsgBox "Wrong!" Unload Me End If End Sub
VB Code:
Private Sub Form_Load() Text1 = getHDD If Text1.Text = "AA-ABCD12345678" Then Exit Sub MsgBox "Wrong!" Unload Me End Sub
Last question, for example:
Your hd address = 1111.2222.3333
Will the program always at start give the same serial number?
So if you use this code:
And you run it on a other computer, it will always say wrong?Code:Private Sub Form_Load()
Text1 = getHDD
If Not Text1 = "AA-ABCD12345678" Then
MsgBox "Wrong!"
Unload Me
End If
End Sub
Actually question = "Will it always give the same serial number on 1 hardware address?"
All HDs have unique hardware serial numbers so if it truely gets the physical SN then it will be unique on every system.
Does this work on every OS? At least from 98 to XP?
Ive only tested it on XP SP1 and SP2
To answer the other question, it is unique to the Hardware, as it uses the Manufacturer's Hard Drive Serial Number. Ive used the Activation code part for over a year and it has never let me down yet. If they reinstall windows, it still works. If they install on another computer, they email me for re-activation.
So yes, if I run that code here, or someone else does, we get "Wrong", as our HDD Serial Number is not equal to that.