Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / systools / win32 / odbccp32.hxx
blobbbfaf9eecbd9774f2e38b99c5858d09be8b80634
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
8 */
10 #pragma once
12 #include <sal/config.h>
14 #include <prewin.h>
15 #include <postwin.h>
17 namespace sal::systools
19 // Linking to odbccp32 requires also legacy_stdio_definitions; and that breaks
20 // in some configurations, with make error 139. Load it dynamically instead.
21 class odbccp32
23 public:
24 odbccp32()
25 : m_hDLL(LoadLibraryW(L"odbccp32.dll"))
28 ~odbccp32() { FreeLibrary(m_hDLL); }
30 bool SQLGetInstalledDrivers(LPWSTR sBuf, WORD nBufSize) const
32 using proc_t = BOOL __stdcall(LPWSTR, WORD, WORD*);
33 return Invoke<proc_t>("SQLGetInstalledDriversW", sBuf, nBufSize, nullptr);
36 bool SQLManageDataSources(HWND hwndParent)
38 using proc_t = BOOL __stdcall(HWND);
39 return Invoke<proc_t>("SQLManageDataSources", hwndParent);
42 private:
43 template <typename proc_t, typename... Args> bool Invoke(const char* func, Args... args) const
45 if (auto pFunc = reinterpret_cast<proc_t*>(GetProcAddress(m_hDLL, func)))
46 return pFunc(args...);
47 return false;
50 HMODULE m_hDLL;
52 } // sal::systools
54 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */