tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / setup_native / source / win32 / customactions / shellextensions / shlxtmsi.hxx
blob3a08060bee60196549504c58bc40f50c1d974cd9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SETUP_NATIVE_SOURCE_WIN32_CUSTOMACTIONS_SHELLEXTENSIONS_SHLXTMSI_HXX
21 #define INCLUDED_SETUP_NATIVE_SOURCE_WIN32_CUSTOMACTIONS_SHELLEXTENSIONS_SHLXTMSI_HXX
23 #define WIN32_LEAN_AND_MEAN
24 #include <windows.h>
25 #include <msiquery.h>
27 #include <string>
29 static inline std::wstring GetMsiPropertyW( MSIHANDLE handle, const std::wstring& sProperty )
31 std::wstring result;
32 WCHAR szDummy[1] = L"";
33 DWORD nChars = 0;
35 if ( MsiGetPropertyW( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
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;
44 return result;
47 static inline void SetMsiPropertyW( MSIHANDLE handle, const std::wstring& sProperty, const std::wstring& sValue )
49 MsiSetPropertyW( handle, sProperty.c_str(), sValue.c_str() );
52 static inline void UnsetMsiPropertyW( MSIHANDLE handle, const std::wstring& sProperty )
54 MsiSetPropertyW( handle, sProperty.c_str(), nullptr );
57 #endif // INCLUDED_SETUP_NATIVE_SOURCE_WIN32_CUSTOMACTIONS_SHELLEXTENSIONS_SHLXTMSI_HXX
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */