[Libreoffice-commits] core.git: avmedia/source basic/source bean/native canvas/source desktop/source dtrans/source embedserv/source extensions/source fpicker/source hwpfilter/source idlc/source include/comphelper jvmfwk/plugins jvmfwk/source opencl/source sal/osl sfx2/source svl/source tools/source vcl/inc vcl/opengl vcl/source vcl/win xmlhelp/source xmlsecurity/source

Mike Kaganski mike.kaganski at collabora.com
Sat Sep 30 09:24:09 UTC 2017


 avmedia/source/win/player.cxx                                         |   24 -
 avmedia/source/win/window.cxx                                         |   42 +--
 basic/source/runtime/methods.cxx                                      |    3 
 bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c         |   10 
 canvas/source/directx/dx_9rm.cxx                                      |    2 
 desktop/source/app/app.cxx                                            |    6 
 desktop/source/app/cmdlinehelp.cxx                                    |   10 
 desktop/source/deployment/misc/lockfile.cxx                           |    2 
 dtrans/source/win32/dnd/source.cxx                                    |    2 
 dtrans/source/win32/dnd/target.cxx                                    |   12 
 dtrans/source/win32/dtobj/DTransHelper.cxx                            |    2 
 dtrans/source/win32/dtobj/DataFmtTransl.cxx                           |    8 
 dtrans/source/win32/misc/ImplHelper.cxx                               |   22 -
 embedserv/source/embed/docholder.cxx                                  |    8 
 embedserv/source/embed/ed_idataobj.cxx                                |   16 -
 embedserv/source/embed/ed_ipersiststr.cxx                             |    6 
 embedserv/source/embed/syswinwrapper.cxx                              |   20 -
 embedserv/source/embed/tracker.cxx                                    |   11 
 embedserv/source/inprocserv/dllentry.cxx                              |   40 +--
 extensions/source/activex/SOActiveX.cxx                               |   20 -
 extensions/source/activex/SOActiveX.h                                 |    2 
 extensions/source/scanner/scanwin.cxx                                 |   10 
 fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx               |    4 
 fpicker/source/win32/folderpicker/MtaFop.cxx                          |   59 ++--
 hwpfilter/source/hwpreader.cxx                                        |    4 
 hwpfilter/source/mzstring.cxx                                         |    6 
 idlc/source/options.cxx                                               |    2 
 include/comphelper/windowserrorstring.hxx                             |    2 
 jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx                   |    6 
 jvmfwk/plugins/sunmajor/pluginlib/util.cxx                            |    6 
 jvmfwk/source/fwkutil.cxx                                             |   14 -
 opencl/source/openclwrapper.cxx                                       |    4 
 sal/osl/w32/security.cxx                                              |   14 -
 sfx2/source/appl/shutdowniconw32.cxx                                  |   22 -
 sfx2/source/doc/graphhelp.cxx                                         |    3 
 sfx2/source/doc/guisaveas.cxx                                         |    2 
 sfx2/source/doc/syspathw32.cxx                                        |    2 
 svl/source/crypto/cryptosign.cxx                                      |   11 
 tools/source/stream/strmwnt.cxx                                       |    9 
 vcl/inc/win/saldata.hxx                                               |   10 
 vcl/inc/win/wincomp.hxx                                               |   20 -
 vcl/opengl/win/gdiimpl.cxx                                            |   10 
 vcl/source/app/settings.cxx                                           |   32 +-
 vcl/source/window/toolbox.cxx                                         |   10 
 vcl/win/app/salinfo.cxx                                               |   10 
 vcl/win/app/salinst.cxx                                               |   42 +--
 vcl/win/app/salshl.cxx                                                |   12 
 vcl/win/gdi/DWriteTextRenderer.cxx                                    |    8 
 vcl/win/gdi/salbmp.cxx                                                |    6 
 vcl/win/gdi/salfont.cxx                                               |   76 ++----
 vcl/win/gdi/salnativewidgets-luna.cxx                                 |    2 
 vcl/win/gdi/salprn.cxx                                                |   45 +--
 vcl/win/gdi/winlayout.cxx                                             |    2 
 vcl/win/window/salframe.cxx                                           |  122 +++++-----
 vcl/win/window/salobj.cxx                                             |   39 +--
 xmlhelp/source/cxxhelp/provider/databases.cxx                         |   12 
 xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx |   26 --
 xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx       |    5 
 xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx     |   41 +--
 59 files changed, 479 insertions(+), 499 deletions(-)

New commits:
commit 362a21d3a129b90149f6ef645c127f5e86e0ba61
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Tue Sep 26 11:28:57 2017 +0300

    Use explicit function names for fooA/fooW WinAPI; prefer fooW
    
    We should only use generic foo function name when it takes params
    that are also dependent on UNICODE define, like
    LoadCursor( nullptr, IDC_ARROW )
    where IDC_ARROW is defined in MSVC headers synchronised with
    LoadCursor definition.
    
    We should always use Unicode API for any file paths operations,
    because otherwise we will get "?" for any character in path that
    is not in current non-unicode codepage, which will result in failed
    file operations.
    
    Change-Id: I3a7f453ca0f893002d8a9764318919709fd8b633
    Reviewed-on: https://gerrit.libreoffice.org/42935
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx
index 4ba72ca9a368..268babd1b17c 100644
--- a/avmedia/source/win/player.cxx
+++ b/avmedia/source/win/player.cxx
@@ -44,7 +44,7 @@ namespace avmedia { namespace win {
 
 LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
 {
-    Player* pPlayer = reinterpret_cast<Player*>(::GetWindowLongPtr( hWnd, 0 ));
+    Player* pPlayer = reinterpret_cast<Player*>(::GetWindowLongPtrW( hWnd, 0 ));
     bool    bProcessed = true;
 
     if( pPlayer )
@@ -62,7 +62,7 @@ LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM
     else
         bProcessed = false;
 
-    return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) );
+    return( bProcessed ? 0 : DefWindowProcW( hWnd, nMsg, nPar1, nPar2 ) );
 }
 
 
