mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-04-20 10:44:37 +10:00
Add GetPackageFullName helper
This commit is contained in:
@@ -301,14 +301,7 @@ bool CanUninstallMetroApp( const wchar_t *appid )
|
|||||||
// Uninstalls the app with the given id
|
// Uninstalls the app with the given id
|
||||||
void UninstallMetroApp( const wchar_t *appid )
|
void UninstallMetroApp( const wchar_t *appid )
|
||||||
{
|
{
|
||||||
CComPtr<IShellItem> pAppItem;
|
auto packageName = GetPackageFullName(appid);
|
||||||
if (SUCCEEDED(SHCreateItemInKnownFolder(FOLDERID_AppsFolder2,0,appid,IID_IShellItem,(void**)&pAppItem)))
|
|
||||||
{
|
|
||||||
CComPtr<IPropertyStore> pStore;
|
|
||||||
pAppItem->BindToHandler(NULL,BHID_PropertyStore,IID_IPropertyStore,(void**)&pStore);
|
|
||||||
if (pStore)
|
|
||||||
{
|
|
||||||
CString packageName=GetPropertyStoreString(pStore,PKEY_MetroPackageName);
|
|
||||||
if (!packageName.IsEmpty())
|
if (!packageName.IsEmpty())
|
||||||
{
|
{
|
||||||
wchar_t command[1024];
|
wchar_t command[1024];
|
||||||
@@ -316,8 +309,6 @@ void UninstallMetroApp( const wchar_t *appid )
|
|||||||
ShellExecute(NULL, L"open", L"powershell.exe", command, NULL, SW_HIDE);
|
ShellExecute(NULL, L"open", L"powershell.exe", command, NULL, SW_HIDE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Asks for confirmation to uninstall the specified app
|
// Asks for confirmation to uninstall the specified app
|
||||||
void UninstallMetroApp( HWND parent, const wchar_t *name, const wchar_t *appid )
|
void UninstallMetroApp( HWND parent, const wchar_t *name, const wchar_t *appid )
|
||||||
@@ -381,3 +372,16 @@ bool IsEdgeDefaultBrowser( void )
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CString GetPackageFullName(const wchar_t* appId)
|
||||||
|
{
|
||||||
|
CComPtr<IShellItem> item;
|
||||||
|
if (SUCCEEDED(SHCreateItemInKnownFolder(FOLDERID_AppsFolder, 0, appId, IID_PPV_ARGS(&item))))
|
||||||
|
{
|
||||||
|
CComPtr<IPropertyStore> store;
|
||||||
|
if (SUCCEEDED(item->BindToHandler(nullptr, BHID_PropertyStore, IID_PPV_ARGS(&store))))
|
||||||
|
return GetPropertyStoreString(store, PKEY_MetroPackageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,3 +53,6 @@ CComPtr<IContextMenu> GetMetroPinMenu( const wchar_t *appid );
|
|||||||
|
|
||||||
// Determines if Edge is the default browser
|
// Determines if Edge is the default browser
|
||||||
bool IsEdgeDefaultBrowser( void );
|
bool IsEdgeDefaultBrowser( void );
|
||||||
|
|
||||||
|
// Returns full package name for given App ID
|
||||||
|
CString GetPackageFullName(const wchar_t* appId);
|
||||||
|
|||||||
Reference in New Issue
Block a user