Update manager and add features for App Installer.

This commit is contained in:
Bruce
2026-01-31 22:03:03 +08:00
parent 0c87a2cdcd
commit d91948eaff
37 changed files with 3645 additions and 923 deletions

View File

@@ -1003,3 +1003,33 @@ HRESULT WRTAppDataClearAll (HWRTAPPDATA hAppData, LPWSTR *pErrorCode, LPWSTR *pD
}
return E_FAIL;
}
[STAThread]
HRESULT ActivateAppxApplicationWithArgs (LPCWSTR lpAppUserId, LPCWSTR lpArguments, PDWORD pdwProcessId)
{
HRESULT hr = CoInitializeEx (nullptr, COINIT_APARTMENTTHREADED);
if (FAILED (hr) && hr != RPC_E_CHANGED_MODE) return hr;
if (!lpAppUserId) return E_INVALIDARG;
std::wstring appUserModelId (lpAppUserId);
IApplicationActivationManager *pAam = nullptr;
destruct autoRelease ([&] {
if (pAam) pAam->Release ();
});
hr = CoCreateInstance (
CLSID_ApplicationActivationManager,
nullptr,
CLSCTX_LOCAL_SERVER,
IID_IApplicationActivationManager,
(void **)&pAam
);
if (FAILED (hr)) return hr;
CoAllowSetForegroundWindow (pAam, nullptr);
DWORD pid = 0;
hr = pAam->ActivateApplication (
appUserModelId.c_str (),
lpArguments && *lpArguments ? lpArguments : nullptr, // 允许空
AO_NONE,
&pid
);
if (SUCCEEDED (hr) && pdwProcessId) *pdwProcessId = pid;
return hr;
}

View File

@@ -203,6 +203,8 @@ extern "C"
PKGMGR_API HRESULT CreateAppDataManager (LPCWSTR lpFamilyName, HWRTAPPDATA *ppApplicationData, LPWSTR *pErrorCode, LPWSTR *pDetailMsg);
// 从本地、漫游和临时应用数据存储中删除所有应用程序数据。
PKGMGR_API HRESULT WRTAppDataClearAll (HWRTAPPDATA hAppData, LPWSTR *pErrorCode, LPWSTR *pDetailMsg);
PKGMGR_API HRESULT ActivateAppxApplicationWithArgs (LPCWSTR lpAppUserId, LPCWSTR lpArguments, PDWORD pdwProcessId);
#ifdef _DEFAULT_INIT_VALUE_
#undef _DEFAULT_INIT_VALUE_
#endif