|
-
Mar 6th, 2010, 03:31 PM
#1
Thread Starter
Member
[RESOLVED] How to use WMI
I have been trying to use the WMI for several days now, but for some reason I cannot figure out how to implement it in my program.
I got a WMI code creater from the internet. I've search google. but I cannot get the program/visual studio to recognise it. Am I missing something?
I believe the code i use to fetch it is right. but how to send it to the wmi is probably my problem.
-
Mar 6th, 2010, 04:34 PM
#2
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Mar 6th, 2010, 06:03 PM
#3
Thread Starter
Member
Re: How to use WMI
 Originally Posted by weirddemon
funny, look:
I got a WMI code creater from the internet
I'm not a complete retard
-
Mar 6th, 2010, 06:04 PM
#4
Re: How to use WMI
I'm not a complete retard
You know it gives you the code, right?
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Mar 6th, 2010, 06:08 PM
#5
Thread Starter
Member
Re: How to use WMI
yes but if i enter this:
Code:
Public Overloads Shared Function Main() As Integer
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_VideoController")
For Each queryObj As ManagementObject in searcher.Get()
Console.WriteLine("VideoProcessor: {0}", queryObj("VideoProcessor"))
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Function
I'll just end up with blue lines under managementObjectSearcher
and stuff like that.
So that's why i'm wondering if I should put something else earlier in the code addressing the WMI like I had to do with for example to open a webpage in a default browser.
I'm using Visual Basic for the coding.
It's to grab the information for the Video card (just 1 of them if there are multiple since they will most likely be the same anyway)
-
Mar 6th, 2010, 06:12 PM
#6
Re: How to use WMI
I'll just end up with blue lines under managementObjectSearcher
and stuff like that.
You should have said that in the begining. You can't just say, "it doesn't work" and expect us to know what's wrong. The specifics are important.
The problem is that you need to add a reference to System.Management. You can do this by right-clicking on your project in the solution explorer and selecting, Add Reference....
Then, in the .NET tab, select System.Management. After you've done that, add an import to System.Management at the top of your project, before the class.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Mar 6th, 2010, 10:54 PM
#7
Thread Starter
Member
Re: How to use WMI
that's what I already have in there aswell
Sorry i'm not the best person to explain things.
But I already have the imports at the top of my form, that's why i find it weird.
-
Mar 9th, 2010, 07:49 AM
#8
Thread Starter
Member
Re: How to use WMI
okay turns out something was prohibiting visual studio from accessing the WMI module.
anyway that's fixed.
However I'm trying to get more values from 1 piece of code.
like i want to get the name and amount of memory from the videocard from the 'Win32_VideoController' in the WMI
and then get amount of physical memory, remaining memory and speed in mhz from a different place.
how would i go about doing this?
as I cannot seem to apply the same method I used for a ping request.
help would be appriciated
-
Mar 9th, 2010, 01:46 PM
#9
Re: How to use WMI
Well, if you want good help, you have to give full, specific, and accurate descriptions of your problems. Without details, you can't assume we know what's going on.
like i want to get the name and amount of memory from the videocard from the 'Win32_VideoController' in the WMI
and then get amount of physical memory, remaining memory and speed in mhz from a different place.
What? You want to get the info from WMI that you're now getting, but you also want to retrieve information about what from where? You want that additional information from WMI and the video card? Or from the OS?
And what do you mean, "different place"?
You can't imagine how frustrating it is to try and help someone without specifics. I'm not trying to pick on you, but this kind of things happens every day.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Mar 9th, 2010, 08:27 PM
#10
Thread Starter
Member
Re: How to use WMI
I think I understand in the frusttration part. I often encouter that to in different matters. However it sometimes proves quite hard for me to explain what is actually on my mind without boring people so I try to keep it as short as possible.
So here's a more accurate explanation that I hope that will help:
okay I have 2 labels where I want to print something to, but I cannot state this in the shared section as that is not allowed.
What I want comes down to this, currently I have a tiny ping script fixed together that works like this:
Code:
Public Shared Function GetPingMs(ByRef host As String)
Dim ping As New System.Net.NetworkInformation.Ping
Try
Return ping.Send(host).RoundtripTime.ToString
Catch
Return "No Response"
End Try
End Function
ping_label.Text = GetPingMs("www.google.co.uk") & "ms"
I think you understand that the ping_label is in a private sub 
now i want to do something similar with the WMI code
Code:
Public Overloads Shared Function Main() As Integer
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_VideoController")
For Each queryObj As ManagementObject in searcher.Get()
queryObj("VideoProcessor"))
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Function
but than instead of the name VideoProcessor
I want to put those by a reference like in the ping script.
so that i would state VideoController and Videoprocessor in the private sub like this:
vid_label.Text = GetVidInfo(VideoProcessor) to get the graphics card procesor name and then put GetInfo(adaptarRam) / 1000000 to get the value of the video card memory in MBs
Than from there on I could work out the rest.
below is my code for now if you are interested (and what I have been trying to do to get the video processor name)
Code:
Imports System
Imports System.Management
Imports System.Windows.Forms
Public NotInheritable Class about_box
Public Shared Function GetVidCard(ByRef value As String) As Integer
Try
Dim searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_VideoController")
For Each queryObj As ManagementObject In searcher.Get()
Return queryObj(value)
Next
Catch err As ManagementException
Return err.Message
End Try
End Function
Public Shared Function GetPingMs(ByRef host As String)
Dim ping As New System.Net.NetworkInformation.Ping
Try
Return ping.Send(host).RoundtripTime.ToString
Catch
Return "No Response"
End Try
End Function
Private Sub Launcher_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'check whether the computer is connected to the internet'
If My.Computer.Network.IsAvailable = True Then
connect_label.Text = "Connected"
Else
connect_label.Text = "No connection detected"
End If
End Sub
Private Sub AboutBox1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
name_label.Text = My.Application.Info.ProductName
creator_label.Text = My.Application.Info.CompanyName
version2_label.Text = My.Application.Info.Version.ToString
description_label.Text = My.Application.Info.Description
Dim ramfree As Integer
Dim ram As Integer
os_label.Text = My.Computer.Info.OSFullName
cpu_label.Text = My.Computer.Registry.LocalMachine.OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0").GetValue("ProcessorNameString").ToString.Trim()
ram = My.Computer.Info.TotalPhysicalMemory / 1000000
ramfree = My.Computer.Info.AvailablePhysicalMemory / 1000000
ram_label.Text = "Total: " & ram & " mb" & " [Free: " & ramfree & " mb]"
ping_label.Text = GetPingMs("www.google.co.uk") & "ms"
vid_label.Text = GetVidCard()
I hope this was a better and more detailed discription.
-
Mar 10th, 2010, 08:01 PM
#11
Re: How to use WMI
Although i too don't really understand what you are trying.I'll tell you that this:
Public Shared Function GetVidCard(ByRef value As String) As Integer
Will not work for video card.Have you ever used wmi again?
"VideoProcessor" will return a string and you return an integer back.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Mar 10th, 2010, 08:44 PM
#12
Thread Starter
Member
Re: How to use WMI
 Originally Posted by sapator
