Hi everyone!
I'm a bit new to this aspect of C++ (I've never done programming like this to this extent) and I believe I have a problem with variable conversions.
What I'm doing is querying the WMI service for hardware information. I followed the MSDN closely and I can have the output shown to the console.
However, I'd like to go one step further and have this output thrown into a text file instead.
The code in question is this:
I've never dealt with Variants before (but I believe it stored information in the form of pointers which can be converted to different types depending on the need?)
I'd like to have the above output to a text file instead. However, just using the current form of bstr (this is VB String, yes?) does not produce the desired result (I get a chain of numbers instead of the string that is displayed in the console).
IE. This doesn't work:
and outputs:
"OS : 0016EA2C"
How would I go about converting it to the type I need so that it outputs correctly to a text file?
Thanks!
I'm a bit new to this aspect of C++ (I've never done programming like this to this extent) and I believe I have a problem with variable conversions.
What I'm doing is querying the WMI service for hardware information. I followed the MSDN closely and I can have the output shown to the console.
However, I'd like to go one step further and have this output thrown into a text file instead.
The code in question is this:
VARIANT vtProp; hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0); wcout << "OS Name : " << vtProp.bstrVal; << endl;
I've never dealt with Variants before (but I believe it stored information in the form of pointers which can be converted to different types depending on the need?)
I'd like to have the above output to a text file instead. However, just using the current form of bstr (this is VB String, yes?) does not produce the desired result (I get a chain of numbers instead of the string that is displayed in the console).
IE. This doesn't work:
myfile << "OS : " <<
and outputs:
"OS : 0016EA2C"
How would I go about converting it to the type I need so that it outputs correctly to a text file?
Thanks!
This post has been edited by aommaster: 11 August 2009 - 02:16 PM

Help
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.




Back to top









