> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Constrain

> IXtfApplicationClient::Constrain

# IXtfApplicationClient::Constrain

将具有指定包 moniker 的应用置于受约束模式。

## 语法

```cpp theme={null}
public:
HRESULT Constrain(
         LPCWSTR pszPackageMoniker
)  
```

### 参数

*pszPackageMoniker*\
类型：LPCWSTR

指向要置于受约束模式的应用的包 moniker 的指针。

### 返回值

类型：HRESULT

如果成功则返回 `S_OK`；否则返回 HRESULT 错误代码。

## 备注

此函数将 `pszPackageMoniker` 中指定的应用置于受约束模式。在受约束模式下，应用对预留系统资源的访问受到限制。使用 [Unconstrain](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapplication/classes/IXtfApplicationClient/methods/unconstrain-ixtfapplicationclient-xtfapplication-xbox-windows-m.md) 方法离开受约束模式并返回到完整模式。有关游戏生命周期状态的详细信息，请参阅 [XBOX 游戏生命周期 (NDA 主题)](https://docs.xbox.com/zh-CN/build/console-features/console-workflows/xbox-game-life-cycle.md)。

有关如何使用 XBOX Tools Framework (XTF) 对应用进行约束和解除约束以进行测试的详细信息，请参阅[应用程序管理 (xbapp.exe) (NDA 主题)](https://docs.xbox.com/zh-CN/tools/tools-console/commandlinetools/xbapp.md)。

## 要求

**头文件：** xtfapplication.h

**库：** xtfapplication.lib

**支持的平台：** Windows（用于 XBOX 主机工具）

## 另请参阅

[IXtfApplicationClient::Unconstrain](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapplication/classes/IXtfApplicationClient/methods/unconstrain-ixtfapplicationclient-xtfapplication-xbox-windows-m.md)\
[IXtfApplicationClient](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapplication/classes/IXtfApplicationClient/ixtfapplicationclient-xtfapplication-xbox-microsoft-t.md)\
[XtfApplication](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapplication/xtfapplication-xbox-microsoft-n.md)


## Related topics

- [PFPlayerProfileViewConstraints](https://docs.xbox.com/zh-CN/services/playfab/api-references/c/pftypes/structs/pfplayerprofileviewconstraints.md)
- [title_profile_view_constraints_changed](https://docs.xbox.com/zh-CN/services/playfab/api-references/events/PlayerIdentity/title-profile-view-constraints-changed.md)
- [游戏可持续性：实验室平台基线](https://docs.xbox.com/zh-CN/build/game-principles/sustainability/lab-platform-baselines.md)
- [XBOX 游戏能效基础要点](https://docs.xbox.com/zh-CN/build/game-principles/sustainability/energy-efficiency-essentials.md)
- [Unconstrain](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapplication/classes/IXtfApplicationClient/methods/unconstrain-ixtfapplicationclient-xtfapplication-xbox-windows-m.md)
