Results 1 to 18 of 18

Thread: Hardware serial number

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784

    Hardware serial number

    How to get Hardware s/n thru VB.NET? ..please advise?

    Thanks a lot

    Regards
    Winanjaya

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    What hardware? any hardware? I know for hard disk you can use this method:
    VB Code:
    1. Dim mgmclass As New System.Management.ManagementClass("Win32_PhysicalMedia")
    2. Dim mgmcoll As Management.ManagementObjectCollection = mgmclass.GetInstances()
    3. Dim mgmenum As Management.ManagementObjectCollection.ManagementObjectEnumerator = mgmcoll.GetEnumerator
    4. mgmenum.MoveNext()
    5. MessageBox.Show(mgmenum.Current.Properties("SerialNumber").Value.ToString)
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    Thanks, I need any hardware ID .. likes motherboard, processor, vga card .. and may be hard disk s/n .. what serial no. of harddisk you provided ? .. is that hardware s/n or just o/s s/n? .. what I need is hardware s/n .. I cannot use o/s s/n because it will be changed if it formatted .. any comment?


    thanks a lot in advance

    Regards
    Winanjaya

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    What I provided is the hardcoded hard disk serial number, the one you can see on the sticker on the hard disk. You may play with that class to get the serial number of ther devices but I am afraid there will be no other .NET way of doing that.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    So I though this should be unique s/n.. (correct me If I'm wrong) .. does it compatible for all of harddisk types and brands? please advise?

    thanks

    Winanjaya

  6. #6
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    It is unique and it should be compatible, but honestly I am not sure.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  7. #7
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    By the way I am not sure that method i provided run on all Windows. I am sure it runs on XP and 2003.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    I tried it already, it gave me the following error:

    An unhandled exception type
    'System.Management.ManagementException' occured in system.management.dll

    Additional information: Not found.

    pls help,

    Thanks

    Winanjaya

  9. #9
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    What windows are you running?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    and my o/s is Win 2000 AS.. am I missing something? thanks

    Winanjaya

  11. #11
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I checked it, that requirs Windows XP or 2003.
    http://msdn.microsoft.com/library/en...asp?frame=true
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  12. #12
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784

    Unhappy

    but I don't understand C# ..


  14. #14
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Winanjaya
    but I don't understand C# ..
    Use this converter http://www.kamalpatel.net/ConvertCSharp2VB.aspx . If you stuck in any part let's know we might help .

    or

    Compile the classes (if any because I didn't check) into dll library and use them in your vb project.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    the error I explained was come from below code:

    Dim mgmcoll As Management.ManagementObjectCollection = mgmclass.GetInstances()

    Regards
    Winanjaya

  16. #16
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I've just tested the code Lunatic3 has posted and it works . As he said , this method requires XP or later versions of Windows . Your best bet now is to look for API path so it can run on any OS .
    Last edited by Pirate; Dec 15th, 2003 at 09:12 AM.

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    Thanks for your suggestion, could you please give me the information about where can I find the article or example for this ?

    TIA

    Winanjaya

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this example , at least it gives positive result not like some other methods (either negative number or some crap ) . There are multiple ways other than API and WMI (Scripting , FSO , some OCXs) .

    All search result can be found here :

    They are all VB6 proj but using API calls .
    Last edited by Pirate; Dec 15th, 2003 at 10:27 AM.

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