<?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 mal wieder (Win32_POTSModemToSerialPort)]]></title><description><![CDATA[<p>Hallo,<br />
Ich versuche gerade mir von WMI alle Modems an einem seriellen Port auflisten zu lassen.</p>
<p>Dafür ist &quot;Win32_POTSModemToSerialPort&quot; scheinbar ideal. Jedoch gibt es bei dieser Klasse das Objekt &quot;Win32_POTSModem ref Dependent;&quot; welches auf das Modem weist.</p>
<p>Wie komm ich an die Daten dieses Modems ran? IWbemClassObject::Get() liefert mir den String &quot;\\ACER-SEB\root\cimv2:Win32_POTSModem.DeviceID=&quot;PCI\\VEN_8086&amp;DEV_24C6&amp;SUBSYS_00641025&amp;REV_03\\3&amp;61AAA01&amp;0&amp;FE&quot; zurück.</p>
<p>Wie komm ich jetzt an die Modem-Daten ran? Muss ich da dann ein extra Query starten also (&quot;Select * FROM Win32_POTSModem WHERE DeviceID=&quot;....&quot;&quot;) oder gibt es da eine einfachere Möglichkeit, also kann ich direkt daraus ein IWbemClassObject bekommen?</p>
<p>Als Basis für den Programmteil mit WMI diente <a href="http://www.codeproject.com/system/UsingWMI.asp" rel="nofollow">http://www.codeproject.com/system/UsingWMI.asp</a> .</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/125314/wmi-mal-wieder-win32_potsmodemtoserialport</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 22:30:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/125314.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 05 Nov 2005 18:32:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Sat, 05 Nov 2005 18:32:51 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich versuche gerade mir von WMI alle Modems an einem seriellen Port auflisten zu lassen.</p>
<p>Dafür ist &quot;Win32_POTSModemToSerialPort&quot; scheinbar ideal. Jedoch gibt es bei dieser Klasse das Objekt &quot;Win32_POTSModem ref Dependent;&quot; welches auf das Modem weist.</p>
<p>Wie komm ich an die Daten dieses Modems ran? IWbemClassObject::Get() liefert mir den String &quot;\\ACER-SEB\root\cimv2:Win32_POTSModem.DeviceID=&quot;PCI\\VEN_8086&amp;DEV_24C6&amp;SUBSYS_00641025&amp;REV_03\\3&amp;61AAA01&amp;0&amp;FE&quot; zurück.</p>
<p>Wie komm ich jetzt an die Modem-Daten ran? Muss ich da dann ein extra Query starten also (&quot;Select * FROM Win32_POTSModem WHERE DeviceID=&quot;....&quot;&quot;) oder gibt es da eine einfachere Möglichkeit, also kann ich direkt daraus ein IWbemClassObject bekommen?</p>
<p>Als Basis für den Programmteil mit WMI diente <a href="http://www.codeproject.com/system/UsingWMI.asp" rel="nofollow">http://www.codeproject.com/system/UsingWMI.asp</a> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/908962</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/908962</guid><dc:creator><![CDATA[UB909]]></dc:creator><pubDate>Sat, 05 Nov 2005 18:32:51 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Sat, 05 Nov 2005 18:46:30 GMT]]></title><description><![CDATA[<p>Get erwartet doch als Argument den Namen der Eigenschaft, die du haben möchtest. Alternativ gibt es dort auch Methoden, um die einzelnen Eigenschaften des WMI-Objekts zu enumierieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/908970</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/908970</guid><dc:creator><![CDATA[masterofx32]]></dc:creator><pubDate>Sat, 05 Nov 2005 18:46:30 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Sun, 06 Nov 2005 10:42:22 GMT]]></title><description><![CDATA[<p>das Problem ist: wie komm ich dann an mein IWbemClassObject-Pointer ran? Wenn ich Get aufrufe bekomm ich ja nur den obigen string in meinen Variant geschrieben aber wie komm ich von dem Variant wieder zu einem IWbemClassObject?</p>
<p>Mein Code sieht bisher so aus:</p>
<pre><code class="language-cpp">CComPtr&lt; IWbemClassObject &gt; processor;
_variant_t var_val;
[...]
hr = processor-&gt;Get( L&quot;Dependent&quot;, 0, &amp;var_val, NULL, NULL );
if(SUCCEEDED(hr))
{
	_bstr_t str = var_val;
	std::cout &lt;&lt; &quot;Value: &quot; &lt;&lt; str &lt;&lt; std::endl;
}
</code></pre>
<p>Wenn ich die Werte über BeginEnumeration und Next abhole habe ich das gleiche Problem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/909271</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/909271</guid><dc:creator><![CDATA[UB909]]></dc:creator><pubDate>Sun, 06 Nov 2005 10:42:22 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Mon, 07 Nov 2005 00:40:38 GMT]]></title><description><![CDATA[<p>Was ist denn die Variable &quot;processor&quot;?</p>
<p>EDIT: Ach so, hatte nicht richtig gelesen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Hast du mal probiert, Get als Typ CIM_OBJECT zu übergeben und zu schauen, ob du dann einen Zeiger auf das entsprechende Objekt erhältst und keine String-Repräsentation?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/909757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/909757</guid><dc:creator><![CDATA[masterofx32]]></dc:creator><pubDate>Mon, 07 Nov 2005 00:40:38 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Sun, 06 Nov 2005 18:00:49 GMT]]></title><description><![CDATA[<p>das ist ein Objekt von &quot;Win32_POTSModemToSerialPort&quot; und von dem will ich die Eigenschaft &quot;dependent&quot; und die soll ein Objekt von der WMI-Klasse &quot;Win32_POTSModem&quot; enthalten. Und von dem brauch ich letzendlich die Eigenschaft &quot;Name&quot;.</p>
<p>Link zur Klasse Win32_POTSModemToSerialPort:<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_potsmodemtoserialport.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_potsmodemtoserialport.asp</a></p>
<p>das ist der komplette Code:</p>
<pre><code class="language-cpp">CComPtr&lt; IEnumWbemClassObject &gt; enumerator;
hr = service-&gt;ExecQuery( L&quot;WQL&quot;, L&quot;SELECT * FROM Win32_POTSModemToSerialPort&quot;,
							WBEM_FLAG_FORWARD_ONLY, NULL, &amp;enumerator );
if ( SUCCEEDED( hr ) )
{
	{
		// read the first instance from the enumeration (only one on single processor machines)
		CComPtr&lt; IWbemClassObject &gt; processor = NULL;
		ULONG retcnt;
		hr = enumerator-&gt;Next( WBEM_INFINITE, 1L, reinterpret_cast&lt;IWbemClassObject**&gt;( &amp;processor ), &amp;retcnt );
		if ( SUCCEEDED( hr ) )
		{
			if ( retcnt &gt; 0 )
			{
				// we have a processor installed :)
				// now extract a property value
				_variant_t var_val;
				hr = processor-&gt;Get( L&quot;Dependent&quot;, 0, &amp;var_val, NULL, NULL );
				//hr = processor-&gt;GetMethod( L&quot;Dependent&quot;, 0, NULL, reinterpret_cast&lt;IWbemClassObject**&gt;( &amp;modem));
				if ( SUCCEEDED( hr ) )
				{
					_bstr_t s[url]tr = var_val;
					std::cout &lt;&lt; &quot;Processor name: &quot; &lt;&lt; str &lt;&lt; std::endl;
				}
				else

// Jetzt kommt nur noch Fehlerbehandlung
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/909774</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/909774</guid><dc:creator><![CDATA[UB909]]></dc:creator><pubDate>Sun, 06 Nov 2005 18:00:49 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Sun, 06 Nov 2005 18:17:07 GMT]]></title><description><![CDATA[<p>masterofx32 schrieb:</p>
<blockquote>
<p>Hast du mal probiert, Get als Typ CIM_OBJECT zu übergeben und zu schauen, ob du dann einen Zeiger auf das entsprechende Objekt erhältst und keine String-Repräsentation?</p>
</blockquote>
<p>Geht das?<br />
pvtType ist als &quot;Out&quot; definiert.....</p>
<p>Edit:<br />
Ich hab jetzt mal geschaut was da rauskommt also pvtType wird &quot;CIM_REFERENCE&quot;. Also müsste es richtig sein... jetzt muss ich nur noch aus der komischen Reference ein C-Pointer bekommen....</p>
<p>Edit die 2.:<br />
der Variant ist allerdings vom Typ VT_BSTR.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/909781</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/909781</guid><dc:creator><![CDATA[UB909]]></dc:creator><pubDate>Sun, 06 Nov 2005 18:17:07 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Sun, 06 Nov 2005 18:34:24 GMT]]></title><description><![CDATA[<p>UB909 schrieb:</p>
<blockquote>
<p>masterofx32 schrieb:</p>
<blockquote>
<p>Hast du mal probiert, Get als Typ CIM_OBJECT zu übergeben und zu schauen, ob du dann einen Zeiger auf das entsprechende Objekt erhältst und keine String-Repräsentation?</p>
</blockquote>
<p>Geht das?<br />
pvtType ist als &quot;Out&quot; definiert.....</p>
</blockquote>
<p>Ach so, ja dann nicht.<br />
Was erhältst du denn wenn du den variant einem WBEmClassPointer zuweist? Naja, kann da im Moment auch nicht wirklich helfen. Hab zwar schon mit WMI gearbeitet aber bin noch nie solch einer Referenz gefolgt. Alles weitere wären also nur Mutmaßungen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/909831</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/909831</guid><dc:creator><![CDATA[masterofx32]]></dc:creator><pubDate>Sun, 06 Nov 2005 18:34:24 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Sun, 06 Nov 2005 18:41:02 GMT]]></title><description><![CDATA[<p>masterofx32 schrieb:</p>
<blockquote>
<p>UB909 schrieb:</p>
<blockquote>
<p>masterofx32 schrieb:</p>
<blockquote>
<p>Hast du mal probiert, Get als Typ CIM_OBJECT zu übergeben und zu schauen, ob du dann einen Zeiger auf das entsprechende Objekt erhältst und keine String-Repräsentation?</p>
</blockquote>
<p>Geht das?<br />
pvtType ist als &quot;Out&quot; definiert.....</p>
</blockquote>
<p>Ach so, ja dann nicht.<br />
Was erhältst du denn wenn du den variant einem WBEmClassPointer zuweist?</p>
</blockquote>
<p>zugriffsverletzung....</p>
<blockquote>
<p>Naja, kann da im Moment auch nicht wirklich helfen. Hab zwar schon mit WMI gearbeitet aber bin noch nie solch einer Referenz gefolgt. Alles weitere wären also nur Mutmaßungen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p>naja da weißt du immerhin noch deutlich mehr wie ich....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/909841</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/909841</guid><dc:creator><![CDATA[UB909]]></dc:creator><pubDate>Sun, 06 Nov 2005 18:41:02 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Mon, 07 Nov 2005 00:33:08 GMT]]></title><description><![CDATA[<p>Hab mir die Methoden nochmal angeschaut. Wenn die Eigenschaft wirklich nur als String abrufbar ist, wäre vielleicht die Methode <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/iwbemservices_getobject.asp" rel="nofollow">IWbemServices::GetObject</a> sinnvoll, um die referenzierte Instanz zu erhalten. Damit musst du dann auch kein neues Query ausführen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/910203</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/910203</guid><dc:creator><![CDATA[masterofx32]]></dc:creator><pubDate>Mon, 07 Nov 2005 00:33:08 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Mon, 07 Nov 2005 12:13:36 GMT]]></title><description><![CDATA[<p>Ok so funktionierts.... Danke...</p>
<p>Ich werde den Code dann mal Posten wenn ich ihn ein bisschen übersichtlicher gemacht habe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/910470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/910470</guid><dc:creator><![CDATA[UB909]]></dc:creator><pubDate>Mon, 07 Nov 2005 12:13:36 GMT</pubDate></item><item><title><![CDATA[Reply to WMI mal wieder (Win32_POTSModemToSerialPort) on Mon, 07 Nov 2005 17:25:23 GMT]]></title><description><![CDATA[<p>So und nun noch den Versprochenen Code (falls es jemand mal brauchen kann).</p>
<pre><code class="language-cpp">CComPtr&lt; IWbemLocator &gt; locator;

hr = CoCreateInstance( CLSID_WbemAdministrativeLocator, NULL,
					CLSCTX_INPROC_SERVER,
					IID_IWbemLocator, reinterpret_cast&lt; void** &gt;( &amp;locator ) );
if ( FAILED( hr ) )
{
	std::cerr &lt;&lt; &quot;Instantiation of IWbemLocator failed&quot; &lt;&lt; std::endl;
	return -1;
}

CComPtr&lt; IWbemLocator &gt; locator;
// connect to local service with current credentials
CComPtr&lt; IWbemServices &gt; service;
hr = locator-&gt;ConnectServer( L&quot;root\\cimv2&quot;, NULL, NULL, NULL,
								WBEM_FLAG_CONNECT_USE_MAX_WAIT,
								NULL, NULL, &amp;service );
if ( SUCCEEDED( hr ) )
{
	// execute a query
	CComPtr&lt; IEnumWbemClassObject &gt; enumerator;
	hr = service-&gt;ExecQuery( L&quot;WQL&quot;, L&quot;SELECT * FROM Win32_POTSModemToSerialPort&quot;,
								WBEM_FLAG_FORWARD_ONLY, NULL, &amp;enumerator );

	if ( SUCCEEDED( hr ) )
	{
		// read the first instance from the enumeration (only one on single processor machines)
		IWbemClassObject *ModemToSerial = NULL;
		ULONG retcnt;

		// Get First ModemToSerialPort-Object
		hr = enumerator-&gt;Next(WBEM_INFINITE, 1L, reinterpret_cast&lt;IWbemClassObject**&gt;( &amp;ModemToSerial ), &amp;retcnt );

		// Enumerate the other Modems.
		while((SUCCEEDED(hr)) &amp;&amp; (retcnt &gt; 0))
		{
			IWbemClassObject *Modem = NULL;
			IWbemClassObject *SerialPort = NULL;
			_variant_t varModemReference;
			_variant_t varSerialPortReference;
			std::wstring sModemName;
			std::wstring sSerialPort;

			// Get String to the Win32_POTSModem-Reference
			hr = ModemToSerial-&gt;Get(L&quot;Dependent&quot;, 0, &amp;varModemReference, NULL, NULL );
			if(SUCCEEDED (hr))
			{
				// Get Object of the String.
				hr = service-&gt;GetObject(varModemReference.bstrVal, 0, NULL, &amp;Modem, NULL); 
				if(SUCCEEDED (hr))
				{
					_variant_t varModem;

					// Get the Name or the wanted Value of Win32_POTSModem.
					hr = Modem-&gt;Get(L&quot;Name&quot;, 0, &amp;varModem, NULL, NULL );
					if(SUCCEEDED (hr))
					{
						sModemName = varModem.bstrVal;
					}
				}
			}

			// Get String to the Win32_SerialPort-Reference
			hr = ModemToSerial-&gt;Get(L&quot;Antecedent&quot;, 0, &amp;varSerialPortReference, NULL, NULL );
			if(SUCCEEDED (hr))
			{
				// Get Object of the String.
				hr = service-&gt;GetObject(varSerialPortReference.bstrVal, 0, NULL, &amp;SerialPort, NULL); 
				if(SUCCEEDED (hr))
				{
					_variant_t varSerialPort;

					// Get the Name or the wanted Value of Win32_POTSModem.
					hr = SerialPort-&gt;Get(L&quot;DeviceID&quot;, 0, &amp;varSerialPort, NULL, NULL );
					if(SUCCEEDED (hr))
					{
						sSerialPort = varSerialPort.bstrVal;
					}
				}
			}

			// Release Pointer
			SAFE_RELEASE(ModemToSerial);
			SAFE_RELEASE(SerialPort);
			SAFE_RELEASE(Modem);

			// Get Next ModemToSerialPort-Object
			hr = enumerator-&gt;Next(WBEM_INFINITE, 1L, reinterpret_cast&lt;IWbemClassObject**&gt;( &amp;ModemToSerial ), &amp;retcnt );
		}
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/910808</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/910808</guid><dc:creator><![CDATA[UB909]]></dc:creator><pubDate>Mon, 07 Nov 2005 17:25:23 GMT</pubDate></item></channel></rss>