How to get Hardware s/n thru VB.NET? ..please advise?
Thanks a lot
Regards
Winanjaya
Printable View
How to get Hardware s/n thru VB.NET? ..please advise?
Thanks a lot
Regards
Winanjaya
What hardware? any hardware? I know for hard disk you can use this method:
VB Code:
Dim mgmclass As New System.Management.ManagementClass("Win32_PhysicalMedia") Dim mgmcoll As Management.ManagementObjectCollection = mgmclass.GetInstances() Dim mgmenum As Management.ManagementObjectCollection.ManagementObjectEnumerator = mgmcoll.GetEnumerator mgmenum.MoveNext() MessageBox.Show(mgmenum.Current.Properties("SerialNumber").Value.ToString)
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
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.
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
It is unique and it should be compatible, but honestly I am not sure.
By the way I am not sure that method i provided run on all Windows. I am sure it runs on XP and 2003.
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
What windows are you running?
and my o/s is Win 2000 AS.. am I missing something? thanks
Winanjaya
I checked it, that requirs Windows XP or 2003.
http://msdn.microsoft.com/library/en...asp?frame=true
You may also find this useful:
http://www.codeproject.com/csharp/wmi.asp?print=true
but I don't understand C# ..
:blush:
Use this converter http://www.kamalpatel.net/ConvertCSharp2VB.aspx . If you stuck in any part let's know we might help .Quote:
Originally posted by Winanjaya
but I don't understand C# ..
:blush:
or
Compile the classes (if any because I didn't check) into dll library and use them in your vb project.
the error I explained was come from below code:
Dim mgmcoll As Management.ManagementObjectCollection = mgmclass.GetInstances()
Regards
Winanjaya
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 .
Thanks for your suggestion, could you please give me the information about where can I find the article or example for this ?
TIA
Winanjaya
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 .