Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

outRider

COM objects from C#

This topic is 5395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Basically, I need to grab various COM objects from within C#. I''ve added a ref to what I need and what have you, but the sample code for UPnP on Microsoft''s site is only in C++, and doesn''t make sense. Where he/she calls pDevices->get__NewEnum(&pUnknown); I call System.Collections.IEnumerator Enum = Devices.GetEnumerator(); but after that things get a little awkward. IEnumerator doesn''t expose any sort of QueryInterface method... It has a GetType method and maybe a Type object can retrieve the IUnknown interface for QueryInterface, but who knows. Does anyone have any experience with COM in C#? ------------ - outRider -

Share this post


Link to post
Share on other sites
Advertisement
Well, if anyone is interested all I had to do was cast the IEnumerator.Current property to a specific type and if the object supported that interface the cast would succeed, else throw an exception. No messing with QueryInterface(). Also works for variants, just use the object type and cast to whatever.

------------
- outRider -

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!