1

I'm creating a desktop C++/WinRT project, and I'd like to declare a runtime class, using MIDL 3.0, that accepts certain Win32 types as method parameters. For example, structs like PROPERTYKEY.

This isn't possible, however, as those aren't MIDL 3.0-compatible types, and from what I understand, they can't be packaged up as objects using box_value either.

I've gone through the documentation and searched at length, but I can't seem to locate a solution. Any help is appreciated.

  • 1
    `PROPERTYKEY` is not a Windows Runtime type, but you can create your own equivalent. `struct PropertyKey { Guid Fmtid; UInt32 Pid; };` – Raymond Chen Mar 31 '23 at 05:23
  • And then would you recommend casting from one to the other? Or would an assignment work? –  Mar 31 '23 at 16:29
  • You would have to do your own conversion. Note that the convention in the Windows Runtime is to pass property keys as strings. You can use `PSPropertyKeyFromString` to convert the string to a `PROPERTYKEY`. – Raymond Chen Mar 31 '23 at 17:56
  • Okay, thanks. I have one last question: is there a way to pass an `IPropertyDescription` pointer to a WinRT class? Thanks again for your help. –  Mar 31 '23 at 18:51
  • All objects passed into or out of the Windows Runtime must be based on IInspectable. – Raymond Chen Mar 31 '23 at 18:55

0 Answers0