LibreOffice Module setup_native (master) 1
shlxtmsi.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_SETUP_NATIVE_SOURCE_WIN32_CUSTOMACTIONS_SHELLEXTENSIONS_SHLXTMSI_HXX
21#define INCLUDED_SETUP_NATIVE_SOURCE_WIN32_CUSTOMACTIONS_SHELLEXTENSIONS_SHLXTMSI_HXX
22
23#define WIN32_LEAN_AND_MEAN
24#include <windows.h>
25#include <msiquery.h>
26
27#include <string>
28
29static inline std::wstring GetMsiPropertyW( MSIHANDLE handle, const std::wstring& sProperty )
30{
31 std::wstring result;
32 WCHAR szDummy[1] = L"";
33 DWORD nChars = 0;
34
35 if ( MsiGetPropertyW( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
36 {
37 DWORD nBytes = ++nChars * sizeof(WCHAR);
38 PWSTR buffer = static_cast<PWSTR>(_alloca(nBytes));
39 ZeroMemory( buffer, nBytes );
40 MsiGetPropertyW( handle, sProperty.c_str(), buffer, &nChars );
41 result = buffer;
42 }
43
44 return result;
45}
46
47static inline void SetMsiPropertyW( MSIHANDLE handle, const std::wstring& sProperty, const std::wstring& sValue )
48{
49 MsiSetPropertyW( handle, sProperty.c_str(), sValue.c_str() );
50}
51
52static inline void UnsetMsiPropertyW( MSIHANDLE handle, const std::wstring& sProperty )
53{
54 MsiSetPropertyW( handle, sProperty.c_str(), nullptr );
55}
56
57#endif // INCLUDED_SETUP_NATIVE_SOURCE_WIN32_CUSTOMACTIONS_SHELLEXTENSIONS_SHLXTMSI_HXX
58
59/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::wstring GetMsiPropertyW(MSIHANDLE handle, const std::wstring &sProperty)
Definition: shlxtmsi.hxx:29
static void SetMsiPropertyW(MSIHANDLE handle, const std::wstring &sProperty, const std::wstring &sValue)
Definition: shlxtmsi.hxx:47
static void UnsetMsiPropertyW(MSIHANDLE handle, const std::wstring &sProperty)
Definition: shlxtmsi.hxx:52
Any result