restricted

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

Specifies that a member of a module, interface, or dispinterface cannot be called arbitrarily.

  
      [ restricted(  
   interfaces  
) ]  

Parameters

interfaces
One or more interfaces that may not be called arbitrarily on a COM object. This parameter is only valid when applied to a class.

The restricted C++ attribute has the same functionality as the restricted MIDL attribute.

The following code shows how to use the restricted attribute:

// cpp_attr_ref_restricted.cpp  
// compile with: /LD  
#include "windows.h"  
#include "unknwn.h"  
[module(name="MyLib")];  
  
[object, uuid("00000000-0000-0000-0000-000000000001")]  
__interface a  
{  
};  
  
[object, uuid("00000000-0000-0000-0000-000000000002")]  
__interface b  
{  
};  
  
[coclass, restricted(a,b), uuid("00000000-0000-0000-0000-000000000003")]  
class c : public a, public b  
{  
};  

Attribute Context

Applies toInterface method, interface, class, struct
RepeatableNo
Required attributescoclass (when applied to class or struct)
Invalid attributesNone

For more information about the attribute contexts, see Attribute Contexts.

IDL Attributes
Interface Attributes
Method Attributes
Attributes Samples

Show: