System Information - Extensive
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
5 posts
Page 1 of 1
Hello,
Alot of people have been asking how to get system information into applications and you can do this in a couple of ways but I think this way is the best and you can get any information you want.
This code uses WMI to get specific information about processors, memory, OS, motherboard, drivers, hardware and everything else to do with the users system.
To make things easier Microsoft have a little application called WMI Code Creator that you can download for free here: http://www.microsoft.com/downloads/deta ... laylang=en
When you run the application it will look like the screenshot above (without the colored borders). Ill explain a little bit about the interface and the sections ive highlighted in the screenshot.
The area marked in RED is where you select which part of the system you want information from such as Processor, BIOS and so on. Once youve made your selection you will get a list of all available commands in the box highlighted in GREEN. If you click one of these commands you will see a code sample in the box highlighted in BLUE which you can use in your application to show the selected piece of information. If you click "Code Language" in the menu bar you can select which programming language you need code for, VB.NET..C# or VBScript.
But we wont be using the code from that blue box in this tutorial because theres too much of it and will take up alot of room in your code if you wanted alot of information. We are going to do it in a much quicker and simpler way so start by creating a new project.
Before we do anything we need to go into Project > Project Properties and click "References". Then add a reference to "System.Management.dll"
Now in code view we will add a function to our code that will do most of the hard work for us and save us loads of time. So add this function code:
On the screenshot in the RED box I have selected "Win32_Processor" but we want to cut out "Win32_" and just use the name of what we want information from..in this case its "Processor".
Now you need to choose a command from the box highlighted in GREEN and for this example I will use "MaxClockSpeed".
So we now know what we want information from and what information we want. The code you would use to show this information is:
Thats all you have to do ;) nice and easy!
I hope someone finds it useful cooll;
Alot of people have been asking how to get system information into applications and you can do this in a couple of ways but I think this way is the best and you can get any information you want.
This code uses WMI to get specific information about processors, memory, OS, motherboard, drivers, hardware and everything else to do with the users system.
To make things easier Microsoft have a little application called WMI Code Creator that you can download for free here: http://www.microsoft.com/downloads/deta ... laylang=en
When you run the application it will look like the screenshot above (without the colored borders). Ill explain a little bit about the interface and the sections ive highlighted in the screenshot.
The area marked in RED is where you select which part of the system you want information from such as Processor, BIOS and so on. Once youve made your selection you will get a list of all available commands in the box highlighted in GREEN. If you click one of these commands you will see a code sample in the box highlighted in BLUE which you can use in your application to show the selected piece of information. If you click "Code Language" in the menu bar you can select which programming language you need code for, VB.NET..C# or VBScript.
But we wont be using the code from that blue box in this tutorial because theres too much of it and will take up alot of room in your code if you wanted alot of information. We are going to do it in a much quicker and simpler way so start by creating a new project.
Before we do anything we need to go into Project > Project Properties and click "References". Then add a reference to "System.Management.dll"
Now in code view we will add a function to our code that will do most of the hard work for us and save us loads of time. So add this function code:
Code: Select all
OK we are ready to get our information and display it somewhere like in a Textbox or Label. Before we can get our information we need to know what we are getting information from and the information we want from it.Private Shared Function AskForTheInfo(ByVal ClassName As String, ByVal PropInfo As String) As String
Dim WinFoSearch As New ManagementObjectSearcher("Select * from Win32_" & ClassName)
For Each WinObj As ManagementObject In WinFoSearch.Get()
Try
Return WinObj(PropInfo).ToString()
Catch e As Exception
MessageBox.Show(e.Message + " " + ClassName + " - " + PropInfo) 'JUST INCASE YOU MADE A MISTAKE IT WILL TELL YOU WHERE IT IS!
End Try
Next WinObj
Return ""
End Function
On the screenshot in the RED box I have selected "Win32_Processor" but we want to cut out "Win32_" and just use the name of what we want information from..in this case its "Processor".
Now you need to choose a command from the box highlighted in GREEN and for this example I will use "MaxClockSpeed".
So we now know what we want information from and what information we want. The code you would use to show this information is:
Code: Select all
If you wanted to display that in a Textbox then you simply use:AskForTheInfo("Processor", "MaxClockSpeed")
Code: Select all
And you use the same short piece of code for everything else. If you wanted to show the BIOS name you would use:TextBox1.Text = AskForTheInfo("Processor", "MaxClockSpeed")
Code: Select all
Or to show the BIOS Manufacturer:AskForTheInfo("BIOS", "Name")
Code: Select all
AskForTheInfo("BIOS", "Manufacturer")
Thats all you have to do ;) nice and easy!
I hope someone finds it useful cooll;
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Wow Thanks for show me how to use this
Thanks Codenstuff, this makes it a lot easier to understand 
Chris

Chris
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023