<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[WMI Win32_Processor]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe hier ein beispiel gefunden zu Win32_Processor und wollte frage wie ich die einzelnen Klassen-Variablen auslesen kann.</p>
<pre><code class="language-cpp">// wbemuuid.lib nicht vergessen!
#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
#include &lt;wbemdisp.h&gt;

int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
  ISWbemObjectSet* pObjectSet = NULL;
  ISWbemServices*  pServices  = NULL;
  ISWbemObject*    pObject    = NULL;
  IEnumVARIANT*    pEnumObj   = NULL;
  IUnknown*        pUnk       = NULL;
  VARIANT          varItem;
  HRESULT          hr;
  BSTR             bstrClass, bstrName;

    CoInitialize(NULL);

    if(SUCCEEDED(CoGetObject(OLESTR(&quot;winmgmts:&quot;), NULL, IID_ISWbemServices, (void**)&amp;pServices)))
    {
        bstrClass = SysAllocString(OLESTR(&quot;Win32_Processor&quot;));

        if(SUCCEEDED(pServices-&gt;InstancesOf(bstrClass, 0, NULL, &amp;pObjectSet)))
        {
            if(SUCCEEDED(pObjectSet-&gt;get__NewEnum(&amp;pUnk)))
            {
                if(SUCCEEDED(pUnk-&gt;QueryInterface(IID_IEnumVARIANT, (void**)&amp;pEnumObj)))
                {
                    while(S_OK == pEnumObj-&gt;Next(1, &amp;varItem, NULL))
                    {
                        if(FAILED(VariantChangeType(&amp;varItem, &amp;varItem, 0, VT_UNKNOWN)))
                        {
                            VariantClear(&amp;varItem);
                            continue;
                        }

                        pObject = NULL;                        
                        hr = V_UNKNOWN(&amp;varItem)-&gt;QueryInterface(IID_ISWbemObject, (void**)&amp;pObject);
                        VariantClear(&amp;varItem);

                        if(FAILED(hr))
                            continue;

                        bstrName = NULL;
                        pObject-&gt;GetObjectText_(0, &amp;bstrName);

                        MessageBoxW(NULL, bstrName, L&quot;Processor Info&quot;, MB_OK);

                        SysFreeString(bstrName);
                        pObject-&gt;Release();
                    }
                    pEnumObj-&gt;Release();
                }
                pUnk-&gt;Release();
            }
            pObjectSet-&gt;Release();
        }
        SysFreeString(bstrClass);
        pServices-&gt;Release();
    }

    CoUninitialize();
    return(0);
}
</code></pre>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/243897/wmi-win32_processor</link><generator>RSS for Node</generator><lastBuildDate>Sat, 04 Apr 2026 03:21:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/243897.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Jun 2009 17:28:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to WMI Win32_Processor on Mon, 22 Jun 2009 17:28:03 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe hier ein beispiel gefunden zu Win32_Processor und wollte frage wie ich die einzelnen Klassen-Variablen auslesen kann.</p>
<pre><code class="language-cpp">// wbemuuid.lib nicht vergessen!
#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
#include &lt;wbemdisp.h&gt;

int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
  ISWbemObjectSet* pObjectSet = NULL;
  ISWbemServices*  pServices  = NULL;
  ISWbemObject*    pObject    = NULL;
  IEnumVARIANT*    pEnumObj   = NULL;
  IUnknown*        pUnk       = NULL;
  VARIANT          varItem;
  HRESULT          hr;
  BSTR             bstrClass, bstrName;

    CoInitialize(NULL);

    if(SUCCEEDED(CoGetObject(OLESTR(&quot;winmgmts:&quot;), NULL, IID_ISWbemServices, (void**)&amp;pServices)))
    {
        bstrClass = SysAllocString(OLESTR(&quot;Win32_Processor&quot;));

        if(SUCCEEDED(pServices-&gt;InstancesOf(bstrClass, 0, NULL, &amp;pObjectSet)))
        {
            if(SUCCEEDED(pObjectSet-&gt;get__NewEnum(&amp;pUnk)))
            {
                if(SUCCEEDED(pUnk-&gt;QueryInterface(IID_IEnumVARIANT, (void**)&amp;pEnumObj)))
                {
                    while(S_OK == pEnumObj-&gt;Next(1, &amp;varItem, NULL))
                    {
                        if(FAILED(VariantChangeType(&amp;varItem, &amp;varItem, 0, VT_UNKNOWN)))
                        {
                            VariantClear(&amp;varItem);
                            continue;
                        }

                        pObject = NULL;                        
                        hr = V_UNKNOWN(&amp;varItem)-&gt;QueryInterface(IID_ISWbemObject, (void**)&amp;pObject);
                        VariantClear(&amp;varItem);

                        if(FAILED(hr))
                            continue;

                        bstrName = NULL;
                        pObject-&gt;GetObjectText_(0, &amp;bstrName);

                        MessageBoxW(NULL, bstrName, L&quot;Processor Info&quot;, MB_OK);

                        SysFreeString(bstrName);
                        pObject-&gt;Release();
                    }
                    pEnumObj-&gt;Release();
                }
                pUnk-&gt;Release();
            }
            pObjectSet-&gt;Release();
        }
        SysFreeString(bstrClass);
        pServices-&gt;Release();
    }

    CoUninitialize();
    return(0);
}
</code></pre>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1731166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1731166</guid><dc:creator><![CDATA[helmut_1337]]></dc:creator><pubDate>Mon, 22 Jun 2009 17:28:03 GMT</pubDate></item><item><title><![CDATA[Reply to WMI Win32_Processor on Mon, 22 Jun 2009 20:27:51 GMT]]></title><description><![CDATA[<p>Hallo, ich habe eine Klasse gebastelt:</p>
<pre><code class="language-cpp">//get: BSTR value = prozessor.Property(L&quot;Architecture&quot;);
//set: prozessor.Property(L&quot;Architecture&quot;, L&quot;blah&quot;);
BSTR CSWbemObject::Property(WCHAR *prop, WCHAR *value=NULL)
{
	BSTR rprop = 0;
	ISWbemPropertySet*  pPropSet    = NULL;
	ISWbemProperty*     pProp       = NULL;
	HRESULT             hr;
	VARIANT v;

	if (m_objWbemObject) // ISWbemObject*
	{
		if(!m_objWbemObject-&gt;get_Properties_(&amp;pPropSet))
		{
			v.vt = VT_EMPTY;
			BSTR bstrProperty = SysAllocString(prop);
			hr = pPropSet-&gt;Item(bstrProperty, 0, &amp;pProp);

			SysFreeString(bstrProperty);
			pPropSet-&gt;Release();

			if(!hr)
			{
				if (!value) // get
				{
					hr = pProp-&gt;get_Value(&amp;v);
					pProp-&gt;Release();
					if (!hr)
					{
						if (!VariantChangeType(&amp;v, &amp;v, 0, VT_BSTR))
						{
							rprop = v.bstrVal;
						}
						else VariantClear(&amp;v);
					}
				}
				else // put
				{
					v.vt = VT_BSTR;
					v.bstrVal = SysAllocString(value);
					pProp-&gt;put_Value(&amp;v);
					VariantClear(&amp;v);
				}
			}
		}
	}
	return rprop;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1731273</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1731273</guid><dc:creator><![CDATA[sapero]]></dc:creator><pubDate>Mon, 22 Jun 2009 20:27:51 GMT</pubDate></item></channel></rss>