@@ -226,31 +226,31 @@ void SAL_CALL Player::start(  )
     {
         if ( mbAddWindow )
         {
-            static WNDCLASS* mpWndClass = nullptr;
+            static WNDCLASSW* mpWndClass = nullptr;
             if ( !mpWndClass )
             {
-                mpWndClass = new WNDCLASS;
+                mpWndClass = new WNDCLASSW;
 
                 memset( mpWndClass, 0, sizeof( *mpWndClass ) );
-                mpWndClass->hInstance = GetModuleHandle( nullptr );
+                mpWndClass->hInstance = GetModuleHandleW( nullptr );
                 mpWndClass->cbWndExtra = sizeof( DWORD );
                 mpWndClass->lpfnWndProc = MediaPlayerWndProc_2;
-                mpWndClass->lpszClassName = "com_sun_star_media_Sound_Player";
+                mpWndClass->lpszClassName = L"com_sun_star_media_Sound_Player";
                 mpWndClass->hbrBackground = static_cast<HBRUSH>(::GetStockObject( BLACK_BRUSH ));
                 mpWndClass->hCursor = ::LoadCursor( nullptr, IDC_ARROW );
 
-                ::RegisterClass( mpWndClass );
+                RegisterClassW( mpWndClass );
             }
             if ( !mnFrameWnd )
             {
-                mnFrameWnd = ::CreateWindow( mpWndClass->lpszClassName, nullptr,
-                                           0,
-                                           0, 0, 0, 0,
-                                           nullptr, nullptr, mpWndClass->hInstance, nullptr );
+                mnFrameWnd = CreateWindowW( mpWndClass->lpszClassName, nullptr,
+                                            0,
+                                            0, 0, 0, 0,
+                                            nullptr, nullptr, mpWndClass->hInstance, nullptr );
                 if ( mnFrameWnd )
                 {
                     ::ShowWindow(mnFrameWnd, SW_HIDE);
-                    ::SetWindowLongPtr( mnFrameWnd, 0, reinterpret_cast<LONG_PTR>(this) );
+                    SetWindowLongPtrW( mnFrameWnd, 0, reinterpret_cast<LONG_PTR>(this) );
                     // mpVW->put_Owner( (OAHWND) mnFrameWnd );
                     setNotifyWnd( mnFrameWnd );
                 }
diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx
index 8b31cbb2fa61..16deeee09a1e 100644
--- a/avmedia/source/win/window.cxx
+++ b/avmedia/source/win/window.cxx
@@ -43,7 +43,7 @@ namespace avmedia { namespace win {
 
 LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
 {
-    Window* pWindow = reinterpret_cast<Window*>(::GetWindowLongPtr( hWnd, 0 ));
+    Window* pWindow = reinterpret_cast<Window*>(GetWindowLongPtrW( hWnd, 0 ));
     bool    bProcessed = true;
 
     if( pWindow )
@@ -136,22 +136,22 @@ LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM n
     else
         bProcessed = false;
 
-    return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) );
+    return( bProcessed ? 0 : DefWindowProcW( hWnd, nMsg, nPar1, nPar2 ) );
 }
 
-WNDCLASS* lcl_getWndClass()
+WNDCLASSW* lcl_getWndClass()
 {
-    WNDCLASS* s_pWndClass = new WNDCLASS;
+    WNDCLASSW* s_pWndClass = new WNDCLASSW;
 
     memset( s_pWndClass, 0, sizeof( *s_pWndClass ) );
-    s_pWndClass->hInstance = GetModuleHandle( nullptr );
+    s_pWndClass->hInstance = GetModuleHandleW( nullptr );
     s_pWndClass->cbWndExtra = sizeof( DWORD );
     s_pWndClass->lpfnWndProc = MediaPlayerWndProc;
-    s_pWndClass->lpszClassName = "com_sun_star_media_PlayerWnd";
+    s_pWndClass->lpszClassName = L"com_sun_star_media_PlayerWnd";
     s_pWndClass->hbrBackground = static_cast<HBRUSH>(::GetStockObject( BLACK_BRUSH ));
     s_pWndClass->hCursor = ::LoadCursor( nullptr, IDC_ARROW );
 
-    ::RegisterClass( s_pWndClass );
+    RegisterClassW( s_pWndClass );
 
     return s_pWndClass;
 }
@@ -261,7 +261,7 @@ void Window::ImplLayoutVideoWindow()
 bool Window::create( const uno::Sequence< uno::Any >& rArguments )
 {
     IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
-    static WNDCLASS* mpWndClass = lcl_getWndClass();
+    static WNDCLASSW* mpWndClass = lcl_getWndClass();
 
     if( !mnFrameWnd && pVideoWindow && mpWndClass )
     {
@@ -273,23 +273,23 @@ bool Window::create( const uno::Sequence< uno::Any >& rArguments )
 
         mnParentWnd = reinterpret_cast<HWND>(nWnd);
 
-        mnFrameWnd = ::CreateWindow( mpWndClass->lpszClassName, nullptr,
-                                           WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
-                                           aRect.X, aRect.Y, aRect.Width, aRect.Height,
-                                           mnParentWnd, nullptr, mpWndClass->hInstance, nullptr );
+        mnFrameWnd = CreateWindowW( mpWndClass->lpszClassName, nullptr,
+                                    WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+                                    aRect.X, aRect.Y, aRect.Width, aRect.Height,
+                                    mnParentWnd, nullptr, mpWndClass->hInstance, nullptr );
 
         if( mnFrameWnd )
         {
-            ::SetWindowLongPtr( mnFrameWnd, 0, reinterpret_cast<LONG_PTR>(this) );
+            SetWindowLongPtrW( mnFrameWnd, 0, reinterpret_cast<LONG_PTR>(this) );
 
-                        pVideoWindow->put_Owner( reinterpret_cast<OAHWND>(mnFrameWnd) );
-                        pVideoWindow->put_MessageDrain( reinterpret_cast<OAHWND>(mnFrameWnd) );
-                        pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
+            pVideoWindow->put_Owner( reinterpret_cast<OAHWND>(mnFrameWnd) );
+            pVideoWindow->put_MessageDrain( reinterpret_cast<OAHWND>(mnFrameWnd) );
+            pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
 
-                        mrPlayer.setNotifyWnd( mnFrameWnd );
+            mrPlayer.setNotifyWnd( mnFrameWnd );
 
-                        meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
-                        ImplLayoutVideoWindow();
+            meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
+            ImplLayoutVideoWindow();
         }
     }
 
@@ -303,7 +303,7 @@ void Window::processGraphEvent()
 
 void Window::updatePointer()
 {
-    char* pCursorName;
+    LPCTSTR pCursorName;
 
     switch( mnPointerType )
     {
@@ -316,7 +316,7 @@ void Window::updatePointer()
         break;
     }
 
-    ::SetCursor( ::LoadCursor( nullptr, pCursorName ) );
+    SetCursor( LoadCursor( nullptr, pCursorName ) );
 }
 
 void SAL_CALL Window::update(  )
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 8a0ae5d2ff36..cef5dd269a3a 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -2958,8 +2958,7 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite)
             OUString aPathURL = getFullPath( rPar.Get(1)->GetOUString() );
             OUString aPath;
             FileBase::getSystemPathFromFileURL( aPathURL, aPath );
-            OString aSystemPath(OUStringToOString(aPath, osl_getThreadTextEncoding()));
-            DWORD nRealFlags = GetFileAttributes (aSystemPath.getStr());
+            DWORD nRealFlags = GetFileAttributesW (SAL_W(aPath.getStr()));
             if (nRealFlags != 0xffffffff)
             {
                 if (nRealFlags == FILE_ATTRIBUTE_NORMAL)
diff --git a/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c
index dc3ee5b4bb35..b1b476356fd5 100644
--- a/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c
+++ b/bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c
@@ -38,7 +38,7 @@
 
 #define SYSTEM_WIN32   1
 
-#define OLD_PROC_KEY "oldwindowproc"
+#define OLD_PROC_KEY L"oldwindowproc"
 
 static LRESULT APIENTRY OpenOfficeWndProc( HWND , UINT , WPARAM , LPARAM );
 
@@ -131,10 +131,10 @@ JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNative
        and calls on such construct produce
        a stack overflow.
      */
-    if (GetProp( hWnd, OLD_PROC_KEY )==NULL)
+    if (GetPropW( hWnd, OLD_PROC_KEY )==NULL)
     {
-        hFuncPtr = SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR)OpenOfficeWndProc );
-        SetProp( hWnd, OLD_PROC_KEY, (HANDLE)hFuncPtr );
+        hFuncPtr = SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (LONG_PTR)OpenOfficeWndProc );
+        SetPropW( hWnd, OLD_PROC_KEY, (HANDLE)hFuncPtr );
     }
 
     return (jlong)hWnd;
@@ -182,7 +182,7 @@ static LRESULT APIENTRY OpenOfficeWndProc(
 #pragma warning(push)
 #pragma warning(disable: 4152) /* function/data pointer conversion: */
 #endif
-    return CallWindowProc(GetProp(hWnd, OLD_PROC_KEY),
+    return CallWindowProcW(GetPropW(hWnd, OLD_PROC_KEY),
                           hWnd, uMsg, wParam, lParam);
 #if defined _MSC_VER
 #pragma warning(pop)
diff --git a/canvas/source/directx/dx_9rm.cxx b/canvas/source/directx/dx_9rm.cxx
index ce1d7d03b6d2..3cc7fd5437a3 100644
--- a/canvas/source/directx/dx_9rm.cxx
+++ b/canvas/source/directx/dx_9rm.cxx
@@ -73,7 +73,7 @@ namespace dxcanvas
         public:
 
             monitorSupport() :
-                mhLibrary(LoadLibrary("user32.dll")),
+                mhLibrary(LoadLibraryW(L"user32.dll")),
                 mpMonitorFromWindow(nullptr)
             {
                 if(mhLibrary)
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index b08e928dd32c..7c194f890db9 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2633,12 +2633,12 @@ void Desktop::CheckFirstRun( )
 
 #ifdef _WIN32
         // Check if Quickstarter should be started (on Windows only)
-        TCHAR szValue[8192];
+        WCHAR szValue[8192];
         DWORD nValueSize = sizeof(szValue);
         HKEY hKey;
-        if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE,  "Software\\LibreOffice", &hKey ) )
+        if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_LOCAL_MACHINE, L"Software\\LibreOffice", &hKey ) )
         {
-            if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("RunQuickstartAtFirstStart"), nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) )
+            if ( ERROR_SUCCESS == RegQueryValueExW( hKey, L"RunQuickstartAtFirstStart", nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) )
             {
                 css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
                 css::office::Quickstart::createAutoStart(xContext, true/*Quickstart*/, true/*bAutostart*/);
diff --git a/desktop/source/app/cmdlinehelp.cxx b/desktop/source/app/cmdlinehelp.cxx
index a4b3114cf3bb..43028a72fd10 100644
--- a/desktop/source/app/cmdlinehelp.cxx
+++ b/desktop/source/app/cmdlinehelp.cxx
@@ -187,9 +187,9 @@ namespace desktop
             {
                 if (GetStdHandle(STD_OUTPUT_HANDLE) == nullptr) // application does not have associated standard handles
                 {
-                    STARTUPINFOA aStartupInfo;
+                    STARTUPINFOW aStartupInfo;
                     aStartupInfo.cb = sizeof(aStartupInfo);
-                    GetStartupInfoA(&aStartupInfo);
+                    GetStartupInfoW(&aStartupInfo);
                     if ((aStartupInfo.dwFlags & STARTF_USESTDHANDLES) == STARTF_USESTDHANDLES)
                     {
                         // If standard handles had been passed to this process, use them
@@ -247,11 +247,11 @@ namespace desktop
                     ke.bKeyDown = TRUE;
                     ke.wRepeatCount = 1;
                     ke.wVirtualKeyCode = VK_RETURN;
-                    ke.wVirtualScanCode = MapVirtualKeyA(VK_RETURN, MAPVK_VK_TO_VSC);
-                    ke.uChar.AsciiChar = '\r';
+                    ke.wVirtualScanCode = MapVirtualKeyW(VK_RETURN, MAPVK_VK_TO_VSC);
+                    ke.uChar.UnicodeChar = L'\r';
                     ke.dwControlKeyState = 0;
                     DWORD nEvents;
-                    WriteConsoleInputA(GetStdHandle(STD_INPUT_HANDLE), &ir, 1, &nEvents);
+                    WriteConsoleInputW(GetStdHandle(STD_INPUT_HANDLE), &ir, 1, &nEvents);
                     break;
                 }
                 case allocated:
diff --git a/desktop/source/deployment/misc/lockfile.cxx b/desktop/source/deployment/misc/lockfile.cxx
index 11530d0be892..0544f434bd14 100644
--- a/desktop/source/deployment/misc/lockfile.cxx
+++ b/desktop/source/deployment/misc/lockfile.cxx
@@ -55,7 +55,7 @@ static OString impl_getHostname()
        */
     DWORD sz = MAX_COMPUTERNAME_LENGTH + 1;
     auto szHost = std::unique_ptr<char[]>(new char[sz]);
-    if (GetComputerName(szHost.get(), &sz))
+    if (GetComputerNameA(szHost.get(), &sz))
         aHost = OString(szHost.get());
     else
         aHost = OString("UNKNOWN");
diff --git a/dtrans/source/win32/dnd/source.cxx b/dtrans/source/win32/dnd/source.cxx
index b6d1d9a628bd..06c8e4977def 100644
--- a/dtrans/source/win32/dnd/source.cxx
+++ b/dtrans/source/win32/dnd/source.cxx
@@ -314,7 +314,7 @@ unsigned __stdcall DndOleSTAFunc(LPVOID pParams)
         // We force the creation of a thread message queue. This is necessary
         // for a later call to AttachThreadInput
         MSG msgtemp;
-        PeekMessage( &msgtemp, nullptr, WM_USER, WM_USER, PM_NOREMOVE);
+        PeekMessageW( &msgtemp, nullptr, WM_USER, WM_USER, PM_NOREMOVE);
 
         DWORD threadId= GetCurrentThreadId();
 
diff --git a/dtrans/source/win32/dnd/target.cxx b/dtrans/source/win32/dnd/target.cxx
index b797d4e769d8..ab3c554ea5bc 100644
--- a/dtrans/source/win32/dnd/target.cxx
+++ b/dtrans/source/win32/dnd/target.cxx
@@ -76,7 +76,7 @@ void SAL_CALL DropTarget::disposing()
     if( m_threadIdTarget)
     {
         // Call RevokeDragDrop and wait for the OLE thread to die;
-        PostThreadMessage( m_threadIdTarget, WM_REVOKEDRAGDROP, reinterpret_cast<WPARAM>(this), 0);
+        PostThreadMessageW( m_threadIdTarget, WM_REVOKEDRAGDROP, reinterpret_cast<WPARAM>(this), 0);
         WaitForSingleObject( m_hOleThread, INFINITE);
         CloseHandle( m_hOleThread);
         //OSL_ENSURE( SUCCEEDED( hr), "HWND not valid!" );
@@ -142,13 +142,13 @@ void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments )
             m_threadIdWindow= GetWindowThreadProcessId( m_hWnd, nullptr);
             // The event is set by the thread that we will create momentarily.
             // It indicates that the thread is ready to receive messages.
-            HANDLE m_evtThreadReady= CreateEvent( nullptr, FALSE, FALSE, nullptr);
+            HANDLE m_evtThreadReady= CreateEventW( nullptr, FALSE, FALSE, nullptr);
 
             m_hOleThread= CreateThread( nullptr, 0, DndTargetOleSTAFunc,
                                             &m_evtThreadReady, 0, &m_threadIdTarget);
             WaitForSingleObject( m_evtThreadReady, INFINITE);
             CloseHandle( m_evtThreadReady);
-            PostThreadMessage( m_threadIdTarget, WM_REGISTERDRAGDROP, reinterpret_cast<WPARAM>(this), 0);
+            PostThreadMessageW( m_threadIdTarget, WM_REGISTERDRAGDROP, reinterpret_cast<WPARAM>(this), 0);
         }
         else if( hr == S_OK || hr == S_FALSE)
         {
@@ -197,7 +197,7 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams)
     {
         MSG msg;
         // force the creation of a message queue
-        PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE);
+        PeekMessageW( &msg, nullptr, 0, 0, PM_NOREMOVE);
         // Signal the creator ( DropTarget::initialize) that the thread is
         // ready to receive messages.
         SetEvent( *static_cast<HANDLE*>(pParams));
@@ -206,7 +206,7 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams)
         DWORD threadId= GetCurrentThreadId();
         // We force the creation of a thread message queue. This is necessary
         // for a later call to AttachThreadInput
-        while( GetMessage(&msg, nullptr, 0, 0) )
+        while( GetMessageW(&msg, nullptr, 0, 0) )
         {
             if( msg.message == WM_REGISTERDRAGDROP)
             {
@@ -238,7 +238,7 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams)
                 break;
             }
             TranslateMessage(  &msg);
-            DispatchMessage( &msg);
+            DispatchMessageW( &msg);
         }
         OleUninitialize();
     }
diff --git a/dtrans/source/win32/dtobj/DTransHelper.cxx b/dtrans/source/win32/dtobj/DTransHelper.cxx
index 49151f4d4fd1..552ec1368f1a 100644
--- a/dtrans/source/win32/dtobj/DTransHelper.cxx
+++ b/dtrans/source/win32/dtobj/DTransHelper.cxx
@@ -177,7 +177,7 @@ sal_uInt32 SAL_CALL CStgTransferHelper::memSize( CLIPFORMAT cf ) const
         HGLOBAL hGlob;
         GetHGlobalFromStream( m_lpStream, &hGlob );
 
-        if ( CF_TEXT == cf || RegisterClipboardFormat( "HTML Format" ) == cf )
+        if ( CF_TEXT == cf || RegisterClipboardFormatW( L"HTML Format" ) == cf )
         {
             sal_Char* pText = static_cast< sal_Char* >( GlobalLock( hGlob ) );
             if ( pText )
diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx
index 9c6f40047967..c72f2646563b 100644
--- a/dtrans/source/win32/dtobj/DataFmtTransl.cxx
+++ b/dtrans/source/win32/dtobj/DataFmtTransl.cxx
@@ -87,7 +87,7 @@ CFormatEtc CDataFormatTranslator::getFormatEtcFromDataFlavor( const DataFlavor&
                     aFormat >>= aClipFmtName;
 
                     OSL_ASSERT( aClipFmtName.getLength( ) );
-                    cf = RegisterClipboardFormatW( reinterpret_cast<LPCWSTR>(aClipFmtName.getStr( )) );
+                    cf = RegisterClipboardFormatW( SAL_W(aClipFmtName.getStr( )) );
 
                     OSL_ENSURE( CF_INVALID != cf, "RegisterClipboardFormat failed" );
                 }
@@ -163,7 +163,7 @@ CFormatEtc SAL_CALL CDataFormatTranslator::getFormatEtcForClipformatName( const
     if ( !aClipFmtName.getLength( ) )
         return CFormatEtc( CF_INVALID );
 
-    CLIPFORMAT cf = sal::static_int_cast<CLIPFORMAT>(RegisterClipboardFormatW( reinterpret_cast<LPCWSTR>(aClipFmtName.getStr( )) ));
+    CLIPFORMAT cf = sal::static_int_cast<CLIPFORMAT>(RegisterClipboardFormatW( SAL_W(aClipFmtName.getStr( )) ));
     return getFormatEtcForClipformat( cf );
 }
 
@@ -172,7 +172,7 @@ OUString CDataFormatTranslator::getClipboardFormatName( CLIPFORMAT aClipformat )
     OSL_PRECOND( CF_INVALID != aClipformat, "Invalid clipboard format" );
 
     sal_Unicode wBuff[ MAX_CLIPFORMAT_NAME + 1 ]; // Null terminator isn't counted, apparently.
-    sal_Int32   nLen = GetClipboardFormatNameW( aClipformat, reinterpret_cast<LPWSTR>(wBuff), MAX_CLIPFORMAT_NAME );
+    sal_Int32   nLen = GetClipboardFormatNameW( aClipformat, SAL_W(wBuff), MAX_CLIPFORMAT_NAME );
 
     return OUString( wBuff, nLen );
 }
@@ -204,7 +204,7 @@ CFormatEtc SAL_CALL CDataFormatTranslator::getFormatEtcForClipformat( CLIPFORMAT
         of which FileContents it wants to paste
         see MSDN: "Handling Shell Data Transfer Scenarios"
     */
-    if ( cf == RegisterClipboardFormatA( CFSTR_FILECONTENTS ) )
+    if ( cf == RegisterClipboardFormat( CFSTR_FILECONTENTS ) )
          fetc.setLindex( 0 );
 
     return fetc;
diff --git a/dtrans/source/win32/misc/ImplHelper.cxx b/dtrans/source/win32/misc/ImplHelper.cxx
index 8047ffc9a424..f9d5a07a7f28 100644
--- a/dtrans/source/win32/misc/ImplHelper.cxx
+++ b/dtrans/source/win32/misc/ImplHelper.cxx
@@ -92,27 +92,23 @@ OUString SAL_CALL getWinCPFromLocaleId( LCID lcid, LCTYPE lctype )
     else
         OSL_ASSERT( false );
 
-    // we use the GetLocaleInfoA because don't want to provide
-    // a unicode wrapper function for Win9x in sal/systools
-    char buff[6];
-    sal_Int32 nResult = GetLocaleInfoA(
-        lcid, lctype | LOCALE_USE_CP_ACP, buff, sizeof( buff ) );
+    // First, get required buffer size, in characters
+    int nResult = GetLocaleInfoW(
+        lcid, lctype, nullptr, 0 );
 
     OSL_ASSERT( nResult );
 
     if ( nResult )
     {
-        sal_Int32 len = MultiByteToWideChar(
-            CP_ACP, 0, buff, -1, nullptr, 0 );
+        std::unique_ptr<wchar_t> buff( new wchar_t[nResult] );
+        // Now get the actual data
+        nResult = GetLocaleInfoW( lcid, lctype, buff.get(), nResult );
 
-        OSL_ASSERT( len > 0 );
+        OSL_ASSERT(nResult);
 
-        std::vector< sal_Unicode > lpwchBuff(len);
+        if (nResult)
+            winCP = SAL_U( buff.get() );
 
-        len = MultiByteToWideChar(
-            CP_ACP, 0, buff, -1, reinterpret_cast<LPWSTR>(&lpwchBuff[0]), len );
-
-        winCP = OUString( &lpwchBuff[0], (len - 1) );
     }
 
     return winCP;
diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx
index 929e8d252350..c596af732f93 100644
--- a/embedserv/source/embed/docholder.cxx
+++ b/embedserv/source/embed/docholder.cxx
@@ -505,12 +505,12 @@ void DocumentHolder::UIDeactivate()
 void CopyToOLEMenu(HMENU hOrig,WORD origPos,HMENU hDest,WORD destPos)
 {
     HMENU subMenu(nullptr);
-    char buffer[256];
+    wchar_t buffer[256];
 
     subMenu = GetSubMenu(hOrig,origPos);
-    GetMenuString(hOrig,origPos,buffer,256,MF_BYPOSITION);
-    InsertMenu(hDest,destPos,MF_BYPOSITION | MF_POPUP,
-               reinterpret_cast<UINT_PTR>(subMenu),LPCTSTR(buffer));
+    GetMenuStringW(hOrig,origPos,buffer,256,MF_BYPOSITION);
+    InsertMenuW(hDest,destPos,MF_BYPOSITION | MF_POPUP,
+               reinterpret_cast<UINT_PTR>(subMenu),buffer);
 
     MENUITEMINFOW mi;
     memset(&mi,0,sizeof(mi));
diff --git a/embedserv/source/embed/ed_idataobj.cxx b/embedserv/source/embed/ed_idataobj.cxx
index f682254e1f9d..fe37ad43ddd6 100644
--- a/embedserv/source/embed/ed_idataobj.cxx
+++ b/embedserv/source/embed/ed_idataobj.cxx
@@ -118,8 +118,8 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM
     }
     else
     {
-        CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" );
-        CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
+        CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" );
+        CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
         if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj )
         {
             if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
@@ -157,8 +157,8 @@ STDMETHODIMP EmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM
       || pFormatetc->dwAspect == DVASPECT_DOCPRINT )
         return DV_E_DVASPECT;
 
-    CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" );
-    CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
+    CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" );
+    CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
 
     if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj )
     {
@@ -204,8 +204,8 @@ STDMETHODIMP EmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc )
         }
         else
         {
-            CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" );
-            CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
+            CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" );
+            CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
             if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj )
             {
                 if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) )
