Life of a techno-guru
Tuesday, February 28, 2006
  Quick VBscript
Well, today I briefly developed this script (under one minute I think) to grab a serial number from a remote computer using WMI. It's not exactly an elegant script, as it'll throw a nasty error if it can't contact the remote computer, although if you know the computer is most likely on, you should have no problems retrieving the serial # from it. Anyway, without further to do, here it is:

strComputer = inputbox("Computer name:")
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
sClass = "win32_bios"
sQuery = "select serialnumber from " & sClass
set results = objWMI.ExecQuery(sQuery)

for each result in results
wscript.echo strComputer & " :: " & result.serialnumber
next
 
Saturday, February 04, 2006
  Stunning results with multi-threaded application development
Wow ... I've just spent some time today studying multi-threaded application development, and have been absolutely amazed with the results from the multi-threaded test program I created. What kills me most about this new discovery of mine is how easy it is to spawn additional worker threads to make your application more responsive. Here's a great example of how you could use multi-threading: if your application is accessing data from a remote computer on a slow WAN link, you can tell you app to spawn a new thread for the data access, while your main user interface window can continue on in perfect bliss! This is almost exactly what I'm doing with my current test application when connecting to the WMI service on a remote computer. Additionally, since you can specify a different priority for a new thread, this is perfect for times you're running a particularly hefty (lower-priority) WMI query in the background and don't want to make your app lock up while it's in progress. In my future development of a computer management application, I will be sure to take advantage of this awesome, yet easily-implemented feature.

FYI: Don't forget to leave out the parentheses when you're specifying a delegate method, otherwise it'll think you're trying to call the function and give the the following compile-time error: "Method name expected"
 
  Solutions to problems
Well I've been hacking at a problem that I just figured out. In my code writing, I'm trying to access some information retained in the WMI repository on a computer, and I was having some issues with data conversions. I did some debugging of my own, and I found out that the type being returned from WMI was a uint64, and of course I'm expecting the conversion to be easy. It turns out you can't do an implicit/explicit cast on the value to get a 32-bit integer, which makes sense, and the System.Convert class in the .NET 2.0 Framework doesn't contain a ToUint32 method that takes a uint64 as a parameter (but the .NET 1.1 Framework does). Anyway, I finally figured out that I could call the ToString() method on the property value I was retrieving from WMI (the capacity property in the \\localhost\root\cimv2:Win32_PhysicalMemory class), and then convert the string to a int32. Finally!
 
Friday, February 03, 2006
  Creating a collection class
I came across this great article within the MSDN documentation that explains how to create your own collection class in .NET. It explains how to implement the Add() and Remove() methods along with the Item property to allow you to access a particular object in your collection via its index value. While they show the index as being an integer in this article, I am assuming that you can also use a string as an index.
 
My life of learning various things about technology including network administration, development, and 3D design

Name:
Location: Chicago, Illinois, United States
ARCHIVES
January 2006 / February 2006 / March 2006 / May 2006 / June 2006 / July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / January 2007 / February 2007 / March 2007 / April 2007 / May 2007 / June 2007 / August 2007 / December 2007 / January 2008 / March 2008 / April 2008 / June 2008 / July 2008 / September 2008 / December 2008 / January 2009 / February 2009 / March 2009 / May 2009 /


Powered by Blogger