Life of a techno-guru
Saturday, February 04, 2006
  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!
 
Comments: Post a Comment



<< Home
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