<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - Writing a managed version of ICreateDevEnum</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - Writing a managed version of ICreateDevEnum</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Mon, 20 May 2013 06:32:04 GMT</pubDate>
	<lastBuildDate>Mon, 20 May 2013 06:32:04 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>3</c9:totalResults>
	<c9:pageCount>-3</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - Writing a managed version of ICreateDevEnum</title>
		<description><![CDATA[<p>I have the following interface from &quot;strmif.h&quot; (DirectShow stuff):<br>
<br>
&nbsp;&nbsp;&nbsp; MIDL_INTERFACE(&quot;29840822-5B84-11D0-BD3B-00A0C911CE86&quot;)<br>
&nbsp;&nbsp;&nbsp; ICreateDevEnum : public IUnknown<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; public:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; virtual HRESULT STDMETHODCALLTYPE CreateClassEnumerator( <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* [in] */ REFCLSID clsidDeviceClass,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* [out] */ IEnumMoniker **ppEnumMoniker,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* [in] */ DWORD dwFlags) = 0;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; };<br>
<br>
I have found it described in C# like this (in a project called DShow.NET):<br>
<br>
&nbsp;&nbsp;&nbsp; [ComVisible(true), ComImport,<br>
&nbsp;&nbsp;&nbsp; Guid(&quot;29840822-5B84-11D0-BD3B-00A0C911CE86&quot;),<br>
&nbsp;&nbsp;&nbsp; InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]<br>
public interface ICreateDevEnum<br>
{<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [PreserveSig]<br>
&nbsp;&nbsp;&nbsp; int CreateClassEnumerator(<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [In]&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ref Guid&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pType,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [Out]&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; out UCOMIEnumMoniker&nbsp;&nbsp;&nbsp; ppEnumMoniker,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [In]&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dwFlags );<br>
}<br>
<br>
The generated MSIL for the function is:<br>
<br>
.method public hidebysig newslot abstract virtual <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; instance int32&nbsp; CreateClassEnumerator([in] valuetype [mscorlib]System.Guid&amp; pType,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [out] class [mscorlib]System.Runtime.InteropServices.UCOMIEnumMoniker&amp; ppEnumMoniker,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [in] int32 dwFlags) cil managed preservesig<br>
{<br>
} // end of method ICreateDevEnum::CreateClassEnumerator<br>
<br>
<br>
And now my question is: How to represent this interface in C&#43;&#43;/CLI? I use VS2005, and tried several times, but it doesn't compile. I am stuck on the IEnumMoniker parameter, don't know how to declare it.<br>
<br>
Does anyone have an idea on how to write this interface in C&#43;&#43;/CLI, so that I am able to cast the COM server 'SystemDeviceEnum' to the interface 'ICreateDevEnum'?<br>
<br>
Thanks,<br>
Cosmin<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/166409-Writing-a-managed-version-of-ICreateDevEnum/166409#166409</link>
		<pubDate>Sat, 11 Mar 2006 20:10:24 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/166409-Writing-a-managed-version-of-ICreateDevEnum/166409#166409</guid>
		<dc:creator>cosminb</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/cosminb/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Writing a managed version of ICreateDevEnum</title>
		<description><![CDATA[<p>Actually the whole problem reduces to being able to pass an interface as a parameter to a function:<br>
<br>
namespace InterfaceTest<br>
{<br>
<br>
&nbsp;&nbsp;&nbsp; public interface class Intf<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void Read();<br>
&nbsp;&nbsp;&nbsp; };<br>
<br>
&nbsp;&nbsp;&nbsp; public ref class Class1<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void Something(Intf i)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; };<br>
<br>
}<br>
<br>
<br>
This yields on the function 'Something':<br>
<br>
error C3149: 'InterfaceTest::Intf' : cannot use this type here without a top-level '^'<br>
<br>
Thanks<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/166409-Writing-a-managed-version-of-ICreateDevEnum/7e32ddc70c904a9b8f1e9dea01390803#7e32ddc70c904a9b8f1e9dea01390803</link>
		<pubDate>Sat, 11 Mar 2006 20:51:57 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/166409-Writing-a-managed-version-of-ICreateDevEnum/7e32ddc70c904a9b8f1e9dea01390803#7e32ddc70c904a9b8f1e9dea01390803</guid>
		<dc:creator>cosminb</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/cosminb/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Writing a managed version of ICreateDevEnum</title>
		<description><![CDATA[<p><blockquote>
<div>cosminb wrote:</div>
<div>namespace InterfaceTest<br>
{<br>
<br>
&nbsp;&nbsp;&nbsp; public interface class Intf<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void Read();<br>
&nbsp;&nbsp;&nbsp; };<br>
<br>
&nbsp;&nbsp;&nbsp; public ref class Class1<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void Something(Intf i)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; };<br>
<br>
}</div>
</blockquote>
<br>
The change is in red:<br>
<br>
namespace InterfaceTest<br>
{<br>
<br>
&nbsp;&nbsp;&nbsp; public interface class Intf<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void Read();<br>
&nbsp;&nbsp;&nbsp; };<br>
<br>
&nbsp;&nbsp;&nbsp; public ref class Class1<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void Something(Intf ^i)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; };<br>
<br>
}<br>
<br>
EDIT: Since the original interface takes a double pointer to the interface, you're probably going to need &quot;void Something(Intf ^%i)&quot; there to pass a tracking reference to the managed pointer.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/166409-Writing-a-managed-version-of-ICreateDevEnum/3965c2646eb443b8a1b99dea0139082f#3965c2646eb443b8a1b99dea0139082f</link>
		<pubDate>Sun, 12 Mar 2006 22:05:25 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/166409-Writing-a-managed-version-of-ICreateDevEnum/3965c2646eb443b8a1b99dea0139082f#3965c2646eb443b8a1b99dea0139082f</guid>
		<dc:creator>Sven Groot</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Sven Groot/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>