{"id":107137,"date":"2022-09-08T07:00:00","date_gmt":"2022-09-08T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=107137"},"modified":"2022-09-08T07:29:59","modified_gmt":"2022-09-08T14:29:59","slug":"20220908-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20220908-00\/?p=107137","title":{"rendered":"How do I consume raw COM interfaces from a Windows Runtime metadata file?"},"content":{"rendered":"<p>Suppose somebody gives you a Windows Runtime metadata file. You can use it from C++ by asking <code>cppwinrt.exe<\/code> to generate C++\/WinRT headers for them. But what if you are writing a C++ program that doesn&#8217;t use exceptions,\u00b9 or for a C program? You want to access the raw COM interfaces rather than the exception-based projection. What can you do?<\/p>\n<p>There is a raw COM counterpart to <code>cppwinrt.exe<\/code> which produces raw COM interfaces rather than C++\/WinRT projections. It goes by the name <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Windows.AbiWinRT\"> Microsoft.<wbr \/>Windows.<wbr \/>AbiWinRT<\/a>. You invoke it basically the same way you invoke <code>cppwinrt.exe<\/code>; the difference is that the output is raw COM header files, which you can include from your C or C++ project, and then either consume directly or wrap inside a non-exception-based smart pointer library like WRL.<\/p>\n<p>\u00b9 For example, video games operate under tight real-time constraints and typically <a href=\"https:\/\/www.youtube.com\/watch?v=IuJ79Og-CfU\"> restrict themselves to a subset of C++<\/a> that, among other things, does not use exceptions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There&#8217;s a handy tool for generating raw COM interfaces.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-107137","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>There&#8217;s a handy tool for generating raw COM interfaces.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/107137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=107137"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/107137\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=107137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=107137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=107137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}