|
Did you actually read the article? Understanding WMI is simple: it's script-based access to information on remote machines. You don't have to understand CIM, which is like WMI standard classes.
A simple way to query a remote client for products is like so:
public void EnumProducts(string machine)
{
string scope = "root\\cimv2";
if (machine != null && machine.Length > 0) scope = string.Format(
"\\\\{0}\\{1}", machine, scope);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
scope,
"SELECT * FROM Win32_Product");
ManagementObjectCollection products = searcher.Get();
foreach (ManagementObject product in products)
Console.WriteLine(product["Name"]);
} Note that this will only enumerator products installed via Windows Installer.
If you read the article, you'll see a link to a VS.NET add-in that creates a typed class for the Win32_Product class (or whatever class you use). This makes it much easier to use and enumerate.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Good morning Heath,
Your code works fine thanks and gives me a good idea of the mechanics.
I have read the article again (I am not sure I understand all of it yet, though) and have a few questions:
Q1: Where can I find possible values for values in 'Product["NAME"]'. (In the article we have 'Product["CAPTION"]' which also works fine'). I have searched the SDK 1.1.
Q2: Same question for Win32_??; I have seen Win32_Product and Win32_Service. Where can I find the rest ?
Q3: What does ATL stand for ?
I have been developing for 15 years but in a different environment which is why both the development environment and the vocabulary is strange to me and causes big problems for me understanding the core issues.
I don't think I am stupid - I just need the concepts re-phrased.
So, what does...
Q4: it mean to 'Instrument an application', and what is instrumentation ? (Playing the guitar ? )
I will proceed with the VS.NET add-in and see if I can get that to work.
Thanks again
William
|
|
|
|
|
A1: Why are you looking in the .NET Framework SDK? These properties are for WMI objects. WMI != .NET. WMI is just a standard for accessing data on a machine. There are WMI classes - which define properties and methods - and instances of those classes, just like any OO development framework (like .NET). If you want to find out what properties are defined on an object, why not simply enumerate the Properties collection property? This would be the logical conclusion if you read the documentation for the ManagementObject .
A2: As I said before, the article has a link toward the bottom for a VS.NET add-in that adds management classes and event to your Server Explorer tab in VS.NET. I recommend downloading that for VS.NET 2003 (which I assume you have since you mentioned the 1.1 SDK) from here[^]. This installs with a default set of classes but you can add more. The best way, however, is to use the CIM Studio mentioned in the article.
A3: Active Template Libraries - a set of templated C++ classes for creating COM components more easily. A quick search for "ATL" on google would've told you as much.
A4: As the article discussed throughout it's entirety, instrumenting an application is making management data available and firing management events. You can also just simply consume management data and handle management events to instrument your application as you're attempting to do now.
When you need to learn something, I suggest researching it on MSDN or some other site. I have to / want to learn new things all the time. Researching is just part of development, and MSDN contains plenty of Microsoft-related developer documentation, being that it is the Microsoft Developer Network.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi everybody,
please try to solve me a mysterious problem .
I opened a new C# console Application and I wrote this code in the Main function:
//-----------------------------------------
//Create new HashTable
Hashtable ht = new Hashtable(100000);
//Add 100,000 elements
for (int i =0 ; i < 100000 ; i++)
ht.Add(i.ToString() , i);
//wait for user
Console.Read();
//-----------------------------------------
Well then I opened the Task Manager and I saw that the memory usage of my app is about 14,256K, then I did something very simple, I just minimized the app and then restored to normal, then I took another look in the Task Manager and saw that the memory usage decreased to 132K.
Can you tell me why this happens?
|
|
|
|
|
I don't have time to go research it, but you shouldn't have anything to worry about. As an exercise, try this:
1) Open taskman
2) Note the memory usage for IEXPLORE.EXE
3) Minimize this browser, and note the memory
4) Maximize again, and note the memory
It's just Windows doing its thing, flushing memory to disk and trimming the working set for applications when it feels necessary. I believe that if your application has allocated more memory than it needs, and some other memory-hogging application starts needing more memory, Windows will free up some of that 14 megs without you doing anything at all. Also, I've noticed that the .NET runtime likes to give around fifteen megs on my own machine to a simple "Hello, world!" app.
I imagine you're trying to gauge the impact to users with wimpy machines, yes? Well, I think that there's no substitute for actually deploying and testing on a wimpy machine. Sorry I can't be of more help.
-Jeff
here, bloggy bloggy
|
|
|
|
|
.NET is garbage collected. The garbage collector (GC) runs when the application is idle (like when it's minimized) or when memory consumption is high and it'd determined that more memory will be needed soon, or when memory is not available (in some cases). You can force garbage collection by running GC.Collect , but you should not do this in most cases. The GC runs when it needs to and very rarely should you force it (and GC.Collect is a synchronous call, so your thread of execution will block until the GC finishes collecting).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want to drag a window from one point to other with the help of mouse,is there any built-in event for it or some other method,please help
mughalali
|
|
|
|
|
Overriden MouseDown and MouseMove . In the first one set the variable which indicate mouse button pressed and in second one check if that valiable is true then set the Location propoerty of your form. Then in MouseUp set that variable to false,
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Hey There!
I'm using the following code to get the free space on my disks:
string[] DriveLetters = {"C:","D:","E:","F:","O:","S:","_Total"};
const int DriveCount = 7;
PerformanceCounter[] DriveSpaceCount = new PerformanceCounter[DriveCount];
float[] FreeSpace = new float[DriveCount];
void ReadFreeDiskSpace()
{
for (int i = 0; i < DriveCount - 1; i++)
{
FreeSpace[i] = DriveSpaceCount[i].NextValue();
}
}
It works once, but the values do not change when I recall the function,
even when the Counter is recreated (DriveSpaceCount[i] = new PerformanceCounter("LogicalDisk","Free Megabytes",DriveLetters[i]); in the loop)
The only way to get new values is to restart the program.
Why?
Thanks in advance.
----------------------
I think war is a dangerous place.
George W. Bush - Washington DC, May 7th 2003
|
|
|
|
|
I think the problem comes from that don't to Close the counter so the resources are not being free.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Naw...
It doesn't change anything.
What really wonders me is that it doesn't work even when I dispose the Counter and create a new one.
Strange computers....
----------------------
I think war is a dangerous place.
George W. Bush - Washington DC, May 7th 2003
|
|
|
|
|
|
Thanks.
The website doesn't want to work, but thanks for the hint.
----------------------
I think war is a dangerous place.
George W. Bush - Washington DC, May 7th 2003
|
|
|
|
|
In order to make visible a new node in a TreeView, node added at runtime, do I have to repaint again the whole tree (with the BeginUpdate and EndUpdate methods)? Or is there a way to make the new node visible too?
Thank you in advance.
Best regards,
Cristina
|
|
|
|
|
I don't think its needed. Its just using when you want to edit large numbers of nodes.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Hey guys
I am not a J# guy at all but made the unfortunate mistake of using the J# zip classes in a .NET app of mine The app takes a zip file, strips off certain filtered files and writes a new zip file. The issue is that this new zip file is somehow slightly corrupted. I can't read the app-written zip using my app, but WinZip reads it correctly and can extract it correctly too; but even WinZip cannot do a direct delete of an entry (from within WinZip) - it shows some header corrupt error. I am not sure whether the issue is with the ZipFile constructor (while reading) or with the ZipOutputStream class (while writing).
Google searches tell me that this is a known bug and a Microsoft person's suggested workaround was to extract all files with WinZip and rezip it using WinZip. I almost choked with horror at the very idea that this was even remotely a workaround Gosh! I mean if I could do that using WinZip, then why use these zip classes at all, eh?
Anyway I just wanted to know if there is any hotfix or patch that's ready for fixing this bug? Thanks in advance for any help.
Now with my own blog - void Nish(char* szBlog);
My MVP tips, tricks and essays web site - www.voidnish.com
Request - Could everyone who have in the past, posted on my personal forum on CP, be kind enough to delete all your posts please? I intend to start a personal non-technical blog there, now that it is RSSd and would very much like to empty the forum before I do so - because the posts that are there as of now are mostly test posts and posts that were made before we all knew it was a blog
|
|
|
|
|
Not that I'm aware of but I do have some alternatives for zip libraries.
I've used this one before and it works well.
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx[^]
I think there is also a paid alternative from XCeed soft
http://www.xceedsoft.com/products/ZipCompL/index.htm[^]
I somehow dont like hotfixes (for obvious reasons it needs to be sent along with your app and made sure that all the clients install it), which is a major pain.
Anyway, I'm very curious why did you even think of J#, you know that you need a redistributable thingy when you touch it.
Regards,
Kannan
|
|
|
|
|
Kannan Kalyanaraman wrote:
I've used this one before and it works well.
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx[^]
Yup - that's what I am using now. It doesn't work as well as I want it to - but it's fine for my current purposes
Kannan Kalyanaraman wrote:
I think there is also a paid alternative from XCeed soft
http://www.xceedsoft.com/products/ZipCompL/index.htm[^]
Uhm, not looking for pay-ware
Kannan Kalyanaraman wrote:
Anyway, I'm very curious why did you even think of J#, you know that you need a redistributable thingy when you touch it.
This app is for me - to help me when I am editing. I don't intend to distribute it - though maybe I could upload it to the CP tools section for the other editors. It's too simple an app though Just removes unwanted/disallowed files from the zip.
Nish
Now with my own blog - void Nish(char* szBlog);
My MVP tips, tricks and essays web site - www.voidnish.com
Request - Could everyone who have in the past, posted on my personal forum on CP, be kind enough to delete all your posts please? I intend to start a personal non-technical blog there, now that it is RSSd and would very much like to empty the forum before I do so - because the posts that are there as of now are mostly test posts and posts that were made before we all knew it was a blog
|
|
|
|
|
Nishant S wrote:
Yup - that's what I am using now. It doesn't work as well as I want it to - but it's fine for my current purposes
Its based on the zlib impl. so i'm sure its not very friendly in terms of API usability, but its free
As far the paid part I happened to use that in one of my projects when .net was on its initial stage and I think sharpzip was just on its initialstage or was not stable(i dont remember now).
Anyway, didn't know that you are using it for your personal stuff
I'm now having a horrible time with the vs.net ide with some huge no. of projects, it just sucks :
you seemed to have cleaned up most of the stuff from your page, I guess the left overs would be difficult to erase, offcourse you can ask the CP God
Regards,
Kannan
|
|
|
|
|
Kannan Kalyanaraman wrote:
you seemed to have cleaned up most of the stuff from your page, I guess the left overs would be difficult to erase
Yup - the last few are a little tough Dont even know if those people come here any more.
Nish
Now with my own blog - void Nish(char* szBlog);
My MVP tips, tricks and essays web site - www.voidnish.com
Request - Could everyone who have in the past, posted on my personal forum on CP, be kind enough to delete all your posts please? I intend to start a personal non-technical blog there, now that it is RSSd and would very much like to empty the forum before I do so - because the posts that are there as of now are mostly test posts and posts that were made before we all knew it was a blog
|
|
|
|
|
BTW what makes me mad is that there is not even a KB article describing the bug in the zip class library
Nish
Now with my own blog - void Nish(char* szBlog);
My MVP tips, tricks and essays web site - www.voidnish.com
Request - Could everyone who have in the past, posted on my personal forum on CP, be kind enough to delete all your posts please? I intend to start a personal non-technical blog there, now that it is RSSd and would very much like to empty the forum before I do so - because the posts that are there as of now are mostly test posts and posts that were made before we all knew it was a blog
|
|
|
|
|
The .NET FCL 2.0 will include compression streams (at least it does now). Just FYI.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the info Heath. I am writing a bug-report-article for CP to save others the trouble I went through And I've mentioned this there.
Regards
Nish
Now with my own blog - void Nish(char* szBlog);
My MVP tips, tricks and essays web site - www.voidnish.com
Request - Could everyone who have in the past, posted on my personal forum on CP, be kind enough to delete all your posts please? I intend to start a personal non-technical blog there, now that it is RSSd and would very much like to empty the forum before I do so - because the posts that are there as of now are mostly test posts and posts that were made before we all knew it was a blog
|
|
|
|
|
Hey thats cool, where did you get that info from, I haven't seen this one mentioned anywhere. Any idea if this stuff is in the March CTP drop.
|
|
|
|
|
Because I have the PDC bits of .NET 2.0 and VS.NET 2005 (being an MSDN subscriber).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|