зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1709969 Part 1 - Add a utility function to retrieve the current package's family name. r=agashlin
Differential Revision: https://phabricator.services.mozilla.com/D120529
This commit is contained in:
Родитель
a0581e6247
Коммит
2ba1af0e89
|
@ -2294,5 +2294,41 @@ bool WinUtils::PreparePathForTelemetry(nsAString& aPath,
|
|||
return true;
|
||||
}
|
||||
|
||||
nsString WinUtils::GetPackageFamilyName() {
|
||||
nsString rv;
|
||||
|
||||
if (!HasPackageIdentity()) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
HMODULE kernel32Dll = ::GetModuleHandleW(L"kernel32");
|
||||
if (!kernel32Dll) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
typedef LONG(WINAPI * GetCurrentPackageFamilyNameProc)(UINT32*, PWSTR);
|
||||
GetCurrentPackageFamilyNameProc pGetCurrentPackageFamilyName =
|
||||
(GetCurrentPackageFamilyNameProc)::GetProcAddress(
|
||||
kernel32Dll, "GetCurrentPackageFamilyName");
|
||||
if (!pGetCurrentPackageFamilyName) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
UINT32 packageNameSize = 0;
|
||||
if (pGetCurrentPackageFamilyName(&packageNameSize, nullptr) !=
|
||||
ERROR_INSUFFICIENT_BUFFER) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
UniquePtr<wchar_t[]> packageIdentity = MakeUnique<wchar_t[]>(packageNameSize);
|
||||
if (pGetCurrentPackageFamilyName(&packageNameSize, packageIdentity.get()) !=
|
||||
ERROR_SUCCESS) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = packageIdentity.get();
|
||||
return rv;
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -223,6 +223,18 @@ class WinUtils {
|
|||
|
||||
static bool HasPackageIdentity() { return sHasPackageIdentity; }
|
||||
|
||||
/*
|
||||
* The "family name" of a Windows app package is the full name without any of
|
||||
* the components that might change during the life cycle of the app (such as
|
||||
* the version number, or the architecture). This leaves only those properties
|
||||
* which together serve to uniquely identify the app within one Windows
|
||||
* installation, namely the base name and the publisher name. Meaning, this
|
||||
* string is safe to use anywhere that a string uniquely identifying an app
|
||||
* installation is called for (because multiple copies of the same app on the
|
||||
* same system is not a supported feature in the app framework).
|
||||
*/
|
||||
static nsString GetPackageFamilyName();
|
||||
|
||||
/**
|
||||
* Logging helpers that dump output to prlog module 'Widget', console, and
|
||||
* OutputDebugString. Note these output in both debug and release builds.
|
||||
|
|
Загрузка…
Ссылка в новой задаче