Share via


LauncherOptions.PreferredApplicationDisplayName 속성

정의

파일 형식 또는 URI를 처리하기 위해 앱이 없는 경우 사용자가 설치해야 하는 저장소에 있는 앱의 표시 이름을 나타내는 값을 가져오거나 설정합니다.

public:
 property Platform::String ^ PreferredApplicationDisplayName { Platform::String ^ get(); void set(Platform::String ^ value); };
winrt::hstring PreferredApplicationDisplayName();

void PreferredApplicationDisplayName(winrt::hstring value);
public string PreferredApplicationDisplayName { get; set; }
var string = launcherOptions.preferredApplicationDisplayName;
launcherOptions.preferredApplicationDisplayName = string;
Public Property PreferredApplicationDisplayName As String

속성 값

String

Platform::String

winrt::hstring

앱의 표시 이름

예제

preferredApplicationDisplayName이 Windows 스토어에서 앱의 표시 이름으로 설정되고 preferredApplicationPackageFamilyName이 Windows 스토어에서 앱의 패키지 패밀리 이름으로 설정된 Launcher.LaunchFileAsync(IStorageFile, LauncherOptions) | launchFileAsync(IStorageFile, LauncherOptions) 메서드를 호출합니다.

async void DefaultLaunch()
{
   // Path to the file in the app package to launch
   string imageFile = @"images\test.png";

   // Get the image file from the package's image directory
   var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

   if (file != null)
   {
      // Set the recommended app
      var options = new Windows.System.LauncherOptions();
      options.PreferredApplicationPackageFamilyName = "Contoso.FileApp_8wknc82po1e";
      options.PreferredApplicationDisplayName = "Contoso File App";


      // Launch the retrieved file pass in the recommended app 
      // in case the user has no apps installed to handle the file
      bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
      if (success)
      {
         // File launched
      }
      else
      {
         // File launch failed
      }
   }
   else
   {
      // Could not find file
   }
}
Windows::Foundation::IAsyncAction MainPage::DefaultLaunch()
{
    // Get the app's installation folder.
    Windows::Storage::StorageFolder installFolder{ Windows::ApplicationModel::Package::Current().InstalledLocation() };

    Windows::Storage::StorageFile file{ co_await installFolder.GetFileAsync(L"Assets\\LockScreenLogo.scale-200.png") };

    if (file)
    {
        // Set the recommended app.
        Windows::System::LauncherOptions launcherOptions;
        launcherOptions.PreferredApplicationPackageFamilyName(L"Contoso.FileApp_8wknc82po1e");
        launcherOptions.PreferredApplicationDisplayName(L"Contoso File App");

        // Launch the retrieved file.
        bool success{ co_await Windows::System::Launcher::LaunchFileAsync(file, launcherOptions) };
        if (success)
        {
            // File launched.
        }
        else
        {
            // File launch failed.
        }
    }
    else
    {
        // Couldn't find file.
    }
}
void MainPage::DefaultLaunch()
{
   auto installFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;

   concurrency::task<Windows::Storage::StorageFile^> getFileOperation(installFolder->GetFileAsync("images\\test.png"));
   getFileOperation.then([](Windows::Storage::StorageFile^ file)
   {
      if (file != nullptr)
      {
         // Set the recommended app
         auto launchOptions = ref new Windows::System::LauncherOptions();
         launchOptions->PreferredApplicationPackageFamilyName = "Contoso.FileApp_8wknc82po1e";
         launchOptions->PreferredApplicationDisplayName = "Contoso File App";

         // Launch the retrieved file pass in the recommended app 
         // in case the user has no apps installed to handle the file
         concurrency::task<bool> launchFileOperation(Windows::System::Launcher::LaunchFileAsync(file, launchOptions));
         launchFileOperation.then([](bool success)
         {
            if (success)
            {
               // File launched
            }
            else
            {
               // File launch failed
            }
         });
      }
      else
      {
         // Could not find file
      }
   });
}
async Sub DefaultLaunch()

   ' Path to the file in the app package to launch
   Dim imageFile = "images\test.png"

   ' Get the image file from the package's image directory
   Dim file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile)

   If file IsNot Nothing Then
      ' Set the recommended app
      Dim options = Windows.System.LauncherOptions()
      options.PreferredApplicationPackageFamilyName = "Contoso.FileApp_8wknc82po1e";
      options.PreferredApplicationDisplayName = "Contoso File App";

      ' Launch the retrieved file pass in the recommended app 
      ' in case the user has no apps installed to handle the file
      Dim success = await Windows.System.Launcher.LaunchFileAsync(file)

      If success Then
         ' File launched
      Else
         ' File launch failed
      End If
   Else
      ' Could not find file
   End If
End Sub

설명

경우에 따라 사용자는 시작할 파일을 처리하는 앱을 설치하지 않으려 할 수 있습니다. 기본적으로 Windows는 이러한 경우 사용자에게 스토어에서 적절한 앱을 검색할 수 있는 링크를 제공합니다. LauncherOptions.PreferredApplicationDisplayNameLauncherOptions.preferredApplicationPackageFamilyName과 함께 사용하여 사용자에게 Windows 스토어에서 파일을 처리하기 위해 획득할 수 있는 앱을 제공합니다. 사용하는 표시 이름은 Windows 스토어에 있는 앱의 표시 이름과 일치해야 합니다.

앱을 추천하려면 이러한 기본 설정 애플리케이션 속성을 모두 설정해야 합니다. 하나만 설정하면 오류가 발생합니다.

참고

하나의 대체만 사용할 수 있으므로 기본 설정 애플리케이션 속성과 대체 URI를 동시에 설정할 수 없습니다. 두 대체 항목이 모두 설정되면 Launcher API가 실패합니다.

중요

이 속성은 데스크톱 디바이스에서만 구현됩니다.

적용 대상

추가 정보