@@ -241,8 +241,8 @@ STDMETHODIMP EmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn
     }
     else
     {
-        CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatA( "Embed Source" );
-        CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
+        CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" );
+        CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
         if ( pFormatetcIn->cfFormat == cf_embSource || pFormatetcIn->cfFormat == cf_embObj )
         {
             pFormatetcOut->tymed = TYMED_ISTORAGE;
diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx
index 0de9ab79fd09..70c8b226a4df 100644
--- a/embedserv/source/embed/ed_ipersiststr.cxx
+++ b/embedserv/source/embed/ed_ipersiststr.cxx
@@ -422,7 +422,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg )
                 if ( hr == S_OK )
                 {
                     wchar_t const * aCurType = getStorageTypeFromGUID_Impl( &m_guid ); // ???
-                    CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
+                    CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
                     hr = WriteFmtUserTypeStg( pStg,
                                             cf,                         // ???
                                             const_cast<wchar_t *>(aCurType) );
@@ -750,7 +750,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ )
     if ( FAILED( hr ) || !m_pMasterStorage ) return E_FAIL;
 
     o3tl::u16string_view aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ???
-    CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
+    CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
     hr = WriteFmtUserTypeStg( m_pMasterStorage,
                             cf,                         // ???
                             const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) );
@@ -801,7 +801,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ )
         if ( hr == S_OK )
         {
             aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ???
-            cf = (CLIPFORMAT)RegisterClipboardFormatA( "Embedded Object" );
+            cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" );
             hr = WriteFmtUserTypeStg( m_pMasterStorage,
                                     cf,                         // ???
                                     const_cast<wchar_t *>(reinterpret_cast<wchar_t const *>(aCurType.data())) );
diff --git a/embedserv/source/embed/syswinwrapper.cxx b/embedserv/source/embed/syswinwrapper.cxx
index 64eefc17af38..ef92307b0d53 100644
--- a/embedserv/source/embed/syswinwrapper.cxx
+++ b/embedserv/source/embed/syswinwrapper.cxx
@@ -40,7 +40,7 @@ using namespace winwrap;
 //Notification codes for WM_COMMAND messages
 #define HWN_BORDERDOUBLECLICKED         1
 #define CBHATCHWNDEXTRA                 (sizeof(LONG))
-#define SZCLASSHATCHWIN                 TEXT("hatchwin")
+#define SZCLASSHATCHWIN                 L"hatchwin"
 
 typedef CHatchWin *PCHatchWin;
 
@@ -106,7 +106,7 @@ HINSTANCE winwrap::CWindow::Instance()
 
 BOOL winwrap::HatchWindowRegister(HINSTANCE hInst)
 {
-    WNDCLASS    wc;
+    WNDCLASSW    wc;
 
     //Must have CS_DBLCLKS for border!
     wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
@@ -120,7 +120,7 @@ BOOL winwrap::HatchWindowRegister(HINSTANCE hInst)
     wc.lpszMenuName  = nullptr;
     wc.lpszClassName = SZCLASSHATCHWIN;
 
-    return RegisterClass(&wc);
+    return RegisterClassW(&wc);
 }
 
 
@@ -141,8 +141,8 @@ CHatchWin::CHatchWin(HINSTANCE hInst,const DocumentHolder* pDocHolder)
     m_hWndAssociate=nullptr;
     m_uID=0;
 
-    m_dBorderOrg=GetProfileInt(TEXT("windows")
-                               , TEXT("OleInPlaceBorderWidth")
+    m_dBorderOrg=GetProfileIntW(L"windows"
+                               , L"OleInPlaceBorderWidth"
                                , HATCHWIN_BORDERWIDTHDEFAULT);
 
     m_dBorder=m_dBorderOrg;
@@ -187,7 +187,7 @@ CHatchWin::~CHatchWin()
 BOOL CHatchWin::Init(HWND hWndParent, WORD uID, HWND hWndAssoc)
 {
     m_hWndParent = hWndParent;
-    m_hWnd=CreateWindowEx(
+    m_hWnd=CreateWindowExW(
         WS_EX_NOPARENTNOTIFY, SZCLASSHATCHWIN
         , SZCLASSHATCHWIN, WS_CHILD | WS_CLIPSIBLINGS
         | WS_CLIPCHILDREN, 0, 0, 100, 100, hWndParent
@@ -370,14 +370,14 @@ LRESULT APIENTRY winwrap::HatchWndProc(
     HDC         hDC;
     PAINTSTRUCT ps;
 
-    phw=reinterpret_cast<PCHatchWin>(GetWindowLongPtr(hWnd, HWWL_STRUCTURE));
+    phw=reinterpret_cast<PCHatchWin>(GetWindowLongPtrW(hWnd, HWWL_STRUCTURE));
     POINT ptMouse;
 
     switch (iMsg)
     {
         case WM_CREATE:
             phw=static_cast<PCHatchWin>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
-            SetWindowLongPtr(hWnd, HWWL_STRUCTURE, reinterpret_cast<LONG_PTR>(phw));
+            SetWindowLongPtrW(hWnd, HWWL_STRUCTURE, reinterpret_cast<LONG_PTR>(phw));
             break;
         case WM_PAINT:
             hDC=BeginPaint(hWnd,&ps);
@@ -421,7 +421,7 @@ LRESULT APIENTRY winwrap::HatchWndProc(
              */
             if (nullptr!=phw->m_hWndAssociate)
             {
-                SendMessage(
+                SendMessageW(
                     phw->m_hWndAssociate, WM_COMMAND,
                     MAKEWPARAM(phw->m_uID, HWN_BORDERDOUBLECLICKED),
                     reinterpret_cast<LPARAM>(hWnd));
@@ -429,7 +429,7 @@ LRESULT APIENTRY winwrap::HatchWndProc(
 
             break;
         default:
-            return DefWindowProc(hWnd, iMsg, wParam, lParam);
+            return DefWindowProcW(hWnd, iMsg, wParam, lParam);
     }
 
     return 0;
diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx
index b39f5499d53f..ae30e630f709 100644
--- a/embedserv/source/embed/tracker.cxx
+++ b/embedserv/source/embed/tracker.cxx
@@ -255,10 +255,9 @@ void Tracker::Construct()
         }
 
         // get default handle size from Windows profile setting
-        static const TCHAR szWindows[] = TEXT("windows");
-        static const TCHAR szInplaceBorderWidth[] =
-            TEXT("oleinplaceborderwidth");
-        afxHandleSize = GetProfileInt(szWindows, szInplaceBorderWidth, 4);
+        static const WCHAR szWindows[] = L"windows";
+        static const WCHAR szInplaceBorderWidth[] = L"oleinplaceborderwidth";
+        afxHandleSize = GetProfileIntW(szWindows, szInplaceBorderWidth, 4);
         bInitialized = TRUE;
 
         afxCursors[0] = afxCursors[2] = LoadCursor(nullptr,IDC_SIZENWSE);
@@ -396,7 +395,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo)
     for (;;)
     {
         MSG msg;
-        GetMessage(&msg, nullptr, 0, 0);
+        GetMessageW(&msg, nullptr, 0, 0);
 
         if (GetCapture() != hWnd)
             break;
@@ -461,7 +460,7 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo)
 
             // just dispatch rest of the messages
         default:
-            DispatchMessage(&msg);
+            DispatchMessageW(&msg);
             break;
         }
     }
diff --git a/embedserv/source/inprocserv/dllentry.cxx b/embedserv/source/inprocserv/dllentry.cxx
index a4346eab84c2..f6f3b21d01df 100644
--- a/embedserv/source/inprocserv/dllentry.cxx
+++ b/embedserv/source/inprocserv/dllentry.cxx
@@ -42,47 +42,47 @@ static ULONG g_nLock = 0;
 
 
 namespace {
-    void FillCharFromInt( int nValue, char* pBuf, int nLen )
+    void FillCharFromInt( int nValue, wchar_t* pBuf, int nLen )
     {
         int nInd = 0;
         while( nInd < nLen )
         {
             char nSign = ( nValue / ( 1 << ( ( nLen - nInd - 1 ) * 4 ) ) ) % 16;
             if ( nSign >= 0 && nSign <= 9 )
-                pBuf[nInd] = nSign + '0';
+                pBuf[nInd] = nSign + L'0';
             else if ( nSign >= 10 && nSign <= 15 )
-                pBuf[nInd] = nSign - 10 + 'a';
+                pBuf[nInd] = nSign - 10 + L'a';
 
             nInd++;
         }
     }
 
-    int GetStringFromClassID( const GUID& guid, char* pBuf, int nLen )
+    int GetStringFromClassID( const GUID& guid, wchar_t* pBuf, int nLen )
     {
         // is not allowed to insert
         if ( nLen < 38 )
             return 0;
 
-        pBuf[0] = '{';
+        pBuf[0] = L'{';
         FillCharFromInt( guid.Data1, &pBuf[1], 8 );
-        pBuf[9] = '-';
+        pBuf[9] = L'-';
         FillCharFromInt( guid.Data2, &pBuf[10], 4 );
-        pBuf[14] = '-';
+        pBuf[14] = L'-';
         FillCharFromInt( guid.Data3, &pBuf[15], 4 );
-        pBuf[19] = '-';
+        pBuf[19] = L'-';
 
         int nInd = 0;
         for ( nInd = 0; nInd < 2 ; nInd++ )
             FillCharFromInt( guid.Data4[nInd], &pBuf[20 + 2*nInd], 2 );
-        pBuf[24] = '-';
+        pBuf[24] = L'-';
         for ( nInd = 2; nInd < 8 ; nInd++ )
             FillCharFromInt( guid.Data4[nInd], &pBuf[20 + 1 + 2*nInd], 2 );
-        pBuf[37] = '}';
+        pBuf[37] = L'}';
 
         return 38;
     }
 
-    HRESULT WriteLibraryToRegistry( const char* pLibrary, DWORD nLen )
+    HRESULT WriteLibraryToRegistry( const wchar_t* pLibrary, DWORD nLen )
     {
         HRESULT hRes = E_FAIL;
         if ( pLibrary && nLen )
@@ -92,18 +92,18 @@ namespace {
             hRes = S_OK;
             for ( int nInd = 0; nInd < SUPPORTED_FACTORIES_NUM; nInd++ )
             {
-                const char pSubKeyTemplate[] = "Software\\Classes\\CLSID\\.....................................\\InprocHandler32";
-                char pSubKey[SAL_N_ELEMENTS(pSubKeyTemplate)];
-                strncpy(pSubKey, pSubKeyTemplate, SAL_N_ELEMENTS(pSubKeyTemplate));
+                const wchar_t pSubKeyTemplate[] = L"Software\\Classes\\CLSID\\.....................................\\InprocHandler32";
+                wchar_t pSubKey[SAL_N_ELEMENTS(pSubKeyTemplate)];
+                wcsncpy(pSubKey, pSubKeyTemplate, SAL_N_ELEMENTS(pSubKeyTemplate));
 
                 int nGuidLen = GetStringFromClassID( *guidList[nInd], &pSubKey[23], 38 );
 
                 BOOL bLocalSuccess = FALSE;
                 if ( nGuidLen == 38 )
                 {
-                    if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, pSubKey, &hKey ) )
+                    if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_LOCAL_MACHINE, pSubKey, &hKey ) )
                     {
-                        if ( ERROR_SUCCESS == RegSetValueEx( hKey, "", 0, REG_SZ, reinterpret_cast<const BYTE*>(pLibrary), nLen ) )
+                        if ( ERROR_SUCCESS == RegSetValueExW( hKey, L"", 0, REG_SZ, reinterpret_cast<const BYTE*>(pLibrary), nLen*sizeof(wchar_t) ) )
                             bLocalSuccess = TRUE;
                     }
 
@@ -199,11 +199,11 @@ STDAPI DllCanUnloadNow()
 
 STDAPI DllRegisterServer()
 {
-    HMODULE aCurModule = GetModuleHandleA( "inprocserv.dll" );
+    HMODULE aCurModule = GetModuleHandleW( L"inprocserv.dll" );
     if( aCurModule )
     {
-        char aLibPath[1024];
-        DWORD nLen = GetModuleFileNameA( aCurModule, aLibPath, 1019 );
+        wchar_t aLibPath[1024];
+        DWORD nLen = GetModuleFileNameW( aCurModule, aLibPath, 1019 );
         if ( nLen && nLen < 1019 )
         {
             aLibPath[nLen++] = 0;
@@ -217,7 +217,7 @@ STDAPI DllRegisterServer()
 
 STDAPI DllUnregisterServer()
 {
-    return WriteLibraryToRegistry( "ole32.dll", 10 );
+    return WriteLibraryToRegistry( L"ole32.dll", 10 );
 }
 
 
diff --git a/extensions/source/activex/SOActiveX.cxx b/extensions/source/activex/SOActiveX.cxx
index 436700851200..304b74812756 100644
--- a/extensions/source/activex/SOActiveX.cxx
+++ b/extensions/source/activex/SOActiveX.cxx
@@ -39,23 +39,23 @@
 
 #pragma warning (pop)
 
-#define STAROFFICE_WINDOWCLASS "SOParentWindow"
+#define STAROFFICE_WINDOWCLASS L"SOParentWindow"
 
 
 void OutputError_Impl( HWND hw, HRESULT ErrorCode )
 {
-    LPTSTR sMessage;
-    FormatMessageA(
+    LPWSTR sMessage;
+    FormatMessageW(
         FORMAT_MESSAGE_ALLOCATE_BUFFER |
         FORMAT_MESSAGE_FROM_SYSTEM,
         nullptr,
         ErrorCode,
         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
-        reinterpret_cast<LPTSTR>(&sMessage),
+        reinterpret_cast<LPWSTR>(&sMessage),
         0,
         nullptr
     );
-    ::MessageBoxA( hw, sMessage, nullptr, MB_OK | MB_ICONINFORMATION );
+    MessageBoxW( hw, sMessage, nullptr, MB_OK | MB_ICONINFORMATION );
     LocalFree( sMessage );
 }
 
@@ -164,17 +164,17 @@ CSOActiveX::CSOActiveX()
         OutputError_Impl( nullptr, hr );
 
     mPWinClass.style            = CS_HREDRAW|CS_VREDRAW;
-    mPWinClass.lpfnWndProc      = ::DefWindowProc;
+    mPWinClass.lpfnWndProc      = DefWindowProcW;
     mPWinClass.cbClsExtra       = 0;
     mPWinClass.cbWndExtra       = 0;
-    mPWinClass.hInstance        = GetModuleHandle(nullptr); //myInstance;
+    mPWinClass.hInstance        = GetModuleHandleW(nullptr); //myInstance;
     mPWinClass.hIcon            = nullptr;
     mPWinClass.hCursor          = nullptr;
     mPWinClass.hbrBackground    = reinterpret_cast<HBRUSH>(COLOR_BACKGROUND);
     mPWinClass.lpszMenuName     = nullptr;
     mPWinClass.lpszClassName    = STAROFFICE_WINDOWCLASS;
 
-    RegisterClass(&mPWinClass);
+    RegisterClassW(&mPWinClass);
 }
 
 CSOActiveX::~CSOActiveX()
@@ -991,9 +991,9 @@ HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di )
             }
 
             mParentWin = hwnd;
-            mOffWin = CreateWindow(
+            mOffWin = CreateWindowW(
                                 STAROFFICE_WINDOWCLASS,
-                                "OfficeContainer",
+                                L"OfficeContainer",
                                 WS_CHILD | WS_CLIPCHILDREN | WS_BORDER,
                                 di.prcBounds->left,
                                 di.prcBounds->top,
diff --git a/extensions/source/activex/SOActiveX.h b/extensions/source/activex/SOActiveX.h
index 14451fcdbf51..5f652e6b6752 100644
--- a/extensions/source/activex/SOActiveX.h
+++ b/extensions/source/activex/SOActiveX.h
@@ -90,7 +90,7 @@ protected:
     OLECHAR const *         mCurFileUrl;
     BOOL                    mbLoad;
     BOOL                    mbViewOnly;
-    WNDCLASS                mPWinClass;
+    WNDCLASSW               mPWinClass;
     HWND                    mParentWin;
     HWND                    mOffWin;
 
diff --git a/extensions/source/scanner/scanwin.cxx b/extensions/source/scanner/scanwin.cxx
index 117e8d55f80e..437b408a6918 100644
--- a/extensions/source/scanner/scanwin.cxx
+++ b/extensions/source/scanner/scanwin.cxx
@@ -127,7 +127,7 @@ static ImpTwain* pImpTwainInstance = nullptr;
 
 LRESULT CALLBACK TwainWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
 {
-    return DefWindowProc( hWnd, nMsg, nPar1, nPar2 );
+    return DefWindowProcW( hWnd, nMsg, nPar1, nPar2 );
 }
 
 LRESULT CALLBACK TwainMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
@@ -235,11 +235,11 @@ ImpTwain::ImpTwain( ScannerManager& rMgr, const Link<unsigned long,void>& rNotif
     strncpy( aAppIdent.ProductName, "Office", 32 );
     aAppIdent.ProductName[32] = aAppIdent.ProductName[33] = 0;
 
-    WNDCLASS aWc = { 0, &TwainWndProc, 0, sizeof( WNDCLASS ), GetModuleHandle( nullptr ), nullptr, nullptr, nullptr, nullptr, "TwainClass" };
-    RegisterClass( &aWc );
+    WNDCLASSW aWc = { 0, &TwainWndProc, 0, sizeof( WNDCLASSW ), GetModuleHandleW( nullptr ), nullptr, nullptr, nullptr, nullptr, L"TwainClass" };
+    RegisterClassW( &aWc );
 
-    hTwainWnd = CreateWindowEx( WS_EX_TOPMOST, aWc.lpszClassName, "TWAIN", 0, 0, 0, 0, 0, HWND_DESKTOP, nullptr, aWc.hInstance, nullptr );
-    hTwainHook = SetWindowsHookEx( WH_GETMESSAGE, &TwainMsgProc, nullptr, GetCurrentThreadId() );
+    hTwainWnd = CreateWindowExW( WS_EX_TOPMOST, aWc.lpszClassName, L"TWAIN", 0, 0, 0, 0, 0, HWND_DESKTOP, nullptr, aWc.hInstance, nullptr );
+    hTwainHook = SetWindowsHookExW( WH_GETMESSAGE, &TwainMsgProc, nullptr, GetCurrentThreadId() );
 
     // block destruction until ImplDestroyHdl is called
     mxSelfRef = static_cast< ::cppu::OWeakObject* >( this );
diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
index c3ce95a8054b..c615abd49afd 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
@@ -929,8 +929,8 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest)
                 OUString aSystemPath;
                 osl_getSystemPathFromFileURL( aFileURL.pData, &aSystemPath.pData );
 
-                WIN32_FIND_DATA aFindFileData;
-                HANDLE  hFind = FindFirstFile( reinterpret_cast<PCWSTR>(aSystemPath.getStr()), &aFindFileData );
+                WIN32_FIND_DATAW aFindFileData;
+                HANDLE  hFind = FindFirstFileW( SAL_W(aSystemPath.getStr()), &aFindFileData );
                 if (hFind != INVALID_HANDLE_VALUE)
                     iDialog->SetFolder(pFolder);
                 else
diff --git a/fpicker/source/win32/folderpicker/MtaFop.cxx b/fpicker/source/win32/folderpicker/MtaFop.cxx
index 5e5de9f612c4..e98c20b6e732 100644
--- a/fpicker/source/win32/folderpicker/MtaFop.cxx
+++ b/fpicker/source/win32/folderpicker/MtaFop.cxx
@@ -42,9 +42,9 @@ const bool INIT_NONSIGNALED = false;
 
 namespace
 {
-    const char* const FOLDERPICKER_SRV_DLL_NAME = "fps.dll";
-    const char g_szWndClsName[]           = "FopStaReqWnd###";
-    const char* const CURRENT_INSTANCE          = "CurrInst";
+    const wchar_t* const FOLDERPICKER_SRV_DLL_NAME = L"fps.dll";
+    const wchar_t g_szWndClsName[]                 = L"FopStaReqWnd###";
+    const wchar_t* const CURRENT_INSTANCE          = L"CurrInst";
 
     struct RequestContext
     {
@@ -56,7 +56,7 @@ namespace
     {
         OSL_ASSERT( aRequestContext );
 
-        aRequestContext->hEvent = CreateEventA(
+        aRequestContext->hEvent = CreateEventW(
             nullptr, AUTO_RESET, INIT_NONSIGNALED, nullptr );
 
         aRequestContext->bRet = false;
@@ -106,7 +106,7 @@ CMtaFolderPicker::CMtaFolderPicker( sal_uInt32 Flags ) :
     m_hEvtThrdReady( nullptr ),
     m_hwndStaRequestWnd( nullptr )
 {
-    m_hInstance = GetModuleHandleA( FOLDERPICKER_SRV_DLL_NAME );
+    m_hInstance = GetModuleHandleW( FOLDERPICKER_SRV_DLL_NAME );
     OSL_ENSURE( m_hInstance, "The name of the FolderPicker service dll must have changed" );
 
     ZeroMemory( &m_bi, sizeof( m_bi ) );
@@ -142,7 +142,7 @@ CMtaFolderPicker::CMtaFolderPicker( sal_uInt32 Flags ) :
     m_Description = CResourceProvider::getResString(FOLDER_PICKER_DEF_DESCRIPTION);
 
     // signals that the thread was successfully set up
-    m_hEvtThrdReady  = CreateEventA(
+    m_hEvtThrdReady  = CreateEventW(
         nullptr,
         MANUAL_RESET,
         INIT_NONSIGNALED,
@@ -187,7 +187,7 @@ CMtaFolderPicker::~CMtaFolderPicker( )
         // the thread that created the window
         if ( IsWindow( m_hwndStaRequestWnd ) )
         {
-            SendMessageA( m_hwndStaRequestWnd, MSG_SHUTDOWN, 0, 0 );
+            SendMessageW( m_hwndStaRequestWnd, MSG_SHUTDOWN, 0, 0 );
 
             // we place unregister class here because
             // if we have a valid window we must have
@@ -243,7 +243,7 @@ bool CMtaFolderPicker::browseForFolder( )
         }
 
         // marshall request into the sta thread
-        BOOL const ret = PostMessageA(
+        BOOL const ret = PostMessageW(
             m_hwndStaRequestWnd,
             MSG_BROWSEFORFOLDER,
             0,
@@ -278,8 +278,8 @@ bool CMtaFolderPicker::browseForFolder( )
                     // mouse messages are for the FolderPicker which
                     // is in the foreground and should not arrive here
                     MSG msg;
-                    while ( PeekMessageA( &msg, nullptr, 0, 0, PM_REMOVE ) )
-                        DispatchMessageA(&msg);
+                    while ( PeekMessageW( &msg, nullptr, 0, 0, PM_REMOVE ) )
+                        DispatchMessageW(&msg);
                 }
                 break;
 
@@ -346,7 +346,7 @@ void SAL_CALL CMtaFolderPicker::cancel( )
     {
         // simulate a mouse click to the
         // cancel button
-        BOOL const ret = PostMessageA(
+        BOOL const ret = PostMessageW(
             m_hwnd,
             WM_COMMAND,
             MAKEWPARAM( IDCANCEL, BN_CLICKED ),
@@ -425,7 +425,7 @@ OUString SAL_CALL CMtaFolderPicker::getPathFromItemIdList( LPCITEMIDLIST lpItemI
 
     if ( lpItemIdList )
     {
-        bool bRet = SHGetPathFromIDListW( lpItemIdList, reinterpret_cast<LPWSTR>(m_pathBuff) );
+        bool bRet = SHGetPathFromIDListW( lpItemIdList, SAL_W(m_pathBuff) );
         if ( bRet )
             path = m_pathBuff;
     }
@@ -476,7 +476,7 @@ void SAL_CALL CMtaFolderPicker::onInitialized( )
 
     if ( lpiidDisplayDir )
     {
-        SendMessageA(
+        SendMessageW(
             m_hwnd,
             BFFM_SETSELECTION,
             (WPARAM)false,
@@ -506,7 +506,7 @@ int CALLBACK CMtaFolderPicker::FolderPickerCallback( HWND hwnd, UINT uMsg, LPARA
         case BFFM_INITIALIZED:
             pImpl->m_hwnd = hwnd;
             pImpl->onInitialized( );
-            SetWindowTextW( hwnd, reinterpret_cast<LPCWSTR>(pImpl->m_dialogTitle.getStr()) );
+            SetWindowTextW( hwnd, SAL_W(pImpl->m_dialogTitle.getStr()) );
         break;
 
         case BFFM_SELCHANGED:
@@ -547,20 +547,20 @@ LRESULT CALLBACK CMtaFolderPicker::StaWndProc( HWND hWnd, UINT uMsg, WPARAM wPar
     {
         case WM_CREATE:
             {
-                LPCREATESTRUCT lpcs =
-                    reinterpret_cast< LPCREATESTRUCT >( lParam );
+                LPCREATESTRUCTW lpcs =
+                    reinterpret_cast< LPCREATESTRUCTW >( lParam );
 
                 OSL_ASSERT( lpcs->lpCreateParams );
 
                 // connect the instance handle to the window
-                SetPropA( hWnd, CURRENT_INSTANCE, lpcs->lpCreateParams );
+                SetPropW( hWnd, CURRENT_INSTANCE, lpcs->lpCreateParams );
             }
             break;
 
         case WM_NCDESTROY:
                 // RemoveProp returns the saved value on success
                 pImpl = static_cast< CMtaFolderPicker* >(
-                    RemovePropA( hWnd, CURRENT_INSTANCE ) );
+                    RemovePropW( hWnd, CURRENT_INSTANCE ) );
 
                 OSL_ASSERT( pImpl && !IsBadReadPtr( pImpl, sizeof( CMtaFolderPicker ) ) );
             break;
@@ -571,7 +571,7 @@ LRESULT CALLBACK CMtaFolderPicker::StaWndProc( HWND hWnd, UINT uMsg, WPARAM wPar
                 OSL_ASSERT( aReqCtx );
 
                 pImpl = static_cast< CMtaFolderPicker* >(
-                    GetPropA( hWnd, CURRENT_INSTANCE ) );
+                    GetPropW( hWnd, CURRENT_INSTANCE ) );
 
                 OSL_ASSERT( pImpl && !IsBadReadPtr( pImpl, sizeof( CMtaFolderPicker ) ) );
 
@@ -582,7 +582,7 @@ LRESULT CALLBACK CMtaFolderPicker::StaWndProc( HWND hWnd, UINT uMsg, WPARAM wPar
 
         case MSG_SHUTDOWN:
             pImpl = static_cast< CMtaFolderPicker* >(
-                GetPropA( hWnd, CURRENT_INSTANCE ) );
+                GetPropW( hWnd, CURRENT_INSTANCE ) );
 
             OSL_ASSERT( pImpl && !IsBadReadPtr( pImpl, sizeof( CMtaFolderPicker ) ) );
 
@@ -594,7 +594,7 @@ LRESULT CALLBACK CMtaFolderPicker::StaWndProc( HWND hWnd, UINT uMsg, WPARAM wPar
             break;
 
         default:
-            lResult = DefWindowProcA( hWnd, uMsg, wParam, lParam );
+            lResult = DefWindowProcW( hWnd, uMsg, wParam, lParam );
             break;
     }
 
@@ -608,7 +608,7 @@ bool SAL_CALL CMtaFolderPicker::createStaRequestWindow( )
 
     if ( RegisterStaRequestWindowClass( ) )
     {
-        m_hwndStaRequestWnd = CreateWindowA(
+        m_hwndStaRequestWnd = CreateWindowW(
             g_szWndClsName, nullptr,
             0, 0, 0, 0, 0,
             nullptr, nullptr, m_hInstance,
@@ -653,8 +653,8 @@ unsigned int CMtaFolderPicker::run( )
 
         // pumping messages
         MSG msg;
-        while( GetMessageA( &msg, nullptr, 0, 0 ) )
-            DispatchMessageA( &msg );
+        while( GetMessageW( &msg, nullptr, 0, 0 ) )
+            DispatchMessageW( &msg );
 
         nRet = 0;
     }
@@ -697,11 +697,11 @@ ATOM SAL_CALL CMtaFolderPicker::RegisterStaRequestWindowClass( )
 
     if ( 0 == s_ClassAtom )
     {
-        WNDCLASSEXA  wcex;
+        WNDCLASSEXW  wcex;
 
-        ZeroMemory( &wcex, sizeof( WNDCLASSEXA ) );
+        ZeroMemory( &wcex, sizeof( wcex ) );
 
-        wcex.cbSize         = sizeof(WNDCLASSEXA);
+        wcex.cbSize         = sizeof(wcex);
         wcex.style          = 0;
         wcex.lpfnWndProc    = static_cast< WNDPROC >( CMtaFolderPicker::StaWndProc );
         wcex.cbClsExtra     = 0;
@@ -714,7 +714,7 @@ ATOM SAL_CALL CMtaFolderPicker::RegisterStaRequestWindowClass( )
         wcex.lpszClassName  = g_szWndClsName;
         wcex.hIconSm        = nullptr;
 
-        s_ClassAtom = RegisterClassExA( &wcex );
+        s_ClassAtom = RegisterClassExW( &wcex );
         OSL_ASSERT( s_ClassAtom );
     }
 
@@ -745,8 +745,7 @@ void SAL_CALL CMtaFolderPicker::UnregisterStaRequestWindowClass( )
 
     if ( 0 == s_StaRequestWndRegisterCount )
     {
-        UnregisterClassA(
-            reinterpret_cast<PCSTR>((DWORD_PTR)MAKELONG( s_ClassAtom, 0 )), m_hInstance );
+        UnregisterClass( MAKEINTATOM(s_ClassAtom), m_hInstance );
 
         s_ClassAtom = 0;
     }
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 8ac074eff35c..47869520de23 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -532,11 +532,11 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
                         char dirname[128];
                         int fd;
 #ifdef _WIN32
-                        GetTempPath(sizeof(dirname), dirname);
+                        GetTempPathA(sizeof(dirname), dirname);
                         sprintf(filename, "%s%s",dirname, emp->name);
                         if( (fd = open( filename , _O_CREAT | _O_WRONLY | _O_BINARY , 0666)) >= 0 )
 #else
-                            strcpy(dirname, "/tmp/");
+                        strcpy(dirname, "/tmp/");
                         sprintf(filename, "%s%s", dirname, emp->name);
                         if( (fd = open( filename , O_CREAT | O_WRONLY , 0666)) >= 0 )
 #endif
diff --git a/hwpfilter/source/mzstring.cxx b/hwpfilter/source/mzstring.cxx
index 6b579e47b8f6..dae04be2169b 100644
--- a/hwpfilter/source/mzstring.cxx
+++ b/hwpfilter/source/mzstring.cxx
@@ -34,7 +34,7 @@
 #include <string.h>
 
 #ifndef _WIN32
-# define wsprintf sprintf
+# define wsprintfA sprintf
 #endif
 
 const int AllocSize = 8;
@@ -181,7 +181,7 @@ MzString &MzString::operator << (int i)
 {
     char str[80];
 
-    wsprintf(str, "%d", i);
+    wsprintfA(str, "%d", i);
     append(str);
     return *this;
 }
@@ -191,7 +191,7 @@ MzString &MzString::operator << (long l)
 {
     char str[80];
 
-    wsprintf(str, "%ld", l);
+    wsprintfA(str, "%ld", l);
     append(str);
     return *this;
 }
diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx
index cbbd55b895a8..1ae892471ac3 100644
--- a/idlc/source/options.cxx
+++ b/idlc/source/options.cxx
@@ -192,7 +192,7 @@ OString convertIncPathtoShortWindowsPath(const OString& incPath) {
     std::vector<sal_Unicode> vec(path.getLength() + 1);
     //GetShortPathNameW only works if the file can be found!
     const DWORD len = GetShortPathNameW(
-        reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1);
+        SAL_W(path.getStr()), SAL_W(&vec[0]), path.getLength() + 1);
 
     if (len > 0)
     {
diff --git a/include/comphelper/windowserrorstring.hxx b/include/comphelper/windowserrorstring.hxx
index 805c491c37e1..59f27711a5f8 100644
--- a/include/comphelper/windowserrorstring.hxx
+++ b/include/comphelper/windowserrorstring.hxx
@@ -29,7 +29,7 @@ inline OUString WindowsErrorString(DWORD nErrorCode)
                        nullptr) == 0)
         return OUString::number(nErrorCode, 16);
 
-    OUString result(reinterpret_cast<sal_Unicode const *>(pMsgBuf));
+    OUString result(SAL_U(pMsgBuf));
     result.endsWith("\r\n", &result);
 
     LocalFree(pMsgBuf);
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 5d28e0240b58..7a9cefd78f34 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -485,8 +485,7 @@ static void load_msvcr(OUString const & jvm_dll, OUStringLiteral msvcr)
     }
 
     if (LoadLibraryW(
-            reinterpret_cast<wchar_t const *>(
-                OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr())))
+            SAL_W(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr())))
         return;
 
     // Then check if msvcr71.dll is in the parent folder of where
@@ -498,8 +497,7 @@ static void load_msvcr(OUString const & jvm_dll, OUStringLiteral msvcr)
         return;
 
     LoadLibraryW(
-        reinterpret_cast<wchar_t const *>(
-            OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr()));
+        SAL_W(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr()));
 }
 
 // Check if the jvm DLL imports msvcr71.dll, and in that case try
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index f1bf45816af6..7513716d4f90 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -631,7 +631,11 @@ bool getJavaInfoFromRegistry(const wchar_t* szRegKey,
                 // Find out how long the string for JavaHome is and allocate memory to hold the path
                 if( RegQueryValueExW(hKey, L"JavaHome", nullptr, &dwType, nullptr, &dwTmpPathLen)== ERROR_SUCCESS)
                 {
-                    unsigned char* szTmpPath= static_cast<unsigned char *>(malloc( dwTmpPathLen));
+                    unsigned char* szTmpPath= static_cast<unsigned char *>(malloc(dwTmpPathLen+sizeof(sal_Unicode)));
+                    // According to https://msdn.microsoft.com/en-us/ms724911, the application should ensure
+                    // that the string is properly terminated before using it
+                    for (DWORD i = 0; i < sizeof(sal_Unicode); ++i)
+                        szTmpPath[dwTmpPathLen + i] = 0;
                     // Get the path for the runtime lib
                     if(RegQueryValueExW(hKey, L"JavaHome", nullptr, &dwType, szTmpPath, &dwTmpPathLen) == ERROR_SUCCESS)
                     {
diff --git a/jvmfwk/source/fwkutil.cxx b/jvmfwk/source/fwkutil.cxx
index fbb885b1d0c2..95fa21503bc0 100644
--- a/jvmfwk/source/fwkutil.cxx
+++ b/jvmfwk/source/fwkutil.cxx
@@ -66,18 +66,19 @@ bool isAccessibilitySupportDesired()
 #ifdef _WIN32
     bool retVal = false;
     HKEY    hKey = nullptr;
-    if (RegOpenKeyEx(HKEY_CURRENT_USER,
-                     "Software\\LibreOffice\\Accessibility\\AtToolSupport",
-                     0, KEY_READ, &hKey) == ERROR_SUCCESS)
+    if (RegOpenKeyExA(HKEY_CURRENT_USER,
+                      "Software\\LibreOffice\\Accessibility\\AtToolSupport",
+                      0, KEY_READ, &hKey) == ERROR_SUCCESS)
     {
         DWORD   dwType = 0;
         DWORD   dwLen = 16;
         unsigned char arData[16];
-        if( RegQueryValueEx(hKey, "SupportAssistiveTechnology", nullptr, &dwType, arData,
-                            & dwLen)== ERROR_SUCCESS)
+        if( RegQueryValueExA(hKey, "SupportAssistiveTechnology", nullptr, &dwType, arData,
+                             &dwLen)== ERROR_SUCCESS)
         {
             if (dwType == REG_SZ)
             {
+                arData[std::min(dwLen, DWORD(15))] = 0;
                 if (strcmp(reinterpret_cast<char*>(arData), "true") == 0
                     || strcmp(reinterpret_cast<char*>(arData), "1") == 0)
                     retVal = true;
@@ -98,9 +99,8 @@ bool isAccessibilitySupportDesired()
                         "jfw", "bad registry value " << unsigned(arData[0]));
             }
         }
+        RegCloseKey(hKey);
     }
-    RegCloseKey(hKey);
-
 #elif defined UNX
     // Java is no longer required for a11y - we use atk directly.
     bool retVal = ::rtl::Bootstrap::get( "JFW_PLUGIN_FORCE_ACCESSIBILITY", sValue) && sValue == "1";
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index 73412e9fff58..71e6722f83dc 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -502,10 +502,10 @@ bool initOpenCLRunEnv( GPUEnv *gpuInfo )
     const bool bIsNotWinOrIsWin8OrGreater = IsWindows8OrGreater();
 # else
     bool bIsNotWinOrIsWin8OrGreater = true;
-    OSVERSIONINFO aVersionInfo;
+    OSVERSIONINFOW aVersionInfo;
     memset( &aVersionInfo, 0, sizeof(aVersionInfo) );
     aVersionInfo.dwOSVersionInfoSize = sizeof( aVersionInfo );
-    if (GetVersionEx( &aVersionInfo ))
+    if (GetVersionExW( &aVersionInfo ))
     {
         // Windows 7 or lower?
         if (aVersionInfo.dwMajorVersion < 6 ||
diff --git a/sal/osl/w32/security.cxx b/sal/osl/w32/security.cxx
index 02f9c02e82b6..b25e3076af70 100644
--- a/sal/osl/w32/security.cxx
+++ b/sal/osl/w32/security.cxx
@@ -66,7 +66,9 @@ typedef BOOL (STDMETHODCALLTYPE FAR * LPFNGETUSERPROFILEDIR) (
 #define TOKEN_DUP_QUERY (TOKEN_QUERY|TOKEN_DUPLICATE)
 
 static bool GetSpecialFolder(rtl_uString **strPath,int nFolder);
-static BOOL Privilege(LPCWSTR pszPrivilege, BOOL bEnable);
+// We use LPCTSTR here, because we use it with SE_foo_NAME constants
+// which are defined in winnt.h as UNICODE-dependent TEXT("PrivilegeName")
+static BOOL Privilege(LPCTSTR pszPrivilege, BOOL bEnable);
 static bool SAL_CALL getUserNameImpl(oslSecurity Security, rtl_uString **strName, bool bIncludeDomain);
 
 oslSecurity SAL_CALL osl_getCurrentSecurity(void)
@@ -99,7 +101,7 @@ oslSecurityError SAL_CALL osl_loginUser( rtl_uString *strUserName, rtl_uString *
     }
 
     // this process must have the right: 'act as a part of operatingsystem'
-    OSL_ASSERT(LookupPrivilegeValueW(nullptr, L"SeTcbPrivilege", &luid));
+    OSL_ASSERT(LookupPrivilegeValue(nullptr, SE_TCB_NAME, &luid));
     (void) luid;
 
     if (LogonUserW(SAL_W(strUser), strDomain ? SAL_W(strDomain) : L"", SAL_W(rtl_uString_getStr(strPasswd)),
@@ -510,7 +512,7 @@ sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security)
 
     RegCloseKey(HKEY_CURRENT_USER);
 
-    if (Privilege(L"SeRestorePrivilege", TRUE))
+    if (Privilege(SE_RESTORE_NAME, TRUE))
     {
         HMODULE                 hUserEnvLib         = nullptr;
         LPFNLOADUSERPROFILE     fLoadUserProfile    = nullptr;
@@ -712,7 +714,9 @@ static bool GetSpecialFolder(rtl_uString **strPath, int nFolder)
     return bRet;
 }
 
-static BOOL Privilege(LPCWSTR strPrivilege, BOOL bEnable)
+// We use LPCTSTR here, because we use it with SE_foo_NAME constants
+// which are defined in winnt.h as UNICODE-dependent TEXT("PrivilegeName")
+static BOOL Privilege(LPCTSTR strPrivilege, BOOL bEnable)
 {
     HANDLE           hToken;
     TOKEN_PRIVILEGES tp;
@@ -722,7 +726,7 @@ static BOOL Privilege(LPCWSTR strPrivilege, BOOL bEnable)
         return FALSE;
 
     // get the luid
-    if (!LookupPrivilegeValueW(nullptr, strPrivilege, &tp.Privileges[0].Luid))
+    if (!LookupPrivilegeValue(nullptr, strPrivilege, &tp.Privileges[0].Luid))
         return FALSE;
 
     tp.PrivilegeCount = 1;
diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx
index f384339f25f2..e670d62e4d7e 100644
--- a/sfx2/source/appl/shutdowniconw32.cxx
+++ b/sfx2/source/appl/shutdowniconw32.cxx
@@ -96,9 +96,9 @@ typedef struct tagMYITEM
 static void addMenuItem( HMENU hMenu, UINT id, UINT iconId, const OUString& text, int& pos, bool bOwnerdraw, const OUString& module )
 {
     MENUITEMINFOW mi;
-    memset( &mi, 0, sizeof( MENUITEMINFOW ) );
+    memset( &mi, 0, sizeof( mi ) );
 
-    mi.cbSize = sizeof( MENUITEMINFOW );
+    mi.cbSize = sizeof( mi );
     if( id == static_cast<UINT>( -1 ) )
     {
         mi.fMask=MIIM_TYPE;
@@ -326,7 +326,7 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
                     EnableMenuItem( popupMenu, IDM_TEMPLATE, MF_BYCOMMAND | (ShutdownIcon::bModalMode ? MF_GRAYED : MF_ENABLED) );
                     int m = TrackPopupMenuEx( popupMenu, TPM_RETURNCMD|TPM_LEFTALIGN|TPM_RIGHTBUTTON,
                                               pt.x, pt.y, hWnd, nullptr );
-                    BOOL const ret = PostMessage( hWnd, 0, 0, 0 );
+                    BOOL const ret = PostMessageW( hWnd, 0, 0, 0 );
                     SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!");
                     switch( m )
                     {
@@ -344,11 +344,11 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
                             break;
                         case IDM_EXIT:
                             // delete taskbar icon
-                            NOTIFYICONDATAA nid;
-                            nid.cbSize=sizeof(NOTIFYICONDATA);
+                            NOTIFYICONDATAW nid;
+                            nid.cbSize=sizeof(nid);
                             nid.hWnd = hWnd;
                             nid.uID = ID_QUICKSTART;
-                            Shell_NotifyIconA(NIM_DELETE, &nid);
+                            Shell_NotifyIconW(NIM_DELETE, &nid);
                             break;
                     }
 
@@ -372,11 +372,11 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
             else if ( uMsg == s_uMsgKillTray )
             {
                 // delete taskbar icon
-                NOTIFYICONDATAA nid;
-                nid.cbSize=sizeof(NOTIFYICONDATA);
+                NOTIFYICONDATAW nid;
+                nid.cbSize=sizeof(nid);
                 nid.hWnd = hWnd;
                 nid.uID = ID_QUICKSTART;
-                Shell_NotifyIconA(NIM_DELETE, &nid);
+                Shell_NotifyIconW(NIM_DELETE, &nid);
 
                 BOOL const ret = PostMessageW(aExecuterWindow, WM_COMMAND, IDM_EXIT, reinterpret_cast<LPARAM>(hWnd));
                 SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!");
@@ -628,7 +628,7 @@ void OnDrawItem(HWND /*hwnd*/, LPDRAWITEMSTRUCT lpdis)
         }
     }
 
-    hIcon = static_cast<HICON>(LoadImageA( hModule, MAKEINTRESOURCE( pMyItem->iconId ),
+    hIcon = static_cast<HICON>(LoadImageW( hModule, MAKEINTRESOURCEW( pMyItem->iconId ),
                                 IMAGE_ICON, cx, cy,
                                 LR_DEFAULTCOLOR | LR_SHARED ));
 
@@ -719,7 +719,7 @@ static HRESULT WINAPI SHCoCreateInstance( LPVOID lpszReserved, REFCLSID clsid, L
     {
         typedef HRESULT (WINAPI *SHCoCreateInstance_PROC)( LPVOID lpszReserved, REFCLSID clsid, LPUNKNOWN pUnkUnknwon, REFIID iid, LPVOID *ppv );
 
-        SHCoCreateInstance_PROC lpfnSHCoCreateInstance = reinterpret_cast<SHCoCreateInstance_PROC>(GetProcAddress( hModShell, MAKEINTRESOURCE(102) ));
+        SHCoCreateInstance_PROC lpfnSHCoCreateInstance = reinterpret_cast<SHCoCreateInstance_PROC>(GetProcAddress( hModShell, MAKEINTRESOURCEA(102) ));
 
         if ( lpfnSHCoCreateInstance )
             hResult = lpfnSHCoCreateInstance( lpszReserved, clsid, pUnkUnknown, iid, ppv );
diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx
index eb8ad7ffe736..02664519ee8a 100644
--- a/sfx2/source/doc/graphhelp.cxx
+++ b/sfx2/source/doc/graphhelp.cxx
@@ -88,7 +88,6 @@ void* GraphicHelper::getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta )
 
         OUString aMetaFile = aTempFile.GetFileName();
         OUString aMetaURL = aTempFile.GetURL();
-        OString aWinFile = OUStringToOString( aMetaFile, osl_getThreadTextEncoding() );
 
         SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMetaURL, StreamMode::STD_READWRITE );
         if ( pStream )
@@ -99,7 +98,7 @@ void* GraphicHelper::getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta )
             delete pStream;
 
             if ( !nFailed )
-                pResult = GetEnhMetaFileA( aWinFile.getStr() );
+                pResult = GetEnhMetaFileW( SAL_W(aMetaFile.getStr()) );
         }
     }
 #else
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 548ccd30d161..86a02dc5dd8f 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -1195,7 +1195,7 @@ OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir )
             if( SUCCEEDED(hRes) )
             {
                 OUString sTempINetFiles;
-                if( osl::FileBase::getFileURLFromSystemPath(reinterpret_cast<sal_Unicode*>(sPath), sTempINetFiles) == osl::FileBase::E_None )
+                if( osl::FileBase::getFileURLFromSystemPath(SAL_U(sPath), sTempINetFiles) == osl::FileBase::E_None )
                     bIsInTempPath = !sTempINetFiles.isEmpty() && sLocationURL.startsWith( sTempINetFiles );
             }
         }
diff --git a/sfx2/source/doc/syspathw32.cxx b/sfx2/source/doc/syspathw32.cxx
index c190a7e159bd..ea6e13c078ba 100644
--- a/sfx2/source/doc/syspathw32.cxx
+++ b/sfx2/source/doc/syspathw32.cxx
@@ -61,7 +61,7 @@ static bool SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize )
 bool GetUserTemplateLocation(sal_Unicode* pFolder, int nSize)
 {
 #ifdef _WIN32
-    return SHGetSpecialFolderW32( CSIDL_TEMPLATES, reinterpret_cast<LPWSTR>(pFolder), nSize );
+    return SHGetSpecialFolderW32( CSIDL_TEMPLATES, SAL_W(pFolder), nSize );
 #else
     (void)pFolder;
     (void)nSize;
diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx
index 8c2d18e0ac87..83840fb8de5a 100644
--- a/svl/source/crypto/cryptosign.cxx
+++ b/svl/source/crypto/cryptosign.cxx
@@ -762,7 +762,7 @@ bool CreateSigningCertificateAttribute(void const * pDerEncoded, int nDerEncoded
     std::vector<unsigned char> aSHA256{0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01};
 
     HCRYPTPROV hProv = 0;
-    if (!CryptAcquireContext(&hProv, nullptr, nullptr, PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
+    if (!CryptAcquireContextW(&hProv, nullptr, nullptr, PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
     {
         SAL_WARN("svl.crypto", "CryptAcquireContext() failed");
         return false;
@@ -1867,7 +1867,7 @@ bad_data:
 bool VerifyNonDetachedSignature(const std::vector<unsigned char>& aData, const std::vector<BYTE>& rExpectedHash)
 {
     HCRYPTPROV hProv = 0;
-    if (!CryptAcquireContext(&hProv, nullptr, nullptr, PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
+    if (!CryptAcquireContextW(&hProv, nullptr, nullptr, PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
     {
         SAL_WARN("svl.crypto", "CryptAcquireContext() failed");
         return false;
@@ -1941,14 +1941,13 @@ OUString GetSubjectName(PCCERT_CONTEXT pCertContext)
                             szName,
                             dwData))
     {
+        LocalFree(szName);
         SAL_WARN("svl.crypto", "ValidateSignature: CertGetNameString failed");
         return subjectName;
     }
 
-    subjectName = OUString(reinterpret_cast<sal_Unicode*>(szName));
-
-    if (szName != nullptr)
-        LocalFree(szName);
+    subjectName = SAL_U(szName);
+    LocalFree(szName);
 
     return subjectName;
 }
diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx
index 3c629b1b9cba..c0c5373573e2 100644
--- a/tools/source/stream/strmwnt.cxx
+++ b/tools/source/stream/strmwnt.cxx
@@ -276,7 +276,6 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode )
     m_eStreamMode &= ~StreamMode::TRUNC; // don't truncate on reopen
 
     aFilename = aParsedFilename;
-    OString aFileNameA(OUStringToOString(aFilename, osl_getThreadTextEncoding()));
     SetLastError( ERROR_SUCCESS );  // might be changed by Redirector
 
     DWORD   nOpenAction;
@@ -317,8 +316,8 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode )
             nOpenAction = OPEN_EXISTING;
     }
 
-    pInstanceData->hFile = CreateFile(
-        aFileNameA.getStr(),
+    pInstanceData->hFile = CreateFileW(
+        SAL_W(aFilename.getStr()),
         nAccessMode,
         nShareMode,
         nullptr,
@@ -351,8 +350,8 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode )
             // if Openaction is CREATE_ALWAYS
             nOpenAction = OPEN_EXISTING;
             SetLastError( ERROR_SUCCESS );
-            pInstanceData->hFile = CreateFile(
-                aFileNameA.getStr(),
+            pInstanceData->hFile = CreateFileW(
+                SAL_W(aFilename.getStr()),
                 GENERIC_READ,
                 nShareMode,
                 nullptr,
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 5b0e638c3c00..0f3e05b8f31a 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -196,8 +196,8 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 );
 #define SAL_TMPSUBFRAME_CLASSNAMEW  L"SALTMPSUBFRAME"
 #define SAL_OBJECT_WNDEXTRA         sizeof( DWORD )
 #define SAL_OBJECT_THIS             GWLP_USERDATA
-#define SAL_OBJECT_CLASSNAMEA       "SALOBJECT"
-#define SAL_OBJECT_CHILDCLASSNAMEA  "SALOBJECTCHILD"
+#define SAL_OBJECT_CLASSNAMEW       L"SALOBJECT"
+#define SAL_OBJECT_CHILDCLASSNAMEW  L"SALOBJECTCHILD"
 #define SAL_COM_CLASSNAMEW          L"SALCOMWND"
 
 #define SAL_MOUSELEAVE_TIMEOUT      300
@@ -273,7 +273,7 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 );
 
 inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis )
 {
-    SetWindowLongPtr( hWnd, SAL_FRAME_THIS, reinterpret_cast<LONG_PTR>(pThis) );
+    SetWindowLongPtrW( hWnd, SAL_FRAME_THIS, reinterpret_cast<LONG_PTR>(pThis) );
 }
 
 inline WinSalFrame* GetWindowPtr( HWND hWnd )
@@ -283,12 +283,12 @@ inline WinSalFrame* GetWindowPtr( HWND hWnd )
 
 inline void SetSalObjWindowPtr( HWND hWnd, WinSalObject* pThis )
 {
-    SetWindowLongPtr( hWnd, SAL_OBJECT_THIS, reinterpret_cast<LONG_PTR>(pThis) );
+    SetWindowLongPtrW( hWnd, SAL_OBJECT_THIS, reinterpret_cast<LONG_PTR>(pThis) );
 }
 
 inline WinSalObject* GetSalObjWindowPtr( HWND hWnd )
 {
-    return reinterpret_cast<WinSalObject*>(GetWindowLongPtr( hWnd, SAL_OBJECT_THIS ));
+    return reinterpret_cast<WinSalObject*>(GetWindowLongPtrW( hWnd, SAL_OBJECT_THIS ));
 }
 
 #endif // INCLUDED_VCL_INC_WIN_SALDATA_HXX
diff --git a/vcl/inc/win/wincomp.hxx b/vcl/inc/win/wincomp.hxx
index 8fd774fc6eb1..4a436fbd309d 100644
--- a/vcl/inc/win/wincomp.hxx
+++ b/vcl/inc/win/wincomp.hxx
@@ -97,22 +97,22 @@ inline void DeletePalette( HPALETTE hPalette )
 
 inline void SetWindowStyle( HWND hWnd, DWORD nStyle )
 {
-    SetWindowLong( hWnd, GWL_STYLE, nStyle );
+    SetWindowLongPtrW( hWnd, GWL_STYLE, nStyle );
 }
 
 inline DWORD GetWindowStyle( HWND hWnd )
 {
-    return GetWindowLong( hWnd, GWL_STYLE );
+    return GetWindowLongPtrW( hWnd, GWL_STYLE );
 }
 
 inline void SetWindowExStyle( HWND hWnd, DWORD nStyle )
 {
-    SetWindowLong( hWnd, GWL_EXSTYLE, nStyle );
+    SetWindowLongPtrW( hWnd, GWL_EXSTYLE, nStyle );
 }
 
 inline DWORD GetWindowExStyle( HWND hWnd )
 {
-    return GetWindowLong( hWnd, GWL_EXSTYLE );
+    return GetWindowLongPtrW( hWnd, GWL_EXSTYLE );
 }
 
 inline BOOL IsMinimized( HWND hWnd )
@@ -127,12 +127,12 @@ inline BOOL IsMaximized( HWND hWnd )
 
 inline void SetWindowFont( HWND hWnd, HFONT hFont, BOOL bRedraw )
 {
-    SendMessage( hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), MAKELPARAM((UINT)bRedraw,0) );
+    SendMessageW( hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), MAKELPARAM((UINT)bRedraw,0) );
 }
 
 inline HFONT GetWindowFont( HWND hWnd )
 {
-    return reinterpret_cast<HFONT>(SendMessage( hWnd, WM_GETFONT, 0, 0 ));
+    return reinterpret_cast<HFONT>(SendMessageW( hWnd, WM_GETFONT, 0, 0 ));
 }
 
 inline void SetClassCursor( HWND hWnd, HCURSOR hCursor )
@@ -167,17 +167,17 @@ inline HBRUSH GetClassBrush( HWND hWnd )
 
 inline HINSTANCE GetWindowInstance( HWND hWnd )
 {
-    return reinterpret_cast<HINSTANCE>(GetWindowLongPtr( hWnd, GWLP_HINSTANCE ));
+    return reinterpret_cast<HINSTANCE>(GetWindowLongPtrW( hWnd, GWLP_HINSTANCE ));
 }
 
 
-#define MOUSEZ_CLASSNAME  "MouseZ"            // wheel window class
-#define MOUSEZ_TITLE      "Magellan MSWHEEL"  // wheel window title
+#define MOUSEZ_CLASSNAME  L"MouseZ"            // wheel window class
+#define MOUSEZ_TITLE      L"Magellan MSWHEEL"  // wheel window title
 
 #define MSH_WHEELMODULE_CLASS (MOUSEZ_CLASSNAME)
 #define MSH_WHEELMODULE_TITLE (MOUSEZ_TITLE)
 
-#define MSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG"
+#define MSH_SCROLL_LINES L"MSH_SCROLL_LINES_MSG"
 
 #ifndef WHEEL_DELTA
 #define WHEEL_DELTA                 120
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index d81c37283983..0d2a0c0a8f0c 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -183,7 +183,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
     case WM_DESTROY:
         return 0;
     default:
-        return DefWindowProc(hwnd, message, wParam, lParam);
+        return DefWindowProcW(hwnd, message, wParam, lParam);
     }
 }
 
@@ -193,7 +193,7 @@ bool InitTempWindow(HWND& hwnd, int width, int height, const PIXELFORMATDESCRIPT
 
     PIXELFORMATDESCRIPTOR  pfd = inPfd;
     int ret;
-    WNDCLASS wc;
+    WNDCLASSW wc;
     wc.style = 0;
     wc.lpfnWndProc = WndProc;
     wc.cbClsExtra = wc.cbWndExtra = 0;
@@ -202,9 +202,9 @@ bool InitTempWindow(HWND& hwnd, int width, int height, const PIXELFORMATDESCRIPT
     wc.hCursor = nullptr;
     wc.hbrBackground = nullptr;
     wc.lpszMenuName = nullptr;
-    wc.lpszClassName = "GLRenderer";
-    RegisterClass(&wc);
-    hwnd = CreateWindow(wc.lpszClassName, nullptr, WS_DISABLED, 0, 0, width, height, nullptr, nullptr, wc.hInstance, nullptr);
+    wc.lpszClassName = L"GLRenderer";
+    RegisterClassW(&wc);
+    hwnd = CreateWindowW(wc.lpszClassName, nullptr, WS_DISABLED, 0, 0, width, height, nullptr, nullptr, wc.hInstance, nullptr);
     glWin.hDC = GetDC(hwnd);
 
     int nPixelFormat = ChoosePixelFormat(glWin.hDC, &pfd);
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 95b3a2a2de22..ebf5cb50104c 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2445,21 +2445,21 @@ bool MiscSettings::GetEnableATToolSupport() const
         // be activated ..
         HKEY hkey;
 
-        if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,
-            "Software\\LibreOffice\\Accessibility\\AtToolSupport",
+        if( ERROR_SUCCESS == RegOpenKeyW(HKEY_CURRENT_USER,
+            L"Software\\LibreOffice\\Accessibility\\AtToolSupport",
             &hkey) )
         {
             DWORD dwType;
-            sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD
+            wchar_t Data[6]; // possible values: "true", "false", "1", "0", DWORD
             DWORD cbData = sizeof(Data);
 
-            if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology",
-                nullptr, &dwType, Data, &cbData) )
+            if( ERROR_SUCCESS == RegQueryValueExW(hkey, L"SupportAssistiveTechnology",
+                nullptr, &dwType, reinterpret_cast<LPBYTE>(Data), &cbData) )
             {
                 switch (dwType)
                 {
                     case REG_SZ:
-                        mxData->mnEnableATT = ((0 == stricmp(reinterpret_cast<const char *>(Data), "1")) || (0 == stricmp(reinterpret_cast<const char *>(Data), "true"))) ? TRISTATE_TRUE : TRISTATE_FALSE;
+                        mxData->mnEnableATT = ((0 == wcsicmp(Data, L"1")) || (0 == wcsicmp(Data, L"true"))) ? TRISTATE_TRUE : TRISTATE_FALSE;
                         break;
                     case REG_DWORD:
                         switch (reinterpret_cast<DWORD *>(Data)[0]) {
@@ -2517,29 +2517,29 @@ void MiscSettings::SetEnableATToolSupport( bool bEnable )
         HKEY hkey;
 
         // If the accessibility key in the Windows registry exists, change it synchronously
-        if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,
-            "Software\\LibreOffice\\Accessibility\\AtToolSupport",
+        if( ERROR_SUCCESS == RegOpenKeyW(HKEY_CURRENT_USER,
+            L"Software\\LibreOffice\\Accessibility\\AtToolSupport",
             &hkey) )
         {
             DWORD dwType;
-            sal_uInt8 Data[6]; // possible values: "true", "false", 1, 0
+            wchar_t Data[6]; // possible values: "true", "false", 1, 0
             DWORD cbData = sizeof(Data);
 
-            if( ERROR_SUCCESS == RegQueryValueEx(hkey, "SupportAssistiveTechnology",
-                nullptr,   &dwType, Data, &cbData) )
+            if( ERROR_SUCCESS == RegQueryValueExW(hkey, L"SupportAssistiveTechnology",
+                nullptr,   &dwType, reinterpret_cast<LPBYTE>(Data), &cbData) )
             {
                 switch (dwType)
                 {
                     case REG_SZ:
-                        RegSetValueEx(hkey, "SupportAssistiveTechnology",
+                        RegSetValueExW(hkey, L"SupportAssistiveTechnology",
                             0, dwType,
-                            reinterpret_cast<sal_uInt8 const *>(bEnable ? "true" : "false"),
-                            bEnable ? sizeof("true") : sizeof("false"));
+                            reinterpret_cast<const BYTE*>(bEnable ? L"true" : L"false"),
+                            bEnable ? sizeof(L"true") : sizeof(L"false"));
                         break;
                     case REG_DWORD:
                         reinterpret_cast<DWORD *>(Data)[0] = bEnable ? 1 : 0;
-                        RegSetValueEx(hkey, "SupportAssistiveTechnology",
-                            0, dwType, Data, sizeof(DWORD));
+                        RegSetValueExW(hkey, L"SupportAssistiveTechnology",
+                            0, dwType, reinterpret_cast<const BYTE*>(Data), sizeof(DWORD));
                         break;
                     default:
                         // Unsupported registry type
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 70d031d4ee69..45099edbefe0 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -5130,19 +5130,19 @@ void ToolBox::ImplDisableFlatButtons()
         bInit = true;
         HKEY hkey;
 
-        if( ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, "Software\\LibreOffice\\Accessibility\\AtToolSupport", &hkey) )
+        if( ERROR_SUCCESS == RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\LibreOffice\\Accessibility\\AtToolSupport", &hkey) )
         {
             DWORD dwType = 0;
-            sal_uInt8 Data[6]; // possible values: "true", "false", "1", "0", DWORD
+            wchar_t Data[6]; // possible values: "true", "false", "1", "0", DWORD
             DWORD cbData = sizeof(Data);
 
-            if( ERROR_SUCCESS == RegQueryValueEx(hkey, "DisableFlatToolboxButtons",
-                nullptr, &dwType, Data, &cbData) )
+            if( ERROR_SUCCESS == RegQueryValueExW(hkey, L"DisableFlatToolboxButtons",
+                nullptr, &dwType, reinterpret_cast<LPBYTE>(Data), &cbData) )
             {
                 switch (dwType)
                 {
                     case REG_SZ:
-                        bValue = ((0 == stricmp(reinterpret_cast<const char *>(Data), "1")) || (0 == stricmp(reinterpret_cast<const char *>(Data), "true")));
+                        bValue = ((0 == wcsicmp(Data, L"1")) || (0 == wcsicmp(Data, L"true")));
                         break;
                     case REG_DWORD:
                         bValue = (bool)(reinterpret_cast<DWORD *>(Data)[0]);
diff --git a/vcl/win/app/salinfo.cxx b/vcl/win/app/salinfo.cxx
index 815582c8e2a5..c96f80862b53 100644
--- a/vcl/win/app/salinfo.cxx
+++ b/vcl/win/app/salinfo.cxx
@@ -59,7 +59,7 @@ bool WinSalSystem::handleMonitorCallback( sal_IntPtr hMonitor, sal_IntPtr, sal_I
     if( GetMonitorInfoW( reinterpret_cast<HMONITOR>(hMonitor), &aInfo ) )
     {
         aInfo.szDevice[CCHDEVICENAME-1] = 0;
-        OUString aDeviceName( reinterpret_cast<const sal_Unicode *>(aInfo.szDevice) );
+        OUString aDeviceName( SAL_U(aInfo.szDevice) );
         std::map< OUString, unsigned int >::const_iterator it =
             m_aDeviceNameToMonitor.find( aDeviceName );
         if( it != m_aDeviceNameToMonitor.end() )
@@ -110,8 +110,8 @@ bool WinSalSystem::initMonitors()
             {
                 aDev.DeviceName[31] = 0;
                 aDev.DeviceString[127] = 0;
-                OUString aDeviceName( reinterpret_cast<const sal_Unicode *>(aDev.DeviceName) );
-                OUString aDeviceString( reinterpret_cast<const sal_Unicode *>(aDev.DeviceString) );
+                OUString aDeviceName( SAL_U(aDev.DeviceName) );
+                OUString aDeviceString( SAL_U(aDev.DeviceString) );
                 if( aDeviceStringCount.find( aDeviceString ) == aDeviceStringCount.end() )
                     aDeviceStringCount[ aDeviceString ] = 1;
                 else
@@ -169,8 +169,8 @@ int WinSalSystem::ShowNativeMessageBox(const OUString& rTitle, const OUString& r
     ImplHideSplash();
     return MessageBoxW(
         nullptr,
-        reinterpret_cast<LPCWSTR>(rMessage.getStr()),
-        reinterpret_cast<LPCWSTR>(rTitle.getStr()),
+        SAL_W(rMessage.getStr()),
+        SAL_W(rTitle.getStr()),
         MB_TASKMODAL | MB_SETFOREGROUND | MB_ICONWARNING | MB_DEFBUTTON1);
 }
 
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 437e8b594c65..faa5bd3776e4 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -88,7 +88,7 @@ void SalAbort( const OUString& rErrorText, bool )
         CrashReporter::AddKeyValue("AbortMessage", rErrorText);
         // make sure crash reporter is triggered
         RaiseException( 0, EXCEPTION_NONCONTINUABLE, 0, nullptr );
-        FatalAppExitW( 0, reinterpret_cast<LPCWSTR>(rErrorText.getStr()) );
+        FatalAppExitW( 0, SAL_W(rErrorText.getStr()) );
     }
 }
 
@@ -228,27 +228,27 @@ void SalData::initKeyCodeMap()
 {
     UINT nKey;
     #define initKey( a, b )\
-        nKey = LOWORD( VkKeyScan( a ) );\
+        nKey = LOWORD( VkKeyScanW( a ) );\
         if( nKey < 0xffff )\
             maVKMap[ nKey ] = b;
 
     maVKMap.clear();
 
-    initKey( '+', KEY_ADD );
-    initKey( '-', KEY_SUBTRACT );
-    initKey( '*', KEY_MULTIPLY );
-    initKey( '/', KEY_DIVIDE );
-    initKey( '.', KEY_POINT );
-    initKey( ',', KEY_COMMA );
-    initKey( '<', KEY_LESS );
-    initKey( '>', KEY_GREATER );
-    initKey( '=', KEY_EQUAL );
-    initKey( '~', KEY_TILDE );
-    initKey( '`', KEY_QUOTELEFT );
-    initKey( '[', KEY_BRACKETLEFT );
-    initKey( ']', KEY_BRACKETRIGHT );
-    initKey( ';', KEY_SEMICOLON );
-    initKey( '\'', KEY_QUOTERIGHT );
+    initKey( L'+', KEY_ADD );
+    initKey( L'-', KEY_SUBTRACT );
+    initKey( L'*', KEY_MULTIPLY );
+    initKey( L'/', KEY_DIVIDE );
+    initKey( L'.', KEY_POINT );
+    initKey( L',', KEY_COMMA );
+    initKey( L'<', KEY_LESS );
+    initKey( L'>', KEY_GREATER );
+    initKey( L'=', KEY_EQUAL );
+    initKey( L'~', KEY_TILDE );
+    initKey( L'`', KEY_QUOTELEFT );
+    initKey( L'[', KEY_BRACKETLEFT );
+    initKey( L']', KEY_BRACKETRIGHT );
+    initKey( L';', KEY_SEMICOLON );
+    initKey( L'\'', KEY_QUOTERIGHT );
 }
 
 // SalData
@@ -344,11 +344,11 @@ void InitSalMain()
     SalData* pData = GetSalData();
     if ( pData )    // Im AppServer NULL
     {
-        STARTUPINFO aSI;
+        STARTUPINFOW aSI;
         aSI.cb = sizeof( aSI );
-        GetStartupInfo( &aSI );
-        pData->mhInst                   = GetModuleHandle( nullptr );
-        pData->mnCmdShow                = aSI.wShowWindow;
+        GetStartupInfoW( &aSI );
+        pData->mhInst    = GetModuleHandleW( nullptr );
+        pData->mnCmdShow = aSI.wShowWindow;
     }
 }
 
diff --git a/vcl/win/app/salshl.cxx b/vcl/win/app/salshl.cxx
index 5fd1959b228d..1cd38e05abeb 100644
--- a/vcl/win/app/salshl.cxx
+++ b/vcl/win/app/salshl.cxx
@@ -33,7 +33,7 @@ HCURSOR ImplLoadSalCursor( int nId )
 {
     SAL_WARN_IF( !aSalShlData.mhInst, "vcl", "no DLL instance handle" );
 
-    HCURSOR hCursor = LoadCursor( aSalShlData.mhInst, MAKEINTRESOURCE( nId ) );
+    HCURSOR hCursor = LoadCursorW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ) );
 
     SAL_WARN_IF( !hCursor, "vcl", "cursor not found in sal resource" );
 
@@ -44,7 +44,7 @@ HBITMAP ImplLoadSalBitmap( int nId )
 {
     SAL_WARN_IF( !aSalShlData.mhInst, "vcl", "no DLL instance handle" );
 
-    HBITMAP hBitmap = LoadBitmap( aSalShlData.mhInst, MAKEINTRESOURCE( nId ) );
+    HBITMAP hBitmap = LoadBitmapW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ) );
 
     SAL_WARN_IF( !hBitmap, "vcl", "bitmap not found in sal resource" );
 
@@ -72,19 +72,19 @@ bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon )
     }
 
     // Try at first to load the icons from the application exe file
-    rIcon = static_cast<HICON>(LoadImage( pSalData->mhInst, MAKEINTRESOURCE( nId ),
+    rIcon = static_cast<HICON>(LoadImageW( pSalData->mhInst, MAKEINTRESOURCEW( nId ),
                                            IMAGE_ICON, GetSystemMetrics( SM_CXICON ), GetSystemMetrics( SM_CYICON ),
                                            LR_DEFAULTCOLOR ));
     if ( !rIcon )
     {
         // If the application don't provide these icons, then we try
         // to load the icon from the VCL resource
-        rIcon = static_cast<HICON>(LoadImage( aSalShlData.mhInst, MAKEINTRESOURCE( nId ),
+        rIcon = static_cast<HICON>(LoadImageW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ),
                                            IMAGE_ICON, GetSystemMetrics( SM_CXICON ), GetSystemMetrics( SM_CYICON ),
                                            LR_DEFAULTCOLOR ));
         if ( rIcon )
         {
-            rSmallIcon = static_cast<HICON>(LoadImage( aSalShlData.mhInst, MAKEINTRESOURCE( nId ),
+            rSmallIcon = static_cast<HICON>(LoadImageW( aSalShlData.mhInst, MAKEINTRESOURCEW( nId ),
                                            IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
                                            LR_DEFAULTCOLOR ));
         }
@@ -93,7 +93,7 @@ bool ImplLoadSalIcon( int nId, HICON& rIcon, HICON& rSmallIcon )
     }
     else
     {
-        rSmallIcon = static_cast<HICON>(LoadImage( pSalData->mhInst, MAKEINTRESOURCE( nId ),
+        rSmallIcon = static_cast<HICON>(LoadImageW( pSalData->mhInst, MAKEINTRESOURCEW( nId ),
                                        IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
                                        LR_DEFAULTCOLOR ));
     }
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx
index e16381040e4a..bd9c012d55fc 100755
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -37,8 +37,8 @@ D2DWriteTextOutRenderer::pDWriteCreateFactory_t D2DWriteTextOutRenderer::DWriteC
 
 bool D2DWriteTextOutRenderer::InitModules()
 {
-    mmD2d1 = LoadLibrary("D2d1.dll");
-    mmDWrite = LoadLibrary("dwrite.dll");
+    mmD2d1 = LoadLibraryW(L"D2d1.dll");
+    mmDWrite = LoadLibraryW(L"dwrite.dll");
     if (mmD2d1 && mmDWrite)
     {
         D2D1CreateFactory = pD2D1CreateFactory_t(GetProcAddress(mmD2d1, "D2D1CreateFactory"));
@@ -75,7 +75,7 @@ D2DTextAntiAliasMode lclGetSystemTextAntiAliasMode()
     D2DTextAntiAliasMode eMode = D2DTextAntiAliasMode::Default;
 
     BOOL bFontSmoothing;
-    if (!SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &bFontSmoothing, 0))
+    if (!SystemParametersInfoW(SPI_GETFONTSMOOTHING, 0, &bFontSmoothing, 0))
         return eMode;
 
     if (bFontSmoothing)
@@ -83,7 +83,7 @@ D2DTextAntiAliasMode lclGetSystemTextAntiAliasMode()
         eMode = D2DTextAntiAliasMode::AntiAliased;
 
         UINT nType;
-        if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &nType, 0) && nType == FE_FONTSMOOTHINGCLEARTYPE)
+        if (SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE, 0, &nType, 0) && nType == FE_FONTSMOOTHINGCLEARTYPE)
             eMode = D2DTextAntiAliasMode::ClearType;
     }
     else
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index fb8fb10d8055..f4d2a578ae64 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -515,7 +515,7 @@ bool WinSalBitmap::Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle )
     {
         BITMAP  aDDBInfo;
 
-        if( GetObjectA( mhDDB, sizeof( BITMAP ), &aDDBInfo ) )
+        if( GetObjectW( mhDDB, sizeof( aDDBInfo ), &aDDBInfo ) )
         {
             maSize = Size( aDDBInfo.bmWidth, aDDBInfo.bmHeight );
             mnBitCount = aDDBInfo.bmPlanes * aDDBInfo.bmBitsPixel;
@@ -610,7 +610,7 @@ bool WinSalBitmap::Create( const SalBitmap& rSSalBmp, SalGraphics* pSGraphics )
 
         GlobalUnlock( rSalBmp.mhDIB );
 
-        if( hNewDDB && GetObjectA( hNewDDB, sizeof( BITMAP ), &aDDBInfo ) )
+        if( hNewDDB && GetObjectW( hNewDDB, sizeof( aDDBInfo ), &aDDBInfo ) )
         {
             mhDDB = hNewDDB;
             maSize = Size( aDDBInfo.bmWidth, aDDBInfo.bmHeight );
@@ -797,7 +797,7 @@ HANDLE WinSalBitmap::ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB )
         BITMAP aBmp;
 
         // find out size of source bitmap
-        GetObjectA( hHdl, sizeof( BITMAP ), &aBmp );
+        GetObjectW( hHdl, sizeof( aBmp ), &aBmp );
 
         // create destination bitmap
         if ( (hCopy = CreateBitmapIndirect( &aBmp )) != nullptr )
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index f46ace4070a5..70ad1e908152 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -527,7 +527,7 @@ static FontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rEnumFont
     aDFA.SetSymbolFlag(rLogFont.lfCharSet == SYMBOL_CHARSET);
 
     // get the font face name
-    aDFA.SetFamilyName(OUString(reinterpret_cast<const sal_Unicode*>(rLogFont.lfFaceName)));
+    aDFA.SetFamilyName(SAL_U(rLogFont.lfFaceName));
 
     // use the face's style name only if it looks reasonable
     const wchar_t* pStyleName = rEnumFont.elfStyle;
@@ -537,7 +537,7 @@ static FontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rEnumFont
         if( *p < 0x0020 )
             break;
     if( p < pEnd )
-        aDFA.SetStyleName(OUString(reinterpret_cast<const sal_Unicode*>(pStyleName)));
+        aDFA.SetStyleName(SAL_U(pStyleName));
 
     // heuristics for font quality
     // -   opentypeTT > truetype
@@ -571,7 +571,7 @@ static WinFontFace* ImplLogMetricToDevFontDataW( const ENUMLOGFONTEXW* pLogFont,
 
 void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont )
 {
-    OUString aFontName( reinterpret_cast<const sal_Unicode*>(rLogFont.lfFaceName) );
+    OUString aFontName( SAL_U(rLogFont.lfFaceName) );
     if (!aFontName.isEmpty())
     {
         rFont.SetFamilyName( aFontName );
@@ -944,8 +944,8 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa
     HFONT hOldFont = SelectFont( getHDC(), mhFonts[nFallbackLevel] );
 
     wchar_t aFaceName[LF_FACESIZE+60];
-    if( ::GetTextFaceW( getHDC(), sizeof(aFaceName)/sizeof(wchar_t), aFaceName ) )
-        rxFontMetric->SetFamilyName(OUString(reinterpret_cast<const sal_Unicode*>(aFaceName)));
+    if( GetTextFaceW( getHDC(), SAL_N_ELEMENTS(aFaceName), aFaceName ) )
+        rxFontMetric->SetFamilyName(SAL_U(aFaceName));
 
     const DWORD nHheaTag = CalcTag("hhea");
     const DWORD nOS2Tag = CalcTag("OS/2");
@@ -964,7 +964,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa
 
     // get the font metric
     OUTLINETEXTMETRICW aOutlineMetric;
-    const bool bOK = GetOutlineTextMetricsW(getHDC(), sizeof(OUTLINETEXTMETRICW), &aOutlineMetric);
+    const bool bOK = GetOutlineTextMetricsW(getHDC(), sizeof(aOutlineMetric), &aOutlineMetric);
     // restore the HDC to the font in the base level
     SelectFont( getHDC(), hOldFont );
     if( !bOK )
@@ -1019,7 +1019,7 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe,
         // Ignore vertical fonts
         if ( pLogFont->elfLogFont.lfFaceName[0] != '@' )
         {
-            OUString aName = OUString(reinterpret_cast<const sal_Unicode*>(pLogFont->elfLogFont.lfFaceName));
+            OUString aName = SAL_U(pLogFont->elfLogFont.lfFaceName);
             pInfo->mpName = &aName;
             memcpy(pInfo->mpLogFont->lfFaceName, pLogFont->elfLogFont.lfFaceName, (aName.getLength()+1)*sizeof(wchar_t));
             pInfo->mpLogFont->lfCharSet = pLogFont->elfLogFont.lfCharSet;
@@ -1062,7 +1062,7 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe,
 struct TempFontItem
 {
     OUString maFontFilePath;
-    OString maResourcePath;
+    OUString maResourcePath;
     TempFontItem* mpNextItem;
 };
 
@@ -1072,35 +1072,33 @@ bool ImplAddTempFont( SalData& rSalData, const OUString& rFontFileURL )
     OUString aUSytemPath;
     OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, aUSytemPath ) );
 
-    nRet = AddFontResourceExW( reinterpret_cast<LPCWSTR>(aUSytemPath.getStr()), FR_PRIVATE, nullptr );
+    nRet = AddFontResourceExW( SAL_W(aUSytemPath.getStr()), FR_PRIVATE, nullptr );
 
     if ( !nRet )
     {
         static int nCounter = 0;
-        char aFileName[] = "soAA.fot";
-        aFileName[2] = sal::static_int_cast<char>('A' + (15 & (nCounter>>4)));
-        aFileName[3] = sal::static_int_cast<char>('A' + (15 & nCounter));
-        char aResourceName[512];
-        int const nMaxLen = sizeof(aResourceName)/sizeof(*aResourceName) - 16;
-        int nLen = ::GetTempPathA( nMaxLen, aResourceName );
-        ::strncpy( aResourceName + nLen, aFileName, sizeof( aResourceName )- nLen );
+        wchar_t aFileName[] = L"soAA.fot";
+        aFileName[2] = sal::static_int_cast<wchar_t>(L'A' + (15 & (nCounter>>4)));
+        aFileName[3] = sal::static_int_cast<wchar_t>(L'A' + (15 & nCounter));
+        wchar_t aResourceName[512];
+        int const nMaxLen = SAL_N_ELEMENTS(aResourceName) - 16;
+        int nLen = GetTempPathW( nMaxLen, aResourceName );
+        wcsncpy( aResourceName + nLen, aFileName, SAL_N_ELEMENTS( aResourceName ) - nLen );
         // security: end buffer in any case
-        aResourceName[ (sizeof(aResourceName)/sizeof(*aResourceName))-1 ] = 0;
-        ::DeleteFileA( aResourceName );
+        aResourceName[ SAL_N_ELEMENTS(aResourceName)-1 ] = 0;
+        DeleteFileW( aResourceName );
 
-        rtl_TextEncoding theEncoding = osl_getThreadTextEncoding();
-        OString aCFileName = OUStringToOString( aUSytemPath, theEncoding );
         // TODO: font should be private => need to investigate why it doesn't work then
-        if( !::CreateScalableFontResourceA( 0, aResourceName, aCFileName.getStr(), nullptr ) )
+        if( !CreateScalableFontResourceW( 0, aResourceName, SAL_W(aUSytemPath.getStr()), nullptr ) )
             return false;
         ++nCounter;
 
-        nRet = ::AddFontResourceA( aResourceName );
+        nRet = AddFontResourceW( aResourceName );
         if( nRet > 0 )
         {
             TempFontItem* pNewItem = new TempFontItem;
-            pNewItem->maResourcePath = OString( aResourceName );
-            pNewItem->maFontFilePath = aUSytemPath.getStr();
+            pNewItem->maResourcePath = SAL_U( aResourceName );
+            pNewItem->maFontFilePath = aUSytemPath;
             pNewItem->mpNextItem = rSalData.mpTempFontItem;
             rSalData.mpTempFontItem = pNewItem;
         }
@@ -1117,13 +1115,13 @@ void ImplReleaseTempFonts( SalData& rSalData )
         ++nCount;
         if( p->maResourcePath.getLength() )
         {
-            const char* pResourcePath = p->maResourcePath.getStr();
-            ::RemoveFontResourceA( pResourcePath );
-            ::DeleteFileA( pResourcePath );
+            const wchar_t* pResourcePath = SAL_W(p->maResourcePath.getStr());
+            RemoveFontResourceW( pResourcePath );
+            DeleteFileW( pResourcePath );
         }
         else
         {
-            ::RemoveFontResourceW( reinterpret_cast<LPCWSTR>(p->maFontFilePath.getStr()) );
+            RemoveFontResourceW( SAL_W(p->maFontFilePath.getStr()) );
         }
 
         rSalData.mpTempFontItem = p->mpNextItem;
@@ -1147,19 +1145,17 @@ static bool ImplGetFontAttrFromFile( const OUString& rFontFileURL,
     rDFA.SetPitch(PITCH_DONTKNOW);
 
     // Create temporary file name
-    char aResourceName[512];
-    int nMaxLen = sizeof(aResourceName)/sizeof(*aResourceName) - 16;
-    int nLen = ::GetTempPathA( nMaxLen, aResourceName );
-    ::strncpy( aResourceName + nLen, "soAAT.fot", std::max( 0, nMaxLen - nLen ));
-    ::DeleteFileA( aResourceName );
+    wchar_t aResourceName[512];
+    int nMaxLen = SAL_N_ELEMENTS(aResourceName) - 16;
+    int nLen = GetTempPathW( nMaxLen, aResourceName );
+    wcsncpy( aResourceName + nLen, L"soAAT.fot", std::max( 0, nMaxLen - nLen ));
+    DeleteFileW( aResourceName );
 
     // Create font resource file (typically with a .fot file name extension).
-    rtl_TextEncoding theEncoding = osl_getThreadTextEncoding();
-    OString aCFileName = OUStringToOString( aUSytemPath, theEncoding );
-    ::CreateScalableFontResourceA( 0, aResourceName, aCFileName.getStr(), nullptr );
+    CreateScalableFontResourceW( 0, aResourceName, SAL_W(aUSytemPath.getStr()), nullptr );
 
     // Open and read the font resource file
-    OUString aFotFileName = OStringToOUString( aResourceName, osl_getThreadTextEncoding() );
+    OUString aFotFileName = SAL_U( aResourceName );
     osl::FileBase::getFileURLFromSystemPath( aFotFileName, aFotFileName );
     osl::File aFotFile( aFotFileName );
     osl::FileBase::RC aError = aFotFile.open( osl_File_OpenFlag_Read );
@@ -1171,7 +1167,7 @@ static bool ImplGetFontAttrFromFile( const OUString& rFontFileURL,
     aFotFile.read( aBuffer, sizeof( aBuffer ), nBytesRead );
     // clean up temporary resource file

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list