5

I want to return from IDL an array of interfaces. I try this:

interface ISecurityPolicy : IDispatch{
[id(6)]          HRESULT GetPolicyList([out, ref, retval] SAFEARRAY(IEntityPolicy*)* result);
}

I get this warning(in VS 2010): Warning 1 warning MIDL2456: SAFEARRAY(interface pointer) doesn't work using midl generated proxy : [ Parameter 'result' of Procedure 'GetPolicyList' ( Interface 'ISecurityPolicy' ) ]

Is this a bogus warning as http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/thread/84a632a9-4e29-4a95-8da7-f7aedb650339 might suggest ?

Ghita
  • 4,465
  • 4
  • 42
  • 69
  • Drop the [ref] attribute, it doesn't make much sense. – Hans Passant Sep 08 '11 at 13:12
  • I'm afraid that I still get the warning for that too. On the other side, things work, you just have to adjust the return type as SAFEARRAY(IUnknown*)* to make things easier – Ghita Sep 08 '11 at 17:20
  • It could be a better idea for me to use a collection implementation for the same propose though. It would be much more clear, only more work to do :-) – Ghita Sep 09 '11 at 08:00

1 Answers1

2

Declaring this as:

interface ISecurityPolicy : IDispatch{
[id(6)]          HRESULT GetPolicyList([out, ref, retval] SAFEARRAY(IUnknown*)* result);
}

simplifies things a little for implementation of the interface. It could still be a better idea though instead of returning an array of interfaces to the caller to return it an iterator over the "collection".

Ghita
  • 4,465
  • 4
  • 42
  • 69