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

# XPersistentLocalStorageMountForPackage

> XPersistentLocalStorageMountForPackage

# XPersistentLocalStorageMountForPackage

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

## Syntax

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

### Parameters

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

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

*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** を返します。そうでない場合はエラー コードを返します。エラー コードの一覧については、[エラー コード](/reference/errorcodes) を参照してください。指定されたタイトルの 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) を参照してください。</Note>

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

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

次のコード スニペットは、別のタイトルの共有可能な 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](/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members)\
[新しい MicrosoftGame.config ファイルの使用方法](/build/core-features/common/game-config/MicrosoftGameConfig-toc)\
[ローカル ストレージ](/build/console-features/storage/local-storage)


## Related topics

- [XPersistentLocalStorage](/ja-jp/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members.md)
- [XPersistentLocalStorageSpaceInfo](/ja-jp/reference/system/xpersistentlocalstorage/structs/xpersistentlocalstoragespaceinfo.md)
- [XPersistentLocalStorageGetPath](/ja-jp/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpath.md)
- [XPersistentLocalStorageGetSpaceInfo](/ja-jp/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetspaceinfo.md)
- [XPersistentLocalStorageGetPathSize](/ja-jp/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpathsize.md)
