File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Microsoft.Management.Deployment Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -497,4 +497,16 @@ namespace AppInstaller::Filesystem
497497
498498 return result;
499499 }
500+
501+ std::filesystem::path GetExecutablePathForProcess (HANDLE process)
502+ {
503+ wil::unique_cotaskmem_string imageName = nullptr ;
504+ if (SUCCEEDED (wil::QueryFullProcessImageNameW (process, 0 , imageName)) &&
505+ (imageName.get () != nullptr ))
506+ {
507+ return imageName.get ();
508+ }
509+
510+ return {};
511+ }
500512}
Original file line number Diff line number Diff line change @@ -119,4 +119,7 @@ namespace AppInstaller::Filesystem
119119 // Gets the PathDetails used for the given path.
120120 // This is exposed primarily to allow for testing, GetPathTo should be preferred.
121121 PathDetails GetPathDetailsFor (PathName path, bool forDisplay = false );
122+
123+ // Gets the path to the executable for the given process id.
124+ std::filesystem::path GetExecutablePathForProcess (HANDLE process);
122125}
Original file line number Diff line number Diff line change 66#include < winrt/Windows.Security.Authorization.AppCapabilityAccess.h>
77#include < appmodel.h>
88#include < Helpers.h>
9+ #include < winget/Filesystem.h>
910#include < winget/Security.h>
1011#include < AppInstallerRuntime.h>
1112
@@ -144,11 +145,10 @@ namespace winrt::Microsoft::Management::Deployment::implementation
144145 }
145146
146147 // if the caller doesn't have an AppUserModelID then fall back to the executable name
147- wil::unique_cotaskmem_string imageName = nullptr ;
148- if (SUCCEEDED (wil::QueryFullProcessImageNameW (processHandle.get (), 0 , imageName)) &&
149- (imageName.get () != nullptr ))
148+ std::filesystem::path executablePath = AppInstaller::Filesystem::GetExecutablePathForProcess (processHandle.get ());
149+ if (executablePath.has_filename ())
150150 {
151- return imageName. get ();
151+ return executablePath. filename ();
152152 }
153153 }
154154
You can’t perform that action at this time.
0 commit comments