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

# XAppCaptureStartUserRecord

> XAppCaptureStartUserRecord

# XAppCaptureStartUserRecord

ユーザーがトリガーしたかのように録画します。 録画中にプレイヤーがゲームを中断/制約すると、録画は停止します。 録画はユーザー パーティションに保存されます。 キャプチャ設定は GameDVR 設定に基づきます。 同時録画数の制限に達すると、別の録画を開始する前に [XAppCaptureStopUserRecord](/reference/system/xappcapture/functions/xappcapturestopuserrecord) または [XAppCaptureCancelUserRecord](/reference/system/xappcapture/functions/xappcapturecanceluserrecord) を呼び出す必要があります。 Windows でのこの API のサポートは、将来のリリースで追加される予定です。

## 構文

```cpp theme={null}
HRESULT XAppCaptureStartUserRecord(
    XUserHandle requestingUser,
    uint32_t localIdBufferLength,
    char* localIdBuffer
)
```

### パラメーター

*requestingUser* \_In\_\
型: XUserHandle

録画を要求するユーザーを表すハンドルです。

*localIdBufferLength* \_In\_\
型: uint32\_t

ローカル録画 ID を受け取るバッファーの長さです。

*localIdBuffer* \_Out\_\
型: char\*

進行中の録画操作を指定するローカル ID を含むバッファーです。

### 戻り値

型: HRESULT

関数の結果です。 `S_OK` 以外の戻り値については、「[XAppCapture エラー コード](/reference/system/xappcapture/xappcapture_errors)」を参照してください。

## 解説

関数が正常に完了すると、localIdOfUserRecording には録画のローカル ID が含まれ、[XAppCaptureStopUserRecord](/reference/system/xappcapture/functions/xappcapturestopuserrecord) または [XAppCaptureCancelUserRecord](/reference/system/xappcapture/functions/xappcapturecanceluserrecord) を使用して特定の録画を停止するために保存する必要があります。

<Note>割り当てられた容量がいっぱいになると、新しいクリップ用のスペースを確保するために古いクリップは削除されます。 一定期間クリップを保持するには、[PLS](/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members) (Persistent Local Storage)、コネクテッド ストレージ (例: [XGameSave](/reference/system/xgamesave/xgamesave_members) または [XGameSaveFiles](/reference/system/xgamesavefiles/xgamesavefiles_members))、または類似のストレージ システムを使用してください。</Note>

```cpp theme={null}
char localIdOfUserRecording[APPCAPTURE_MAX_LOCALID_LENGTH] = { '\0' };

XAppCaptureVideoCaptureSettings captureSettings = { 0 };
if (FAILED_LOG(XAppCaptureGetVideoCaptureSettings(&captureSettings)))
{
    return;
}

if (captureSettings.isCaptureByGamesAllowed)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = g_taskQueue;
    asyncBlock->callback = [](XAsyncBlock* ab)
    {
        auto asyncBlock = std::unique_ptr<XAsyncBlock>(ab);

        XUserHandle user = nullptr;
        auto scopeExit = wil::scope_exit([&]()
        {
            if (user != nullptr)
            {
                XUserCloseHandle(user);
            }
        });

        if (FAILED_LOG(XUserAddResult(asyncBlock.get(), &user)))
        {
            return;
        }

        if (FAILED_LOG(XAppCaptureStartUserRecord(user, ARRAYSIZE(localIdOfUserRecording), localIdOfUserRecording)))
        {
            return;
        }
        appLog.AddLog("Recording started: localId = %s\n", localIdOfUserRecording);
    };

    if (SUCCEEDED_LOG(XUserAddAsync(
        XUserAddOptions::AddDefaultUserAllowingUI,
        asyncBlock.get())))
    {
        // Once started, release the pointer
        asyncBlock.release();
    }
}
```

## 要件

**ヘッダー:** XAppCapture.h

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** XBOX One ファミリー本体、XBOX Series 本体

## 関連項目

[XAppCapture メンバー](/reference/system/xappcapture/xappcapture_members)


## Related topics

- [XAppCaptureUserRecordingResult](/ja-jp/reference/system/xappcapture/structs/xappcaptureuserrecordingresult.md)
- [XAppCaptureCancelUserRecord](/ja-jp/reference/system/xappcapture/functions/xappcapturecanceluserrecord.md)
- [XAppCaptureStopUserRecord](/ja-jp/reference/system/xappcapture/functions/xappcapturestopuserrecord.md)
- [XAppCapture](/ja-jp/reference/system/xappcapture/xappcapture_members.md)
- [XAppCaptureRecordTimespan](/ja-jp/reference/system/xappcapture/functions/xappcapturerecordtimespan.md)
