28 std::wstring progpath;
30 PWSTR dummy =
const_cast<PWSTR
>(L
"");
32 if (MsiGetPropertyW(handle, L
"INSTALLLOCATION", dummy, &sz) == ERROR_MORE_DATA)
35 DWORD nbytes = sz *
sizeof(WCHAR);
36 PWSTR buff =
static_cast<PWSTR
>(_alloca(nbytes));
37 ZeroMemory(buff, nbytes);
38 MsiGetPropertyW(handle, L
"INSTALLLOCATION", buff, &sz);
46 std::wstring productname;
48 PWSTR dummy =
const_cast<PWSTR
>(L
"");
50 if (MsiGetPropertyW(handle, L
"ProductName", dummy, &sz) == ERROR_MORE_DATA)
53 DWORD nbytes = sz *
sizeof(WCHAR);
54 PWSTR buff =
static_cast<PWSTR
>(_alloca(nbytes));
55 ZeroMemory(buff, nbytes);
56 MsiGetPropertyW(handle, L
"ProductName", buff, &sz);
64 std::wstring quickstarterlinkname;
66 PWSTR dummy =
const_cast<PWSTR
>(L
"");
68 if (MsiGetPropertyW(handle, L
"Quickstarterlinkname", dummy, &sz) == ERROR_MORE_DATA)
71 DWORD nbytes = sz *
sizeof(WCHAR);
72 PWSTR buff =
static_cast<PWSTR
>(_alloca(nbytes));
73 ZeroMemory(buff, nbytes);
74 MsiGetPropertyW(handle, L
"Quickstarterlinkname", buff, &sz);
75 quickstarterlinkname = buff;
77 else if (MsiGetPropertyW(handle, L
"ProductName", dummy, &sz) == ERROR_MORE_DATA)
80 DWORD nbytes = sz *
sizeof(WCHAR);
81 PWSTR buff =
static_cast<PWSTR
>(_alloca(nbytes));
82 ZeroMemory(buff, nbytes);
83 MsiGetPropertyW(handle, L
"ProductName", buff, &sz);
84 quickstarterlinkname = buff;
86 return quickstarterlinkname;
91 return nullptr != handle && INVALID_HANDLE_VALUE != handle;
96 static auto lpProc = []() {
97 HMODULE hLibrary = LoadLibraryW(L
"PSAPI.DLL");
98 decltype(GetModuleFileNameExW)* pRet =
nullptr;
100 pRet =
reinterpret_cast<decltype(GetModuleFileNameExW)*
>(
101 GetProcAddress(hLibrary,
"GetModuleFileNameExW"));
106 return lpProc( hProcess, hModule, lpFileName, nSize );
114 std::wstring sImagePath;
116 HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE, dwProcessId );
122 if (
GetModuleFileNameExW_( hProcess,
nullptr, szPathBuffer,
sizeof(szPathBuffer)/
sizeof(szPathBuffer[0]) ) )
123 sImagePath = szPathBuffer;
125 CloseHandle( hProcess );
std::wstring GetOfficeProductNameW(MSIHANDLE handle)
static DWORD WINAPI GetModuleFileNameExW_(HANDLE hProcess, HMODULE hModule, PWSTR lpFileName, DWORD nSize)
static bool IsValidHandle(HANDLE handle)
std::wstring GetProcessImagePathW(DWORD dwProcessId)
std::wstring GetOfficeInstallationPathW(MSIHANDLE handle)
std::wstring GetQuickstarterLinkNameW(MSIHANDLE handle)