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

# XPersistentLocalStorageMountForPackage

> XPersistentLocalStorageMountForPackage

# XPersistentLocalStorageMountForPackage

指定されたパッケージの永続ローカル ストレージ (PLS) を読み取り専用ディスクとしてマウントします。

## Syntax

```cpp theme={null}
HRESULT XPersistentLocalStorageMountForPackage (   
         const char* packageIdentifier,   
         XPackageMountHandle* mountHandle 
) 
```

### Parameters

*packageIdentifier*   \_In\_\
型: char\*

PLS が属するストア パッケージを一意に識別する文字列。パッケージ識別子の詳細については、[ダウンロード可能なコンテンツ (DLC) の管理およびライセンス](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-dlc.md) を参照してください。

*mountHandle*   \_Out\_writes\_to\_(pathSize,*pathUsed)\
型: XPackageMountHandle*

PLS がマウントされたディスクのマウント ハンドル。

### Return value

型: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

成功した場合は **S\_OK** を返します。そうでない場合はエラー コードを返します。エラー コードの一覧については、[エラー コード](https://docs.xbox.com/ja-jp/reference/errorcodes.md) を参照してください。指定されたタイトルの PLS が存在しないために関数が失敗した場合は、**FILE\_NOT\_FOUND** に設定されます。共有可能な永続ローカル ストレージを有効にしていないタイトルの PLS にアクセスしようとして関数が失敗した場合は、**ACCESS\_DENIED** になります。

## Remarks

> [!NOTE]
>
> この関数はタイム センシティブなスレッドで呼び出すのは安全ではありません。詳細については、[タイム センシティブなスレッド](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads) を参照してください。

タイトルが共有可能な PLS をサポートするには、MicrosoftGame.config でその旨を宣言する必要があります。共有可能な永続ローカル ストレージの詳細については、[ローカル ストレージ](https://docs.xbox.com/ja-jp/build/console-features/storage/local-storage.md) を参照してください。

> [!NOTE]
>
> タイトルが PLS を共有可能としてマークしている場合、ゲームを一時停止する前に PLS へのすべてのハンドルを閉じる必要があります。そうでない場合、ゲームの一時停止は失敗し、ゲームは終了します。

次のコード スニペットは、別のタイトルの共有可能な PLS にアクセスする例を示しています。

```cpp theme={null}

HRESULT MountPersistentLocalStorageForPackage(char* packageIdentifier) 
{      
    XPackageMountHandle* mountHandle; 
    HRESULT hr = XPersistentLocalStorageMountForPackage (packageIdentifier, &mountHandle); 

    if (FAILED(hr)) return hr; 
    size_t pathSize; 
    hr = XGetMountPathSize(mountHandle, &pathSize); 
    if (FAILED(hr)) 
    { 
        XPackageCloseMountHandle(mountHandle); 
        return hr; 
    } 
 
    char* path = new (std::nothrow) char[pathSize]; 
    if (path == nullptr) 
    { 
        XPackageCloseMountHandle (mountHandle); 
        return E_OUTOFMEMORY; 
    } 
 
    hr = XPackageGetMountPath (mountHandle, pathSize, path); 
    if (FAILED(hr)) 
    { 
        XPackageCloseMountHandle(mountHandle); 
        delete[] path; 
        return hr; 
    } 
 
    printf("PLS %s mounted at path %s\n", packageIdentifier, path); 
    delete[] path; 
 
    // Unmounts PLS path if this is the last handle 
    // to it. 
    XPackageCloseMountHandle(mountHandle); 
    return S_OK; 
} 

```

## Requirements

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

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

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

## Conceptual documentation

* [タイム センシティブなスレッド](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XPersistentLocalStorage](https://docs.xbox.com/ja-jp/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members.md)\
[新しい MicrosoftGame.config ファイルの使用方法](https://docs.xbox.com/ja-jp/build/core-features/common/game-config/MicrosoftGameConfig-toc.md)\
[ローカル ストレージ](https://docs.xbox.com/ja-jp/build/console-features/storage/local-storage.md)


## Related topics

- [XPersistentLocalStorage (API の内容)](https://docs.xbox.com/ja-jp/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members.md)
- [XPersistentLocalStorageSpaceInfo](https://docs.xbox.com/ja-jp/reference/system/xpersistentlocalstorage/structs/xpersistentlocalstoragespaceinfo.md)
- [XPersistentLocalStorageGetPath](https://docs.xbox.com/ja-jp/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpath.md)
- [XPersistentLocalStorageGetSpaceInfo](https://docs.xbox.com/ja-jp/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetspaceinfo.md)
- [XPersistentLocalStorageGetPathSize](https://docs.xbox.com/ja-jp/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpathsize.md)
