|
1 | | ---- |
2 | | -title: "requires_category | Microsoft Docs" |
3 | | -ms.custom: "" |
4 | | -ms.date: "11/04/2016" |
5 | | -ms.technology: ["cpp-windows"] |
6 | | -ms.topic: "reference" |
7 | | -f1_keywords: ["vc-attr.requires_category"] |
8 | | -dev_langs: ["C++"] |
9 | | -helpviewer_keywords: ["requires_category attribute"] |
10 | | -ms.assetid: a645fdc6-1ef5-414d-8c56-5fe2686d4687 |
11 | | -author: "mikeblome" |
12 | | -ms.author: "mblome" |
13 | | -ms.workload: ["cplusplus", "uwp"] |
14 | | ---- |
15 | | -# requires_category |
16 | | -Specifies the required component categories of the target class. |
17 | | - |
18 | | -## Syntax |
19 | | - |
20 | | -``` |
21 | | - |
22 | | - [ requires_category( |
23 | | - requires_category |
24 | | -) ] |
25 | | -``` |
26 | | - |
27 | | -#### Parameters |
28 | | - *requires_category* |
29 | | - The ID of the required category. |
30 | | - |
31 | | -## Remarks |
32 | | - The **requires_category** C++ attribute specifies the component categories required by the target class. For more information, see [REQUIRED_CATEGORY](../atl/reference/category-macros.md#required_category). |
33 | | - |
34 | | - This attribute requires that the [coclass](../windows/coclass.md), [progid](../windows/progid.md), or [vi_progid](../windows/vi-progid.md) attribute (or another attribute that implies one of these) also be applied to the same element. |
35 | | - |
36 | | -## Example |
37 | | - The following code requires that the object implement the Control category. |
38 | | - |
39 | | -``` |
40 | | -// cpp_attr_ref_requires_category.cpp |
41 | | -// compile with: /LD |
42 | | -#define _ATL_ATTRIBUTES |
43 | | -#include "atlbase.h" |
44 | | -#include "atlcom.h" |
45 | | - |
46 | | -[module (name="MyLibrary")]; |
47 | | - |
48 | | -[ coclass, requires_category("CATID_Control"), |
49 | | - uuid("1e1a2436-f3ea-4ff3-80bf-5409370e8144")] |
50 | | -class CMyClass {}; |
51 | | -``` |
52 | | - |
53 | | -## Requirements |
54 | | - |
55 | | -### Attribute Context |
56 | | - |
57 | | -||| |
58 | | -|-|-| |
59 | | -|**Applies to**|**class**, `struct`| |
60 | | -|**Repeatable**|No| |
61 | | -|**Required attributes**|One or more of the following: **coclass**, **progid**, or **vi_progid**.| |
62 | | -|**Invalid attributes**|None| |
63 | | - |
64 | | - For more information about the attribute contexts, see [Attribute Contexts](../windows/attribute-contexts.md). |
65 | | - |
66 | | -## See Also |
67 | | - [COM Attributes](../windows/com-attributes.md) |
68 | | - [implements_category](../windows/implements-category.md) |
| 1 | +--- |
| 2 | +title: "requires_category | Microsoft Docs" |
| 3 | +ms.custom: "" |
| 4 | +ms.date: "11/04/2016" |
| 5 | +ms.technology: ["cpp-windows"] |
| 6 | +ms.topic: "reference" |
| 7 | +f1_keywords: ["vc-attr.requires_category"] |
| 8 | +dev_langs: ["C++"] |
| 9 | +helpviewer_keywords: ["requires_category attribute"] |
| 10 | +ms.assetid: a645fdc6-1ef5-414d-8c56-5fe2686d4687 |
| 11 | +author: "mikeblome" |
| 12 | +ms.author: "mblome" |
| 13 | +ms.workload: ["cplusplus", "uwp"] |
| 14 | +--- |
| 15 | +# requires_category |
| 16 | +Specifies the required component categories of the target class. |
| 17 | + |
| 18 | +## Syntax |
| 19 | + |
| 20 | +``` |
| 21 | +[ requires_category( |
| 22 | + requires_category |
| 23 | +) ] |
| 24 | +``` |
| 25 | + |
| 26 | +#### Parameters |
| 27 | + *requires_category* |
| 28 | + The ID of the required category. |
| 29 | + |
| 30 | +## Remarks |
| 31 | + The **requires_category** C++ attribute specifies the component categories required by the target class. For more information, see [REQUIRED_CATEGORY](../atl/reference/category-macros.md#required_category). |
| 32 | + |
| 33 | + This attribute requires that the [coclass](../windows/coclass.md), [progid](../windows/progid.md), or [vi_progid](../windows/vi-progid.md) attribute (or another attribute that implies one of these) also be applied to the same element. |
| 34 | + |
| 35 | +## Example |
| 36 | + The following code requires that the object implement the Control category. |
| 37 | + |
| 38 | +```cpp |
| 39 | +// cpp_attr_ref_requires_category.cpp |
| 40 | +// compile with: /LD |
| 41 | +#define _ATL_ATTRIBUTES |
| 42 | +#include "atlbase.h" |
| 43 | +#include "atlcom.h" |
| 44 | + |
| 45 | +[module (name="MyLibrary")]; |
| 46 | + |
| 47 | +[ coclass, requires_category("CATID_Control"), |
| 48 | + uuid("1e1a2436-f3ea-4ff3-80bf-5409370e8144")] |
| 49 | +class CMyClass {}; |
| 50 | +``` |
| 51 | + |
| 52 | +## Requirements |
| 53 | + |
| 54 | +### Attribute Context |
| 55 | + |
| 56 | +||| |
| 57 | +|-|-| |
| 58 | +|**Applies to**|**class**, **struct**| |
| 59 | +|**Repeatable**|No| |
| 60 | +|**Required attributes**|One or more of the following: `coclass`, `progid`, or `vi_progid`.| |
| 61 | +|**Invalid attributes**|None| |
| 62 | + |
| 63 | + For more information about the attribute contexts, see [Attribute Contexts](../windows/attribute-contexts.md). |
| 64 | + |
| 65 | +## See Also |
| 66 | + [COM Attributes](../windows/com-attributes.md) |
| 67 | + [implements_category](../windows/implements-category.md) |
0 commit comments