Although i too don't really understand what you are trying.I'll tell you that this:
Public Shared Function GetVidCard(ByRef value As String) As Integer
Will not work for video card.Have you ever used wmi again?
"VideoProcessor" will return a string and you return an integer back.
No I never used WMI before, but I know it returns an Integer, but I know how to convert those if necessary/possible. in fact a month ago I didn't know how to write programs with Visual basic, though now I know my way around quite well. just I'm new with WMI.
The code I provided "GetVidCard(ByRef value As String) As Integer" was just what I was trying, mostly I just try try try and then eventually I get where I want to be. and I have been 'screwing' around with the code a lot so what you saw as I said is what I was trying, after lots of other things I tried.
So I guess my original question of substituting 'VideoProccesor' with a string/interger or whatever turns out to be not possible?
Though, How can I return the values obtained from WMI to a label.text? (I haven't done much research on this particular thing: To make strings/integers/floats available through out the program. [If that makes sence])
Or maybe you know a more effective way of obtaining the video cards name and amount of ram?
And a side question would you suggest that I get the other information by using WMI rather than using the Registery? (like OS name and such).
Thanks for all the answers so far. Atleast you tell me that my question is frustrating to understand, so I can act upon it rather than nobody helping me out. Because they do not understand the particular questions.
-
Mar 10th, 2010, 09:28 PM
#13
Re: How to use WMI
What's the point of converting p.e. "Nvidia card xxxx" string to integer?
If you want integers the look for other members in WMI that possibly suit your needs.
"How can I return the values obtained from WMI to a label.text?"
Do you mean label1.text = GetVidCard("VideoProcessor") ?
Also any reason you have used ByRef and not ByVal?
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Mar 10th, 2010, 09:34 PM
#14
Thread Starter
Member
Re: How to use WMI
As I stated I was just trying different things. so no, there isn't a particular reason for me to use byRef or ByVal.
I tried the GetVidCard("VideoPorcessor") but maybe I missed something out (wouldn' t be the first time :P )
Thanks for the reply and i'll try it as soon as i can tomorrow.
-
Mar 19th, 2010, 05:13 AM
#15
Thread Starter
Member
Re: How to use WMI
Okay well I have about tried everything.
even just tried putting the default WMI code in there without chaning it or using other WMI codes from the web.
It seems as if WMI is not returning anything to what I ask in Visual basic.
I'll once again post my code here regarding obtaining the data, and tell me please why it would not work.
Code:
Imports System
Imports System.Management
Imports System.Windows.Forms
Public NotInheritable Class about_box
Public Overloads Shared Function Main() As Integer
Dim vidCard As String
Dim VidMem As Integer
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_VideoController")
For Each queryObj As ManagementObject In searcher.Get()
vidCard = queryObj("VideoProcessor")
vidMem = queryObj("AdapterRAM")
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Function
Code:
Private sub AboutBox1_Load
Dim VidCard As String
Dim VidMem As Integer
vid_label.Text = VidCard & (VidMem / 1000000) & " mb"
End Sub
Summary:
1) Get VideoProcessor value from WIN32_VideoController
2) Get Adapter ram value from WIN32_VideoController
3) Out put these value's to a Label.text
That is what I want plain and simple (and don't tell me that is not clear please)
-
Mar 19th, 2010, 06:10 AM
#16
Re: How to use WMI
First of all, what is this
Code:
Public Shared Function GetPingMs(ByRef host As String)
Dim ping As New System.Net.NetworkInformation.Ping
Try
Return ping.Send(host).RoundtripTime.ToString
Catch
Return "No Response"
End Try
End Function
ping_label.Text = GetPingMs("www.google.co.uk") & "ms"
Why are you pinging???????
WMI Code Creator Code modified.
Code:
Imports System.Management
Module Module1
Public Sub Foo()
Dim StuffICareAbout As New List(Of String)
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_VideoController")
For Each queryObj As ManagementObject In searcher.Get()
StuffICareAbout.Add(queryObj("AdapterRAM").ToString)
'Console.WriteLine("AdapterRAM: {0}", queryObj("AdapterRAM"))
StuffICareAbout.Add(queryObj("Description").ToString)
'Console.WriteLine("Description: {0}", queryObj("Description"))
StuffICareAbout.Add(queryObj("DeviceID").ToString)
'Console.WriteLine("DeviceID: {0}", queryObj("DeviceID"))
StuffICareAbout.Add(queryObj("DriverDate").ToString)
'Console.WriteLine("DriverDate: {0}", queryObj("DriverDate"))
'Console.WriteLine("DriverVersion: {0}", queryObj("DriverVersion"))
'Console.WriteLine("MaxRefreshRate: {0}", queryObj("MaxRefreshRate"))
'Console.WriteLine("MinRefreshRate: {0}", queryObj("MinRefreshRate"))
'Console.WriteLine("Name: {0}", queryObj("Name"))
'Console.WriteLine("NumberOfColorPlanes: {0}", queryObj("NumberOfColorPlanes"))
'Console.WriteLine("NumberOfVideoPages: {0}", queryObj("NumberOfVideoPages"))
'Console.WriteLine("Status: {0}", queryObj("Status"))
'Console.WriteLine("StatusInfo: {0}", queryObj("StatusInfo"))
'Console.WriteLine("SystemName: {0}", queryObj("SystemName"))
'Console.WriteLine("VideoArchitecture: {0}", queryObj("VideoArchitecture"))
'Console.WriteLine("VideoMemoryType: {0}", queryObj("VideoMemoryType"))
'Console.WriteLine("VideoMode: {0}", queryObj("VideoMode"))
StuffICareAbout.Add(queryObj("VideoModeDescription").ToString)
'Console.WriteLine("VideoModeDescription: {0}", queryObj("VideoModeDescription"))
StuffICareAbout.Add(queryObj("VideoProcessor").ToString)
'Console.WriteLine("VideoProcessor: {0}", queryObj("VideoProcessor"))
Exit For 'if you have 1 video card then exit
Next
Catch err As ManagementException
Stop
End Try
Stop
End Sub
End Module
-
Mar 19th, 2010, 06:40 AM
#17
Thread Starter
Member
Re: How to use WMI
this program will be part of another program I made. I got my reasons to test the persons latency to my server.
Thanks for the WMI code, i'll see if that will fix my problem.
-
Mar 19th, 2010, 07:18 AM
#18
Re: How to use WMI
Why are you pinging???????
-
Mar 19th, 2010, 08:09 AM
#19
Thread Starter
Member
Re: How to use WMI
Unless you have a better way of testing a persons latency to my server I don't see why I shouldn't be pinging and what might be the problem with pinging. AND no I will not ping google as it is not my server 
I am ping because if the person says: "Help! LAGGGGGGG! so LAGGGGYYY." and stuff like that. Now I would ask him to check what his ping would be to my server, if it is high then that is the cause of his lag, if it is low than it might be his hardware or some other program causing the lag.
And in order to provide them with easy methods for me to help them out, I created this program.
Does that suffice?
And while we are at it maybe you can give me the substraction code, so that I can fully use your module, as I haven't thought myself yet how to use lists..
-
Mar 19th, 2010, 08:49 AM
#20
Re: How to use WMI
I have real issues with the misconceptions about what Ping tells you. Everyone seems to forget that there is a temporal component involved. Yes, I have an example of how you might always track latency. In this example I use a webbrowser.
Code:
Dim latency As New Stopwatch
Dim loaded As Boolean = False
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
latency.Stop() 'stop
'latency.Elapsed has time
Debug.WriteLine(latency.Elapsed.TotalSeconds.ToString("N1"))
loaded = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not loaded Then
loaded = True
latency.Reset() 'set to 0 and stop
latency.Start()
Try
WebBrowser1.Navigate("www.yahoo.com")
Catch ex As Exception
Stop
loaded = False
End Try
End If
End Sub
I have no idea what this "...maybe you can give me the substraction code..." means.
-
Mar 19th, 2010, 08:57 AM
#21
Re: How to use WMI
A better example of why ping isn't a good answer for almost every situation:
Code:
Dim latency As New Stopwatch
Dim loaded As Boolean = False
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
latency.Stop() 'stop
'latency.Elapsed has time
Debug.WriteLine(latency.Elapsed.TotalSeconds.ToString("N1"))
loaded = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not loaded Then
loaded = True
latency.Reset() 'set to 0 and stop
latency.Start()
Try
WebBrowser1.Navigate("http://www.vbforums.com/showthread.php?t=606244")
Catch ex As Exception
Stop
loaded = False
End Try
End If
End Sub
Try pinging www.vbforums.com and tell me how useful that is.
Pinging www.vbforums.com [63.236.73.220] with 32 bytes of data:
Request timed out.
Request timed out.
-
Mar 20th, 2010, 08:55 PM
#22
Thread Starter
Member
Re: How to use WMI
Well I will be pinging a server that will allow pings (as it is my own).
But if you would be so kind to just explain in (more) detail why I shouldn't ping? Is it like security issues?
and could you like explain your code? afterall I wouldn't really learn much if people would just make the code for me, then what good would making a program be?
I am trying to learn how to write a good fast (efficient) and easy to use program. infact maybe you have a suggestion about which programming language I should use for this kind of application:
A program launcher (that launches 1 program) will contain 3 windows, 1 will display some settings (eg. for a game that would be screen resolution, audio etc.) another one would show updates from a web page made on my server. and the last one would display ranking (in case of a game, Haven't figured out yet if it's easier to fetch it straight from the server or handle it through a web page).
A side from these function it will have a way to open up it's root folder and also a way to check all it's files whether these have to be updated or not (state 1 would be every time it is loaded it will do a quick check of essential files [eg. .abc] and once every month or week it would check every single file)
Would you suggest writing this program in Visual basic is adequate or would you suggest writing it in a different language, such as C++ or something else?
thanks for the help in advance, I would appreciate it ^^
Currently learning several new programming languages:
Python, C++, Visual Basic, ASP, PHP, Python and Java.
-
Mar 20th, 2010, 09:25 PM
#23
Re: How to use WMI
Write it at the language you know best.
Btw the WMI class you are inquiring will give you the Video controller settings.
As i see you want the screen resolution so you must use the Win32_DisplayConfiguration WMI class.
And if that's the case then you should have clarified it at your very first post because you have wasted your time looking for something that it's not where you are looking.
As for pinging why don't u use what dbasnett is telling you?
I don't know if ping will always deliver the true latency.
You can use both solutions(ping and not ping) and see which one you fancy most.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Mar 20th, 2010, 09:52 PM
#24
Thread Starter
Member
Re: How to use WMI
What gave you the impression that I wanted the resolution?
I want the Video processor name (eg. Geforce 9600 GT) and the amount of ram it has (eg. amount of ram / 1000000 = 512mb)
I can't say that I know visual basic best, I want to learn the language that will give me the most joy (most performance/speed/efficiency)
I just started visual basic because I had to start somewhere, and didn't just want to start at blank.
I would like to use his code, but a little bit of explanation wouldn' t hurt? I would like to know what happens where and why. etc. so that if i ever need to create it again then I can just create it instead of copy pasting the file..
other wise I could just pay someone and write me this launcher that I want, I would still end up not knowing how he did it.
And I need to figure out how to get the values printed/echo'd/displayed to a label.text. As I said I'm still busy learning, and I want to learn the best language to program my program with :P
Currently learning several new programming languages:
Python, C++, Visual Basic, ASP, PHP, Python and Java.
-
Mar 21st, 2010, 04:12 AM
#25
Re: How to use WMI
"1 will display some settings (eg. for a game that would be screen resolution, audio etc.)"
That gave me the impression.
Also for the language, it depends on what you want to do i guess.
Data modeling and on the go forms are most suited for .net
Game development and hardware manipulation C,C++ .
But also depends on what opportunities you will have.
I was playing with Assembly,C and C++ but a job requirement came that needed VS2003 on VB. So from 2003 and forth i'm using vb.net.
Now a job came that required asp.net so i'm going this direction also.
Anyway in my opinion the best language is C++ but it's a royal pain and also there isn't many company jobs that need this language.The thing is that you feel like really programming in C++ .In .net you feel sometimes that you are just drag n dropping.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Mar 21st, 2010, 05:43 AM
#26
Re: How to use WMI
If it is your network, and that is the only place this code will run then ping away.
My issue with the use of ping, as I see it posted here so often, is that people are doing what I call ping-then-do. "They" want to do something, say browse a web page, and they ping it first, which is pointless. The only people that have a real need for using ping in a program is someone writing a network administrator program.
What code did you want explained?
-
Mar 22nd, 2010, 04:42 AM
#27
Thread Starter
Member
Re: How to use WMI
ahh I see, well it is just for me to get a gross idea of their latency. doesn't have to be accurate. if it says somewhere over 300ms then I can assume pretty sure that their internet connection is crappy and such. if it's 50ms but their hardware is bad then i can assume the lag is caused by that.
Well I would like understand both your latency code and the WMI code (and how to output it to a code).
Thanks for the help so far ^^
====
well the screen resolution would be to set for example a game resolution. this is a seperate program for now, later it will be intergrated in the main program. but I just gave a global idea of what it would be.
this program is to check the following (CPU, RAM, VIDCARD, INTERNET CONNECTION, LATENCY and OS)
it will be a launcher for a game, so would you then suggest visual basic? all I'm concerned about is getting the most performance out of a program. for example I want it to be able to run (reasonably well) on a computer with just a P4 1Ghz and 64mb RAM :P
Currently learning several new programming languages:
Python, C++, Visual Basic, ASP, PHP, Python and Java.
-
Mar 22nd, 2010, 05:25 AM
#28
Re: How to use WMI
Without seeing code or having an understanding of what it is you are trying to do, then "...I can assume pretty sure that their internet connection..." doesn't mean much.
So what is it that you are really trying to do that makes you think you need to ping? The WMI code I posted is pretty much a copy / paste from WMICodeCreator.exe.
-
Mar 22nd, 2010, 10:20 AM
#29
Thread Starter
Member
Re: How to use WMI
To get their latency,
Is it not that if the ping (even if it's not completely accurate) is over say 1000ms wouldn't that explain possible 'lagging' in game as you are running 1000ms behind on the server with sending or receiving packages. so than I can say that it is their connection between them and my server that is slow.
It is to get the delay of sending and receiving packages from the server. if this is low they have a smooth gameplay. if this is high their gameplay will be 'lagy'.
the lower the ping the better, the higher the worse right?
so IF it is high, then that might cause their stutering gameplay. IF it is low than slow hardware might be the cause of their stutering gameplay.
Tell me if you have ever played an MMORPG (Massive Multiplayer Online Role Playing Game) and explain to me that if you have to wait several seconds before you actually see your action or the reaction of a creature or person being hit by one of your skills. wouldn' t that be annoying? hence 'LAG' this usual fals together with the problem of a slow connection to the respective game server.
Would that suffice?
Currently learning several new programming languages:
Python, C++, Visual Basic, ASP, PHP, Python and Java.
-
Mar 22nd, 2010, 10:24 AM
#30
Thread Starter
Member
Re: How to use WMI
oh and btw, the only thing that i'm trying to achieve is this:
Code:
Public Shared Function GetPingMs(ByRef host As String)
Dim ping As New System.Net.NetworkInformation.Ping
Try
Return ping.Send(host).RoundtripTime.ToString
Catch
Return "No Response"
End Try
End Function
This would be my function to get the actual ping if there is one to obtain. otherwise it would return 'No Response'
Code:
ping_label.Text = GetPingMs("www.google.co.uk") & "ms"
This would print the Ping (in ms) to the label called ping_label and in to the text area.
it would then add a 'ms' behind the ping value
eg.
I want to ping Google.co.uk
the returned ping says 50
then what I make it print is: '50ms' in the text area of ping_label.
understand? there is nothing more to the code than that.
=====
And the PING thing doesn't have anything to do with WMI!
I just want to get the following stuff with WMI from VideoController: VideoProccesor and AdapterRAM. and how to output this to a label.
THAT is all I asked for. I appreciate help regarding the rest of my code that is why I posted it.
The whole ping thing is bassically off topic, so please just explain your WMI code, where it does what, and how to output it to a label.text so that I can use it in my program.
Thanks!
Last edited by ALT+F4; Mar 22nd, 2010 at 10:28 AM.
Reason: updated
Currently learning several new programming languages:
Python, C++, Visual Basic, ASP, PHP, Python and Java.
-
Mar 22nd, 2010, 12:12 PM
#31
Re: How to use WMI
Maybe I wasn't clear, or maybe all your application does is ping? Or does it do something else? If it does, then whatever it is can tell you the latency I'm guessing.
Code:
Imports System.Management
'add Project Reference to System.Management
Module Module1
Public Sub main()
Dim getStuff As New List(Of String)
getStuff = foo()
For Each s As String In getStuff
Console.WriteLine(s)
Next
Console.ReadLine()
End Sub
Public Function foo() As List(Of String)
Dim StuffICareAbout As New List(Of String)
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_VideoController")
For Each queryObj As ManagementObject In searcher.Get()
StuffICareAbout.Add(queryObj("AdapterRAM").ToString)
'Console.WriteLine("AdapterRAM: {0}", queryObj("AdapterRAM"))
StuffICareAbout.Add(queryObj("Description").ToString)
'Console.WriteLine("Description: {0}", queryObj("Description"))
StuffICareAbout.Add(queryObj("DeviceID").ToString)
'Console.WriteLine("DeviceID: {0}", queryObj("DeviceID"))
StuffICareAbout.Add(queryObj("DriverDate").ToString)
'Console.WriteLine("DriverDate: {0}", queryObj("DriverDate"))
'Console.WriteLine("DriverVersion: {0}", queryObj("DriverVersion"))
'Console.WriteLine("MaxRefreshRate: {0}", queryObj("MaxRefreshRate"))
'Console.WriteLine("MinRefreshRate: {0}", queryObj("MinRefreshRate"))
'Console.WriteLine("Name: {0}", queryObj("Name"))
'Console.WriteLine("NumberOfColorPlanes: {0}", queryObj("NumberOfColorPlanes"))
'Console.WriteLine("NumberOfVideoPages: {0}", queryObj("NumberOfVideoPages"))
'Console.WriteLine("Status: {0}", queryObj("Status"))
'Console.WriteLine("StatusInfo: {0}", queryObj("StatusInfo"))
'Console.WriteLine("SystemName: {0}", queryObj("SystemName"))
'Console.WriteLine("VideoArchitecture: {0}", queryObj("VideoArchitecture"))
'Console.WriteLine("VideoMemoryType: {0}", queryObj("VideoMemoryType"))
'Console.WriteLine("VideoMode: {0}", queryObj("VideoMode"))
StuffICareAbout.Add(queryObj("VideoModeDescription").ToString)
'Console.WriteLine("VideoModeDescription: {0}", queryObj("VideoModeDescription"))
StuffICareAbout.Add(queryObj("VideoProcessor").ToString)
'Console.WriteLine("VideoProcessor: {0}", queryObj("VideoProcessor"))
Exit For 'if you have 1 video card then exit
Next
Catch err As ManagementException
Return New List(Of String)
End Try
Return StuffICareAbout
End Function
End Module
-
Mar 23rd, 2010, 06:27 AM
#32
Thread Starter
Member
Re: How to use WMI
Maybe I wasn't clear..
What my program does is this:
- System Info
- Internet
- LATENCY TO (MY) SERVER (PING)
- CONNECTION TO INTERNET (YES/NO)
- PROGRAM INFORMATION
I don't get what it is that is so unclear about what I am saying. this is like the so maniest time that I'm saying what this program is for...
and ALL I need to know is this:
- Get Video Processor name from WMI
- Get Video RAM from WMI
- How to print this to a Label (as in HOW, not as in SUPPLY me with the code, I want to KNOW how to do it)
plain and simple, let's just forget about latency shall we?
Currently learning several new programming languages:
Python, C++, Visual Basic, ASP, PHP, Python and Java.
-
Mar 23rd, 2010, 06:45 AM
#33
Re: How to use WMI
So I answered the "and ALL I need to know is this" part and you don't want to discuss the other, so mark the thread resolved.
-
Mar 23rd, 2010, 06:48 AM
#34
Thread Starter
Member
Re: How to use WMI
as I said:
How to print this to a Label (as in HOW, not as in SUPPLY me with the code, I want to KNOW how to do it)
I would like to know HOW that code works, what it does, why it does.
like comments? piece it down? and as I have said I haven't done lists yet so how would I get the values from there?
then i'll mark it as resolved.
and also why would i need all this:
Code:
'Console.WriteLine("DriverVersion: {0}", queryObj("DriverVersion"))
'Console.WriteLine("MaxRefreshRate: {0}", queryObj("MaxRefreshRate"))
'Console.WriteLine("MinRefreshRate: {0}", queryObj("MinRefreshRate"))
'Console.WriteLine("Name: {0}", queryObj("Name"))
'Console.WriteLine("NumberOfColorPlanes: {0}", queryObj("NumberOfColorPlanes"))
'Console.WriteLine("NumberOfVideoPages: {0}", queryObj("NumberOfVideoPages"))
'Console.WriteLine("Status: {0}", queryObj("Status"))
'Console.WriteLine("StatusInfo: {0}", queryObj("StatusInfo"))
'Console.WriteLine("SystemName: {0}", queryObj("SystemName"))
'Console.WriteLine("VideoArchitecture: {0}", queryObj("VideoArchitecture"))
'Console.WriteLine("VideoMemoryType: {0}", queryObj("VideoMemoryType"))
'Console.WriteLine("VideoMode: {0}", queryObj("VideoMode"))
As i Only need 2 which are adapterRAM and Videoprocessor.
that's why I ask you to explain it, rather than just giving it and say enjoy
and btw I don't mind discussing the other one but You don't explain yourself very clearly and I have the feeling that I'm just going arround in circles. And maybe you forgot but I'm still learning how to use Visual Basic, so giving just a piece of code will not answer any of my questions. would be the same as asking a teacher for help with your project and instead of giving help he gives you a A or complete project for you to hand in.
Last edited by ALT+F4; Mar 23rd, 2010 at 08:07 AM.
Currently learning several new programming languages:
Python, C++, Visual Basic, ASP, PHP, Python and Java.
-
Mar 23rd, 2010, 11:48 AM
#35
Re: How to use WMI
 Originally Posted by ALT+F4
as I said:
How to print this to a Label (as in HOW, not as in SUPPLY me with the code, I want to KNOW how to do it)
I would like to know HOW that code works, what it does, why it does.
like comments? piece it down? and as I have said I haven't done lists yet so how would I get the values from there?
then i'll mark it as resolved.
and also why would i need all this:
Code:
'Console.WriteLine("DriverVersion: {0}", queryObj("DriverVersion"))
'Console.WriteLine("MaxRefreshRate: {0}", queryObj("MaxRefreshRate"))
'Console.WriteLine("MinRefreshRate: {0}", queryObj("MinRefreshRate"))
'Console.WriteLine("Name: {0}", queryObj("Name"))
'Console.WriteLine("NumberOfColorPlanes: {0}", queryObj("NumberOfColorPlanes"))
'Console.WriteLine("NumberOfVideoPages: {0}", queryObj("NumberOfVideoPages"))
'Console.WriteLine("Status: {0}", queryObj("Status"))
'Console.WriteLine("StatusInfo: {0}", queryObj("StatusInfo"))
'Console.WriteLine("SystemName: {0}", queryObj("SystemName"))
'Console.WriteLine("VideoArchitecture: {0}", queryObj("VideoArchitecture"))
'Console.WriteLine("VideoMemoryType: {0}", queryObj("VideoMemoryType"))
'Console.WriteLine("VideoMode: {0}", queryObj("VideoMode"))
As i Only need 2 which are adapterRAM and Videoprocessor.
that's why I ask you to explain it, rather than just giving it and say enjoy
and btw I don't mind discussing the other one but You don't explain yourself very clearly and I have the feeling that I'm just going arround in circles. And maybe you forgot but I'm still learning how to use Visual Basic, so giving just a piece of code will not answer any of my questions. would be the same as asking a teacher for help with your project and instead of giving help he gives you a A or complete project for you to hand in.
Look carefully at post #31. It shows how to get each string from the list. All I am doing is writing it to the console.
I included all of those commented lines so you would have a list of ALL of the possible query objects. If you only need two, great.
All your app does is gather information from what I can tell.
If your app isn't using the network then it shouldn't ping.
Any app that does use the network can gather latency information as I showed earlier.
-
Mar 23rd, 2010, 06:10 PM
#36
Re: How to use WMI
May i suggest that you incorporate whatever works ok for you in your application and starts new thread(s) if you have questions on something in specific.
Also if you want to learn WMI then u can look at msdn.com
Also there isn't much books but there are at least 4-5 for WMI.I have some of them in pdf but to tell you the truth i rarely look at them cuz surfing on the net for specific answers is now more easy for me, since i have a basic knowledge.
But you can find some and buy,or....You know
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Mar 23rd, 2010, 06:42 PM
#37
Fanatic Member
Re: How to use WMI
looking at this 2 issues hit me, how is the op going to get the info from the target machine via a remote server? will the target machine have access to the completed software?
I think the op would be better using php or asp (depending on the server) and a scripting language, if the game is located on the server too then it makes more sense to use a server side language approach
If debugging is the process of removing bugs, then programming must be the process of putting them in.
-
Mar 24th, 2010, 12:48 PM
#38
-
Mar 25th, 2010, 05:12 PM
#39
Thread Starter
Member
Re: How to use WMI
Ahh okay, guess the last time I was to fast with my reply. sorry about that.
so just to make it clear for myself, i should just grab it from the 'console'? or should i replace the console.writeline with label.text?
As so far the WMI did give a sort of similar code and I could not put the label.text in there.
It's still abit unclear how values are shared throughout a program.
No this program has nothing to do with the internet. however the program where it will be in intergrated will have things to do with the internet. as it will check for internet connection and then check whether local files would be up to date. but it would be a seperate form that would be included in the same .exe file.
For me to get the information is simple for me, I include a sort of printscreen function that captures the little program and saves it to a file. then I'll just ask the person to upload it to my support forum or helpdesk feature on my website. later I might include a sort of problem checker that does everything for the user but for now this would more than suffice 
The reason why I did not make a new threat was because in my eyes it was related to this program AND I don't like having several different posts open in the same time. however i posted my complete code in here just in case i screwed up somewhere and due to that we landed on the issue of grabbing the latency. and regarding to the latency thanks for that piece of code I can now understand both of them fully as we just discussed them today in further detail in class ^^ guess I am just a bit hasty and for that and any rudeness on my part I say my apologies..
Thanks for all the help, and i'll mark it now as resolved
Currently learning several new programming languages:
Python, C++, Visual Basic, ASP, PHP, Python and Java.
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
|