Page 1 of 2 12 LastLast
Results 1 to 40 of 49

Thread: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

  1. #1

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Arrow How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    I want to give my app for trial version.. therefore for this purpose
    How can i know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc.
    Plz Help.....

  2. #2
    Fanatic Member bgmacaw's Avatar
    Join Date
    Mar 2007
    Location
    Atlanta, GA USA
    Posts
    524

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    You can't because there is no standard way that hardware companies provide this information. What you would need to do is work out a hardware detection algorithm similar to what Windows XP does.

  3. #3

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Unhappy Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by bgmacaw
    You can't because there is no standard way that hardware companies provide this information. What you would need to do is work out a hardware detection algorithm similar to what Windows XP does.

    hmm...
    then you know what is standard way to distribute application for trial versions..
    if i give disk serial no or other id for this purpose then it will be change when going to system formating..
    ...and also i think every thing which store in storage disk or boot sector; it can be change by experts.. No??

  4. #4
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Actually you can (some dont provide the serial numbers, havent come across any that have not yet though), I have the code here for the hard drive firmware serial number (not the volume serial number), works in Limited user mode in XP and in Vista, but it is very detailed and there is more to creating a trial version and or activation then just getting the hardware ID. Also, you cannot depend on just the hard drive serial number, also to the other member, yes MS will use the Hard Drive serial number (if available) along with other hardware.

    Here is an older method though, but you dont get the number if the user is logged on as a Limited User:
    http://www.vbforums.com/showpost.php...3&postcount=23

    Unless you are willing to spend a couple months putting something together, you may want to take a look at a Trial Creator program or something else, see this thread. http://www.vbforums.com/showpost.php?p=3025904


    Anyway here is the Motherboard Serial and Bios ID using WMI, I wont post the hard drive code though as well it is too much, I didnt write it, and I really dont want to take it out of my project right now (maybe another time). Like I said though getting the serial numbers etc is the easy part, there is alot more involved with activations etc. Check out the software link in the thread I posted above, it tested it last night and it works, and its free.

    Code:
    Public Function GetBiosVersion() As String
       Dim strComputerName As String
       Dim objWMIService As Object
       Dim colItems As Object
       Dim objItem As Object
       On Local Error Resume Next
       strComputerName = Space(255)
       GetComputerName strComputerName, 255
       strComputerName = Left(strComputerName, InStr(1, strComputerName, Chr(0)) - 1)
       Set objWMIService = GetObject("winmgmts:\\" & strComputerName)
       Set colItems = objWMIService.ExecQuery("Select SerialNumber from Win32_BIOS", , 48)
       For Each objItem In colItems
           GetBiosVersion = objItem.SerialNumber
       Next
       Set colItems = Nothing
       Set objWMIService = Nothing
    End Function
    
    Public Function GetMoboNumber() As String
       Dim strComputerName As String
       Dim objWMIService As Object
       Dim colItems As Object
       Dim objItem As Object
       On Local Error Resume Next
       strComputerName = Space(255)
       GetComputerName strComputerName, 255
       strComputerName = Left(strComputerName, InStr(1, strComputerName, Chr(0)) - 1)
       Set objWMIService = GetObject("winmgmts:\\" & strComputerName)
       Set colItems = objWMIService.ExecQuery("SELECT SerialNumber FROM Win32_BaseBoard", , 48)
       For Each objItem In colItems
           GetMoboNumber = objItem.SerialNumber
       Next objItem
       Set colItems = Nothing
       Set objWMIService = Nothing
    End Function
    Last edited by rory; Oct 11th, 2007 at 01:15 AM.

  5. #5

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Angry Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by rory
    Actually you can (some dont provide the serial numbers, havent come across any that have not yet though), I have the code here for the hard drive firmware serial number (not the volume serial number), works in Limited user mode in XP and in Vista, but it is very detailed and there is more to creating a trial version and or activation then just getting the hardware ID. Also, you cannot depend on just the hard drive serial number, also to the other member, yes MS will use the Hard Drive serial number (if available) along with other hardware.

    Here is an older method though, but you dont get the number if the user is logged on as a Limited User:
    http://www.vbforums.com/showpost.php...3&postcount=23

    Unless you are willing to spend a couple months putting something together, you may want to take a look at a Trial Creator program or something else, see this thread. http://www.vbforums.com/showpost.php?p=3025904


    Anyway here is the Motherboard Serial and Bios ID using WMI, I wont post the hard drive code though as well it is too much, I didnt write it, and I really dont want to take it out of my project right now (maybe another time). Like I said though getting the serial numbers etc is the easy part, there is alot more involved with activations etc. Check out the software link in the thread I posted above, it tested it last night and it works, and its free.

    Code:
    ...
    i run your code... it execute properly but can not fetches any id...??

  6. #6
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    How did you run it?

  7. #7

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by rory
    How did you run it?
    i copy and paste your code in new vb form and also paste code of ..
    "Private Declare Function GetComputerName Lib "KERNEL32" _
    Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long"

    and then i give this..

    Private Sub Form_click()
    MsgBox Me.GetMoboNumber
    MsgBox Me.GetBiosVersion
    End Sub

    (FOR REMMEMBER I USE WINDOW XP)

  8. #8
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by nilesh16782
    i copy and paste your code in new vb form and also paste code of ..
    "Private Declare Function GetComputerName Lib "KERNEL32" _
    Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long"

    and then i give this..

    Private Sub Form_click()
    MsgBox Me.GetMoboNumber
    MsgBox Me.GetBiosVersion
    End Sub

    (FOR REMMEMBER I USE WINDOW XP)

    Remove the GetComputerName API Declaration, you dont need it in this case.

  9. #9

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    i m trid Your GetHDDSerialNumber.zip it works well...(thanks)
    In this i want to know..

    Is HDD Serial Number changable or not??
    and it is relaible to create programs of trial versions..??

  10. #10
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Its an old version, it will work but it 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 Admin. There is other code out there though that does get the serial number when in either Limited or Admin mode, I just cant post it right now.

  11. #11

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by rory
    Its an old version, it will work but it 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 Admin. There is other code out there though that does get the serial number when in either Limited or Admin mode, I just cant post it right now.
    Then i think it not sutable to use this code for create a trial version program to distribute world wide( where i not know user which system and O/S use.. )

    ok please can you tell me....
    Is HDD Serial Number changable or not??
    and it is relaible(your program to know HDD Serial No. and generate key...) to create programs of trial versions..??

  12. #12
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by nilesh16782
    Then i think it not sutable to use this code for create a trial version program to distribute world wide( where i not know user which system and O/S use.. )
    Free software that will do it for you. I tried to see how they do it but I gave up after an hour or so. So it works pretty good.
    http://www.softwarekey.com/swk_products/trial_creator/

    Open source project:
    http://activelocksoftware.com/

    I use activation in one of my programs also, i use the HDD one you tried, but changing it to another method when I get some free time, though I also use the Bios ID and the Motherboard serial, as well as the user name. It can use all of them, but it has to have at least the HDD serial, or, the Bios ID and the Motherboard Serial, without either of those 2 groups it will not activate. It also uses the User's name, which must be entered in a text box. Using all that, it is all encrypted and encoded then a Serial Key is created out of that. The activation code is based on the same idea. They send me the Serial Key and I send them back an Activation Code. The program then does its thing and checks if it is valid.

    Its pretty straight forward, keeps everything else encrypted using Rijndael in a data file. Ofcourse like anything it is crackable. You need to also put jumps all over the place, dont name things how you normally would (least with the activation part of it), write down your design so you will be able to go back to it and understand it, as you want to make it as hard to understand as possible. In other words just dont say "If this = that then Activated" as that will be hacked in no time.

    Im no expert in this though, Ive also used KeyLok for another app I did, and honestly when I start to get more sales i will fork out the money to buy a solution for this program, one that is ready made, as my time is better spent working on what I do best, and letting the companies that do this type of thing 24/7 deal with that part of it. Its just something to make it more difficult to hack for now

  13. #13
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by nilesh16782
    ok please can you tell me....
    Is HDD Serial Number changable or not??
    and it is relaible(your program to know HDD Serial No. and generate key...) to create programs of trial versions..??
    See post above.
    That is the hard drive's firmware number, far as I know you cant change that.

  14. #14

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Thumbs up Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    ok..
    LOT of THANKS for your LOOOOOOOOOOOOOOOT of help.....


  15. #15
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Ok see attached to get the HDD serial number using the old and the new method. I also added in the Bios and Motherboard numbers (uses WMI) as well as the Bios Version. This will get everything whether or not the user is in Admin or Limited user modes.

    There are other things you can get like MAC address, IP, DNS, etc, but those can be changed, or they do change; so I don't use them.

    Ideally you would put this all in a single class module, but for now I left it as 3 separate modules (plus the declarations module).

    Good luck!

    Ps. Original Developers Copyrights and Disclaimers, and other sources, are included where they are required.

    Note. WMI can take a few milliseconds to initiate the first time it has been run since Windows Startup; WMI is only used for the motherboard info. Also, not 100% certain whether either HDD method works with SMART disabled, perhaps someone can confirm that, my current bios does not allow disabling it.
    Last edited by rory; Oct 12th, 2007 at 08:06 AM.

  16. #16
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    I use the PC's NIC for trial coding.
    Check the link below...Get MAC

  17. #17
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Yeah but you can change the mac.
    Also, using that code in your sig, my mac is: 00-00-00-00-00-00
    I also originally had the mac as an option in my activation but had to take it out.

  18. #18

    Thread Starter
    Lively Member nilesh16782's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    104

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    OK What you think about this code....
    This code return HDD SNO. ..

    IS IT RELIABLE???

    Code:
    Private Sub Form_Load()
        Dim fs, d, s, t
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName("C:\")))
        Select Case d.DriveType
            Case 0: t = "Unknown"
            Case 1: t = "Removable"
            Case 2: t = "Fixed"
            Case 3: t = "Network"
            Case 4: t = "CD-ROM"
            Case 5: t = "RAM Disk"
        End Select
        s = "Drive " & d.DriveLetter & ": - " & t
        s = s & vbCrLf & "SN: " & d.SerialNumber
        MsgBox s
    End Sub

  19. #19
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    No, that is not the firmware serial number.

  20. #20
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    rory, if the whole reason is to make sure only steals or moves your trial version, then check several PC values, NIC, HDD, amount of memory, speed, a value stored on the disk, in the reg...etc
    If any one of these change, ..........

  21. #21
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Yes, please see my attached file above, which does just that, and my other posts on how I handle the actual activation.

  22. #22
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    hello i just used rory's code for bios and mobo number and the bios one works ok but when i run the mobo one:

    Private Sub Command1_Click()
    Text1.Text = GetMoboNumber()
    End Sub

    it waits for a while then says "none" in the textbox

  23. #23
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by killo
    hello i just used rory's code for bios and mobo number and the bios one works ok but when i run the mobo one:

    Private Sub Command1_Click()
    Text1.Text = GetMoboNumber()
    End Sub

    it waits for a while then says "none" in the textbox
    Not all mobo's will return a serial number. What mobo do you have; brand and model number? Also what OS are you using?

    Also, add Exit For in the For Next loop to see if that ends it quicker, and please let us know, thanks.

    Code:
    'get bios id, bios serial, and mobo serial with WMI
    Public Function GetMotherboard() As Boolean
        
    On Error GoTo Error_Handler
    
        Dim strComputerName As String
        Dim objWMIService As Object
        Dim colItems As Object
        Dim objItem As Object
        
        strComputerName = Space$(255)
        GetComputerName strComputerName, 255
        strComputerName = Left$(strComputerName, InStr(1, strComputerName, Chr(0)) - 1)
        Set objWMIService = GetObject("winmgmts:\\" & strComputerName)
        
        Set colItems = objWMIService.ExecQuery("Select Version, SerialNumber from Win32_BIOS", , 48)
        For Each objItem In colItems
            BiosVersion = UCase(Replace(objItem.Version, " ", ""))
            BiosSerial = objItem.SerialNumber
            Exit For
        Next objItem
    
        Set colItems = objWMIService.ExecQuery("Select SerialNumber from Win32_BaseBoard", , 48)
        For Each objItem In colItems
            MoboSerial = objItem.SerialNumber
            Exit For
        Next objItem
        
        GetMotherboard = True
        
    Error_Handler:
        Set colItems = Nothing
        Set objWMIService = Nothing
        
    End Function
    Last edited by rory; Oct 22nd, 2007 at 03:20 PM.

  24. #24
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    ok i tried that but it still doesn't work. it does end it quicker but still says "none" in the textbox heres the code i'm using:

    Code:
    'get bios id, bios serial, and mobo serial with WMI
    Option Explicit
    Private Declare Function GetComputerName Lib "KERNEL32" _
    Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    Dim strComputerName As String
        Dim objWMIService As Object
        Dim colItems As Object
        Dim objItem As Object
       Dim biosversion As String
       Dim biosserial As String
       Dim moboserial As String
        
    Public Function GetMotherboard() As Boolean
        
    On Error GoTo Error_Handler
    
        
        strComputerName = Space$(255)
        GetComputerName strComputerName, 255
        strComputerName = Left$(strComputerName, InStr(1, strComputerName, Chr(0)) - 1)
        Set objWMIService = GetObject("winmgmts:\\" & strComputerName)
        
        Set colItems = objWMIService.ExecQuery("Select Version, SerialNumber from Win32_BIOS", , 48)
        For Each objItem In colItems
            biosversion = UCase(Replace(objItem.Version, " ", ""))
            biosserial = objItem.SerialNumber
            Exit For
        Next objItem
    
        Set colItems = objWMIService.ExecQuery("Select SerialNumber from Win32_BaseBoard", , 48)
        For Each objItem In colItems
            moboserial = objItem.SerialNumber
            Exit For
        Next objItem
        
        GetMotherboard = True
        
    Error_Handler:
        Set colItems = Nothing
        Set objWMIService = Nothing
        
    End Function
    
    
    Private Sub Command1_Click()
     Call GetMotherboard
    
    Text1.Text = moboserial
    End Sub
    
    Private Sub Command2_Click()
     Call GetMotherboard
    Text2.Text = biosserial & vbCrLf & biosversion
    End Sub
    however the bios serial and bios version works fine,
    also, if the user upgraded their bios firmware, then would the bios serial or bios version change?
    I'm unning windows xp, i am not on a limited account and i dont know my motherboard manufacturer
    Last edited by killo; Dec 1st, 2007 at 05:22 AM.

  25. #25
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    can anyone help me with this as i would like to use it in a program registration scheme, maybe the user clicks register and my program gives them their motherboard or bios serial no. and then I SHA1 hash it and encrypt it a few times and send it back then my program veirifies it

  26. #26
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by rory View Post
    Remove the GetComputerName API Declaration, you dont need it in this case.
    Hi Rory
    Although I am too late to this post I feel it is very useful for me.
    However If I remove the GetComputName API Declatartion i get a compile error saying Sub or function not defined highligting (GetComputerName strComputerName, 255)
    If use that API declaration I see GetBiosVersion works fine and GetMoboNumber as blank

    Nasreen

  27. #27
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by nasreen View Post
    However If I remove the GetComputName API Declatartion i get a compile error saying Sub or function not defined highligting (GetComputerName strComputerName, 255)
    For the local PC I believe you can just use "." for the ComputerName,

    strComputerName = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputerName)

  28. #28
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Id say avoid using WMI, because if im not wrong, its only included in WinXp & above...
    unless thats the targes OS you're aiming...

    Use API's to get infos about the pc and the regedit has plenty of info for you to use...
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  29. #29
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Hi some1uk03

    Quote Originally Posted by some1uk03 View Post
    Id say avoid using WMI, because if im not wrong, its only included in WinXp & above...
    unless thats the targes OS you're aiming...

    Use API's to get infos about the pc and the regedit has plenty of info for you to use...
    Can you please give more idea with example how to capture PC infos using API

    Nasreen

  30. #30
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    355

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    The code provided with old and new method does not work on Vista and Windows 7

  31. #31
    New Member
    Join Date
    Mar 2009
    Posts
    11

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    @roy, please share your code to get MFG's HDD Serial in both Administrator and Limited user mode (without using WMI Services cause I actually don't want to add one more scripting library in my apps, just plain api code only)

    Thanks!

  32. #32
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    limited user can't get hdd serial number using api

    if you don't want to use wmi, no solution for limited user
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  33. #33
    New Member
    Join Date
    Mar 2009
    Posts
    11

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    According to Randy Birch: The drive code will only work for SMART drives; not older plain IDE drives

    Original code here: http://vbnet.mvps.org/code/disk/smartide.htm

  34. #34
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by hai2hai View Post
    According to Randy Birch: The drive code will only work for SMART drives; not older plain IDE drives

    Original code here: http://vbnet.mvps.org/code/disk/smartide.htm
    It will still work for IDE drives with SMART enabled as I was using an old 6 or 7 year old IDE hard drive when i first tested this code, and the second harddrive serial code included in the project above is totally different code from the link you posted, and is also API but as mentioned does not work in limited mode.

  35. #35
    New Member
    Join Date
    Mar 2009
    Posts
    11

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by Deliriumxx View Post
    The code provided with old and new method does not work on Vista and Windows 7
    @roy: As Deliriumxx said in above post and also I test roy's code (using API then WMI) in vista/windows7 (w/o Run as Administrator mode). The HDD Serial return Bank.

    May you test the code in Vista and W7 again?

    Thanks!
    Last edited by hai2hai; Jan 22nd, 2010 at 02:25 AM.

  36. #36
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    as this is an old thread resurrected, you should make clear who you are addressing, people who posted in this thread originally may not still be active in the forum

    i have tested wmi in both vista and windows7 (home premium) as a limited user, works in both, but the return strings have to be decoded
    in vista the return is in ascii
    but in widows 7 the return is a hex string
    in either case it easy to process the return to get the correct value
    should be able to figure from the length of the return whether it is ascii or hex
    as admin user the correct value was returned directly from the wmi query in vista, have not tried that yet in windows 7

    i have also made an api version that asks for elevation, then it works correctly with admin password provided
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  37. #37
    New Member
    Join Date
    Mar 2009
    Posts
    11

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    Quote Originally Posted by westconn1 View Post
    i have tested wmi in both vista and windows7 (home premium) as a limited user, works in both, but the return strings have to be decoded
    in vista the return is in ascii
    but in widows 7 the return is a hex string
    in either case it easy to process the return to get the correct value
    should be able to figure from the length of the return whether it is ascii or hex
    as admin user the correct value was returned directly from the wmi query in vista, have not tried that yet in windows 7

    i have also made an api version that asks for elevation, then it works correctly with admin password provided
    Could you please share the code that return & get correct value in both vista and w7?

    And provide me the solution "api version that asks for elevation, then it works correctly with admin password provided"

    TIA

    P/S: Anyone know how to get Physical LAN Adapter (MAC Address). I have the code but it sometime get VMW Adapter, sometime get Wireless Adapter and sometime get LAN Adapter (happen when I disable and enable again the LAN adapter). In most case I want to return Physical LAN Adapter only (Not other if LAN adapter is enable). I don't know why sometime Wireless Adapter have adapter index smaller than the Physical LAN adapter.
    Last edited by hai2hai; Jan 22nd, 2010 at 11:23 PM.

  38. #38
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    vb Code:
    1. Set WMIObjectSet = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_PhysicalMedia")
    2. For Each wmiobject In WMIObjectSet
    3.     s = wmiobject.SerialNumber
    4.     sn = ""
    5.     If Not IsNull(s) Then
    6.     If Len(s) > 20 Then
    7.     For i = 1 To Len(s) Step 4   ' windows 7
    8.         sn = sn & Chr("&h" & Mid(s, i + 2, 2)) & Chr("&h" & Mid(s, i, 2))
    9.     Next
    10.     ElseIf Len(s) = 20 Then
    11.     For i = 1 To Len(s) Step 2   ' vista
    12.         sn = sn & Mid(s, i + 1, 1) & Mid(s, i, 1)
    13.     Next
    14.     Else: sn = s   ' where string returned directly
    15.     End If
    16.     MsgBox wmiobject.Tag & " : " & Trim(sn)
    17.     End If
    18. Next
    19. Set WMIObjectSet = Nothing
    20.  
    21. End Sub

    And provide me the solution "api version that asks for elevation
    you need to follow all instructions for adding manifests to your exe, these are discussed in many places in this forum, all apps should now have this to be vista and windows 7 aware, as this is not just some vb code, but requires a tutorial, you will need to research it
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  39. #39
    New Member
    Join Date
    Mar 2009
    Posts
    11

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    vb Code:
    1. If Not IsNull(s) Then
    2.     If Len(s) > 20 Then
    3.     For i = 1 To Len(s) Step 4   ' windows 7
    4.         sn = sn & Chr("&h" & Mid(s, i + 2, 2)) & Chr("&h" & Mid(s, i, 2))
    5.     Next
    6.     ElseIf Len(s) = 20 Then
    7.     For i = 1 To Len(s) Step 2   ' vista
    8.         sn = sn & Mid(s, i + 1, 1) & Mid(s, i, 1)
    9.     Next
    Many thanks, how about the BIOS & Motherboard Serials in Vista & Windows 7?

  40. #40
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How can know Manufacture Hardware ID (Serial Number) of Disk or MotherBord etc

    you can get with wmi, tested as a limited user in windows 7, there are several threads on this on the forum, most show the same code

    "select * from win32_baseboard"

    on my laptop the serial number for the bios is the same as the baseboard, i have no idea what that means
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width