Update the features about Notification and Cert.

This commit is contained in:
Bruce
2025-11-12 14:59:34 +08:00
parent a5d8981528
commit ce5d3af63b
25 changed files with 866 additions and 86 deletions

View File

@@ -10,8 +10,13 @@ BOOL APIENTRY DllMain( HMODULE hModule,
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
CoInitializeEx (NULL, COINIT_MULTITHREADED | COINIT_APARTMENTTHREADED);
RoInitialize (RO_INIT_MULTITHREADED);
break;
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
CoUninitialize ();
RoUninitialize ();
break;
}
return TRUE;

View File

@@ -628,4 +628,30 @@ HRESULT FindAppxPackage (LPCWSTR lpPackageFullName, PKGMGR_FINDENUMCALLBACK pfCa
[STAThread]
LPCWSTR GetPackageManagerLastErrorCode () { return g_swExceptionCode.c_str (); }
[STAThread]
LPCWSTR GetPackageManagerLastErrorDetailMessage () { return g_swExceptionDetail.c_str (); }
LPCWSTR GetPackageManagerLastErrorDetailMessage () { return g_swExceptionDetail.c_str (); }
HRESULT ActivateAppxApplication (LPCWSTR lpAppUserId, PDWORD pdwProcessId)
{
if (!lpAppUserId) return E_INVALIDARG;
std::wstring strAppUserModelId (L"");
if (lpAppUserId) strAppUserModelId += lpAppUserId;
IApplicationActivationManager *spAppActivationManager = nullptr;
destruct relaamgr ([&] () {
if (spAppActivationManager) spAppActivationManager->Release ();
spAppActivationManager = nullptr;
});
HRESULT hResult = E_INVALIDARG;
if (!strAppUserModelId.empty ())
{
// Instantiate IApplicationActivationManager
hResult = CoCreateInstance (CLSID_ApplicationActivationManager, NULL, CLSCTX_LOCAL_SERVER, IID_IApplicationActivationManager, (LPVOID *)&spAppActivationManager);
if (SUCCEEDED (hResult))
{
// This call ensures that the app is launched as the foreground window
hResult = CoAllowSetForegroundWindow (spAppActivationManager, NULL);
// Launch the app
if (SUCCEEDED (hResult)) hResult = spAppActivationManager->ActivateApplication (strAppUserModelId.c_str (), NULL, AO_NONE, pdwProcessId);
}
}
return hResult;
}

View File

@@ -181,6 +181,8 @@ extern "C"
PKGMGR_API LPCWSTR GetPackageManagerLastErrorCode ();
// 获取错误详细信息。这个是常用的
PKGMGR_API LPCWSTR GetPackageManagerLastErrorDetailMessage ();
// 启动 Metro UI 应用
PKGMGR_API HRESULT ActivateAppxApplication (LPCWSTR lpAppUserId, PDWORD pdwProcessId);
#ifdef _DEFAULT_INIT_VALUE_
#undef _DEFAULT_INIT_VALUE_
#endif

View File

@@ -82,6 +82,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="pkgmgr.cpp" />
<ClCompile Include="stdafx.cpp" />
</ItemGroup>

View File

@@ -21,6 +21,9 @@
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pkgmgr.h">

View File

@@ -27,4 +27,7 @@ using namespace Windows::Management::Deployment;
#include <algorithm>
#include <collection.h>
#include <string>
#include <sddl.h>
#include <sddl.h>
#include <shlobj.h>
#include <stdio.h>
#include <shobjidl.h>