|
-
Oct 14th, 2005, 11:04 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Get System Hardware Info
I would have thought this was easy, but I can't find it. I need to find out what hardware the system has. For example CPU, ram, and harddrive. Is there any way to do this?
Thanks
Last edited by mpdeglau; Oct 14th, 2005 at 01:52 PM.
-
Oct 14th, 2005, 12:33 PM
#2
Thread Starter
Frenzied Member
Re: Get System Hardware Info
Update:
Ok I found I can get most, maybe even all of my information using System.Management. My question now is how can I figure out what tables I can query. Table may be the wrong turm but since this is like an SQL query I'm not sure what to call it. But I can search using SELECT * FROM Win32_OperatingSystem. Anyone know where I can look to find all the available options for Win32_...
Thanks
-
Oct 14th, 2005, 01:52 PM
#3
Thread Starter
Frenzied Member
Re: Get System Hardware Info
Update:
Found it. The 101 examples has it.
-
Oct 14th, 2005, 02:00 PM
#4
Member
Re: [RESOLVED] Get System Hardware Info
mpdeglau could u post the code here?
-
Oct 14th, 2005, 02:51 PM
#5
Thread Starter
Frenzied Member
Re: [RESOLVED] Get System Hardware Info
What are you looking for?
-
Oct 14th, 2005, 03:22 PM
#6
Member
Re: [RESOLVED] Get System Hardware Info
I Have to develop One of Each of the next 3 Categories.
Cat A (Files And Programs):
1. Get the Number Of Times a Specific Program has been used, and the time it was used.
2. Get The Content Details of a Specific Directory or Sub-Directory (Folders)
3. See All Hidden Files in a Specific Directory.
4. Hide All Files from an Specific Extension in a Directory
Cat B (HardDisk):
1. Get The Free and Ocupied Space of a HD
2. See How Many EXE files have been eliminated from a HD in a Specific Period Of Time
3. See All Content of a HD by File Type
4. Determine How Many times a HD has been desfragmented
Cat C (Remote Conexion and Internet):
1. Remotly Check the existence of a Floppy Disk or a CD in a PC
2. Limit the File Types that can be downloaded from Internet
3. Limit the File Size that can be downloaded from Internet
4. Get the most visited WebSites by an User
If Someone Can help me in AT LEAST one i will really really appreciate it
Last edited by loudbliss; Oct 14th, 2005 at 03:23 PM.
Reason: syntax
-
Oct 14th, 2005, 03:54 PM
#7
Thread Starter
Frenzied Member
Re: [RESOLVED] Get System Hardware Info
Here is code to get the hard drive size and the free space. You need to add a reference to System.Management. You will have a much easier time if you download and install the vb.net 101 examples. There are a ton of classes you can use in the query. Install it to any folder you want then search that folder for WMI and it will show you the example project for this.
VB Code:
Imports System.Managment
Public Class Class1
Private HDToGet as String 'the drive you want to get the size of
Private _HDSize as string
Private _HDFreeSpace
Public Sub New()
End Sub
Public Sub New(specificHD as string) 'sets the drive to get the size
HDToGet = SpecificHD
End Sub
Public Property HDSize() As String
Get
getHardDriveTotalSpace(CaptureDrive)
Return _HDSize
End Get
Set(ByVal Value As String)
_HDSize = Value
End Set
End Property
Public Property HDFreeSpace() As String
Get
getHardDriveFreeSpace(CaptureDrive)
Return _HDFreeSpace
End Get
Set(ByVal Value As String)
_HDFreeSpace = Value
End Set
End Property
Private Function getHardDriveTotalSpace(ByVal capDrive As String) As String
Dim HDSize As String
Dim objOS = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk")
Dim objMgmt As ManagementObject
For Each objMgmt In objOS.Get
If objMgmt("Name").ToString = capDrive Then
HDSize = objMgmt("Size").ToString
End If
Next
_HardDriveSize = Format(HDSize / 1073741824, "0.00")
End Function
Private Function getHardDriveFreeSpace(ByVal capDrive As String) As String
Dim HDSpace As String
Dim objOS = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk")
Dim objMgmt As ManagementObject
For Each objMgmt In objOS.Get
If objMgmt("Name").ToString = capDrive Then
HDSpace = objMgmt("FreeSpace").ToString
End If
Next
_HDFreeSpace = Format(HDSpace / 1073741824, "0.00")
End Function
End Class
-
Oct 15th, 2005, 12:04 PM
#8
Member
Re: [RESOLVED] Get System Hardware Info
mpdeglau thx very much man
let me see now how that 101 examples work
-
Oct 15th, 2005, 03:10 PM
#9
Re: [RESOLVED] Get System Hardware Info
Download Scriptomatic2 by the Microsoft team. It writes VBS as well as other languages to easily use WMI. It also emumerates all available options that you select from combo boxes.
-
Oct 18th, 2005, 03:36 PM
#10
Member
Re: [RESOLVED] Get System Hardware Info
mpdeglau
i used your code and it was very very helpful, it just had a couple of errors therefore im going to post the corrected code (the error where in variables and meaningless stuffs like that)
VB Code:
Imports System.Management
Public Class Class1
Private HDToGet As String 'the drive you want to get the size of
Private _HDFreeSpace As String
Private _HardDriveSize As String
Public Sub New(ByVal specificHD As String) 'sets the drive to get the size
HDToGet = specificHD
End Sub
Public Property HDSize() As String
Get
getHardDriveTotalSpace(HDToGet)
Return _HardDriveSize
End Get
Set(ByVal Value As String)
_HardDriveSize = Value
End Set
End Property
Public Property HDFreeSpace() As String
Get
getHardDriveFreeSpace(HDToGet)
Return _HDFreeSpace
End Get
Set(ByVal Value As String)
_HDFreeSpace = Value
End Set
End Property
Private Function getHardDriveTotalSpace(ByVal capDrive As String) As String
Dim HDSize As String
Dim objOS = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk")
Dim objMgmt As ManagementObject
For Each objMgmt In objOS.Get
If objMgmt("Name").ToString = capDrive Then
HDSize = objMgmt("Size").ToString
End If
Next
_HardDriveSize = Format(HDSize / 1073741824, "0.00")
End Function
Private Function getHardDriveFreeSpace(ByVal capDrive As String) As String
Dim HDSpace As String
Dim objOS = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk")
Dim objMgmt As ManagementObject
For Each objMgmt In objOS.Get
If objMgmt("Name").ToString = capDrive Then
HDSpace = objMgmt("FreeSpace").ToString
End If
Next
_HDFreeSpace = Format(HDSpace / 1073741824, "0.00")
End Function
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|