> ## 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.

# QueryExecutionState

> IXtfApplicationClient::QueryExecutionState

# IXtfApplicationClient::QueryExecutionState

查詢具有指定套件 Moniker 之應用程式的執行狀態。

## 語法

```cpp theme={null}
public:
HRESULT QueryExecutionState(
         LPCWSTR pszPackageMoniker,
         DWORD *dwState
)  
```

### 參數

*pszPackageMoniker*\
類型：LPCWSTR

指向要查詢之應用程式的套件 Moniker 的指標。

*dwState*\
類型：DWORD\*

指標，接收應用程式的執行狀態。此參數會設定為下表所列的其中一個值。

| 常數 | 值 | 描述 |
| - | - | - |
| Unknown | 0 | 應用程式的執行狀態不明。 |
| Running | 1 | 應用程式目前正在執行。 |
| Suspending | 2 | 應用程式正在暫停中。 |
| Suspended | 3 | 應用程式的執行目前已暫停。 |
| Terminated | 4 | 應用程式已終止。 |

### 傳回值

類型：HRESULT

如果成功，則傳回 `S_OK`；否則會傳回 HRESULT 錯誤碼。

## 備註

此方法會查詢具有指定套件名稱之應用程式的執行狀態。此方法類似於應用程式管理 (xbapp.exe) 工具中的 `xbapp query` 命令，該工具隨附於 XBOX Tools Framework (XTF) 中。如需 `xbapp query` 命令的詳細資訊，請參閱[應用程式管理 (xbapp.exe) (NDA 主題)](https://docs.xbox.com/zh-TW/tools/tools-console/commandlinetools/xbapp.md)。

如需遊戲生命週期狀態的詳細資訊，請參閱 [XBOX 遊戲生命週期 (NDA 主題)](https://docs.xbox.com/zh-TW/build/console-features/console-workflows/xbox-game-life-cycle.md)。

## 需求

**標頭：** xtfapplication.h

**程式庫：** xtfapplication.lib

**支援的平台：** Windows (適用於 XBOX 主機工具)

## 另請參閱

[IXtfApplicationClient 介面](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfapplication/classes/IXtfApplicationClient/ixtfapplicationclient-xtfapplication-xbox-microsoft-t.md)\
[XtfApplication](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfapplication/xtfapplication-xbox-microsoft-n.md)


## Related topics

- [IXtfApplicationClient 介面 (介面內容)](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfapplication/classes/IXtfApplicationClient/ixtfapplicationclient-xtfapplication-xbox-microsoft-t.md)
- [Query](https://docs.xbox.com/zh-TW/reference/system/dstorage/interfaces/IDStorageQueueX/methods/idstoragequeuex_query.md)
- [ScriptExecutionError](https://docs.xbox.com/zh-TW/services/playfab/api-references/events/data-types/scriptexecutionerror.md)
- [ActionExecutionError](https://docs.xbox.com/zh-TW/services/playfab/api-references/events/data-types/actionexecutionerror.md)
- [/handles/query](https://docs.xbox.com/zh-TW/reference/live/rest/uri/sessiondirectory/uri-handlesquery.md)
