summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/update_pch10
-rw-r--r--cli_ure/source/native/native_bootstrap.cxx17
-rw-r--r--dbaccess/win32/source/odbcconfig/odbcconfig.cxx21
-rw-r--r--desktop/source/deployment/misc/dp_misc.cxx1
-rw-r--r--desktop/win32/source/QuickStart/QuickStart.cxx40
-rw-r--r--desktop/win32/source/guistdio/guistdio.inc28
-rw-r--r--dtrans/source/win32/clipb/MtaOleClipb.cxx47
-rw-r--r--dtrans/source/win32/workbench/XTDo.cxx1
-rw-r--r--dtrans/test/win32/dnd/dndTest.cxx29
-rw-r--r--extensions/source/activex/so_activex.cxx88
-rw-r--r--extensions/source/ole/wincrap.hxx1
-rw-r--r--extensions/source/update/check/onlinecheck.cxx9
-rw-r--r--extensions/test/ole/AxTestComponents/StdAfx.h1
-rw-r--r--extensions/test/ole/OleConverterVar1/convTest.cxx129
-rw-r--r--extensions/test/ole/cppToUno/testcppuno.cxx9
-rw-r--r--extensions/test/ole/cpptest/cpptest.cxx7
-rw-r--r--extensions/test/ole/unoTocomCalls/Test/StdAfx.h1
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h1
-rw-r--r--include/systools/win32/qswin32.h26
-rw-r--r--sal/qa/osl/file/osl_File_Const.h1
-rw-r--r--sal/qa/osl/process/osl_process.cxx8
-rw-r--r--sal/qa/osl/process/osl_process_child.cxx15
-rw-r--r--setup_native/source/win32/customactions/quickstarter/shutdown_quickstart.cxx10
-rw-r--r--setup_native/source/win32/customactions/regactivex/regactivex.cxx75
-rw-r--r--setup_native/source/win32/customactions/tools/checkversion.cxx2
-rw-r--r--setup_native/source/win32/customactions/tools/seterror.cxx2
-rw-r--r--sfx2/source/appl/shutdowniconw32.cxx146
-rw-r--r--shell/inc/config.hxx2
-rw-r--r--shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx39
-rw-r--r--shell/source/win32/shlxthandler/shlxthdl.cxx1
-rw-r--r--shell/source/win32/simplemail/senddoc.cxx4
-rw-r--r--svl/source/svdde/ddecli.cxx13
-rw-r--r--svl/source/svdde/ddedata.cxx10
-rw-r--r--svl/source/svdde/ddestrg.cxx4
-rw-r--r--svl/source/svdde/ddesvr.cxx63
-rw-r--r--svx/inc/pch/precompiled_svx.hxx5
-rw-r--r--sw/source/ui/vba/vbasystem.cxx44
37 files changed, 420 insertions, 490 deletions
diff --git a/bin/update_pch b/bin/update_pch
index ae275cc83cf9..6522cd169394 100755
--- a/bin/update_pch
+++ b/bin/update_pch
@@ -755,16 +755,6 @@ def generate(includes, libname, filename, module):
"""
f.write(sal_define)
- # svx needs this (sendreportw32.cxx)
- if module == 'svx' and libname == 'svx':
- svx_define = """
-#ifdef _WIN32
-# define UNICODE
-# define _UNICODE
-#endif
-"""
- f.write(svx_define)
-
# Dump the headers.
f.write('\n')
for i in includes:
diff --git a/cli_ure/source/native/native_bootstrap.cxx b/cli_ure/source/native/native_bootstrap.cxx
index 19b83fa4eb91..0ec2375a1c78 100644
--- a/cli_ure/source/native/native_bootstrap.cxx
+++ b/cli_ure/source/native/native_bootstrap.cxx
@@ -17,23 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-// Use UNICODE Windows and C API.
-#define _UNICODE
-#define UNICODE
-
-#ifdef _MSC_VER
-#pragma warning(push, 1)
-#endif
-#if !defined WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
-#include <tchar.h>
-
#include "native_share.h"
#include "rtl/bootstrap.hxx"
diff --git a/dbaccess/win32/source/odbcconfig/odbcconfig.cxx b/dbaccess/win32/source/odbcconfig/odbcconfig.cxx
index 59e5b67c4424..86f8e67c4071 100644
--- a/dbaccess/win32/source/odbcconfig/odbcconfig.cxx
+++ b/dbaccess/win32/source/odbcconfig/odbcconfig.cxx
@@ -18,10 +18,6 @@
*/
-#define UNICODE
-#define _UNICODE
-#include <tchar.h>
-
#ifdef _MSC_VER
#pragma warning(push, 1)
#pragma warning(disable:4005)
@@ -31,7 +27,6 @@
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
-#include <shellapi.h>
#include <sqlext.h>
#ifdef _MSC_VER
@@ -50,19 +45,19 @@ int displayLastError()
DWORD dwError = GetLastError();
LPVOID lpMsgBuf;
- FormatMessage(
+ FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
nullptr,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- reinterpret_cast<LPTSTR>(&lpMsgBuf),
+ reinterpret_cast<LPWSTR>(&lpMsgBuf),
0,
nullptr
);
// Display the string.
- MessageBox( nullptr, static_cast<LPCTSTR>(lpMsgBuf), nullptr, MB_OK | MB_ICONERROR );
+ MessageBoxW( nullptr, static_cast<LPCWSTR>(lpMsgBuf), nullptr, MB_OK | MB_ICONERROR );
// Free the buffer.
LocalFree( lpMsgBuf );
@@ -74,11 +69,11 @@ int displayLastError()
*/
BOOL registerWindowClass( HINSTANCE _hAppInstance )
{
- WNDCLASSEX wcx;
+ WNDCLASSEXW wcx;
wcx.cbSize = sizeof(wcx); // size of structure
wcx.style = CS_HREDRAW | CS_VREDRAW; // redraw if size changes
- wcx.lpfnWndProc = DefWindowProc; // points to window procedure
+ wcx.lpfnWndProc = DefWindowProcW; // points to window procedure
wcx.cbClsExtra = 0; // no extra class memory
wcx.cbWndExtra = 0; // no extra window memory
wcx.hInstance = _hAppInstance; // handle to instance
@@ -89,13 +84,13 @@ BOOL registerWindowClass( HINSTANCE _hAppInstance )
wcx.lpszClassName = L"ODBCConfigMainClass"; // name of window class
wcx.hIconSm = nullptr; // small class icon
- return ( !!RegisterClassEx( &wcx ) );
+ return ( !!RegisterClassExW( &wcx ) );
}
/// initializes the application instances
HWND initInstance( HINSTANCE _hAppInstance )
{
- HWND hWindow = CreateWindow(
+ HWND hWindow = CreateWindowW(
L"ODBCConfigMainClass", // name of window class
L"ODBC Config Wrapper", // title-bar string
WS_OVERLAPPEDWINDOW, // top-level window
@@ -114,7 +109,7 @@ HWND initInstance( HINSTANCE _hAppInstance )
}
// main window function
-extern "C" int APIENTRY _tWinMain( HINSTANCE _hAppInstance, HINSTANCE, LPTSTR, int )
+extern "C" int APIENTRY wWinMain( HINSTANCE _hAppInstance, HINSTANCE, LPWSTR, int )
{
if ( !registerWindowClass( _hAppInstance ) )
return FALSE;
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index e593e1b2f71b..aa996d426db9 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -47,7 +47,6 @@
#include <salhelper/linkhelper.hxx>
#ifdef _WIN32
-#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
diff --git a/desktop/win32/source/QuickStart/QuickStart.cxx b/desktop/win32/source/QuickStart/QuickStart.cxx
index 2c426be6c2bb..0cc673c77191 100644
--- a/desktop/win32/source/QuickStart/QuickStart.cxx
+++ b/desktop/win32/source/QuickStart/QuickStart.cxx
@@ -39,35 +39,39 @@
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
-#include <tchar.h>
bool SofficeRuns()
{
// check for soffice by searching the communication window
- return FindWindowEx( nullptr, nullptr, QUICKSTART_CLASSNAME, nullptr ) != nullptr;
+ return FindWindowExW( nullptr, nullptr, QUICKSTART_CLASSNAME, nullptr ) != nullptr;
}
bool launchSoffice( )
{
if ( !SofficeRuns() )
{
- char filename[_MAX_PATH + 1];
+ wchar_t filename[_MAX_PATH + 1];
filename[_MAX_PATH] = 0;
- GetModuleFileName( nullptr, filename, _MAX_PATH ); // soffice resides in the same dir
- char *p = strrchr( filename, '\\' );
+ GetModuleFileNameW( nullptr, filename, _MAX_PATH ); // soffice resides in the same dir
+ wchar_t *p = wcsrchr( filename, L'\\' );
if ( !p )
return false;
- strncpy( p+1, "soffice.exe", _MAX_PATH - (p+1 - filename) );
+ wcsncpy( p+1, L"soffice.exe", _MAX_PATH - (p+1 - filename) );
- char imagename[_MAX_PATH + 1];
+ wchar_t imagename[_MAX_PATH + 1];
imagename[_MAX_PATH] = 0;
- _snprintf(imagename, _MAX_PATH, "\"%s\" --quickstart", filename );
-
- UINT ret = WinExec( imagename, SW_SHOW );
- if ( ret < 32 )
+ _snwprintf(imagename, _MAX_PATH, L"\"%s\" --quickstart", filename );
+
+ STARTUPINFOW aStartupInfo;
+ ZeroMemory(&aStartupInfo, sizeof(aStartupInfo));
+ aStartupInfo.cb = sizeof(aStartupInfo);
+ aStartupInfo.wShowWindow = SW_SHOW;
+ PROCESS_INFORMATION aProcessInfo;
+ BOOL bSuccess = CreateProcessW(filename, imagename, nullptr, nullptr, TRUE, 0, nullptr, nullptr, &aStartupInfo, &aProcessInfo);
+ if ( !bSuccess )
return false;
return true;
@@ -76,10 +80,10 @@ bool launchSoffice( )
return true;
}
-int APIENTRY WinMain(HINSTANCE /*hInstance*/,
- HINSTANCE /*hPrevInstance*/,
- LPSTR /*lpCmdLine*/,
- int /*nCmdShow*/)
+int APIENTRY wWinMain(HINSTANCE /*hInstance*/,
+ HINSTANCE /*hPrevInstance*/,
+ LPWSTR /*lpCmdLine*/,
+ int /*nCmdShow*/)
{
// Look for --killtray argument
@@ -87,12 +91,12 @@ int APIENTRY WinMain(HINSTANCE /*hInstance*/,
{
if ( 0 == strcmp( __argv[i], "--killtray" ) )
{
- HWND hwndTray = FindWindow( QUICKSTART_CLASSNAME, nullptr );
+ HWND hwndTray = FindWindowW( QUICKSTART_CLASSNAME, nullptr );
if ( hwndTray )
{
- UINT uMsgKillTray = RegisterWindowMessage( SHUTDOWN_QUICKSTART_MESSAGE );
- SendMessage( hwndTray, uMsgKillTray, 0, 0 );
+ UINT uMsgKillTray = RegisterWindowMessageW( SHUTDOWN_QUICKSTART_MESSAGE );
+ SendMessageW( hwndTray, uMsgKillTray, 0, 0 );
}
return 0;
diff --git a/desktop/win32/source/guistdio/guistdio.inc b/desktop/win32/source/guistdio/guistdio.inc
index 5617d889a402..5d6634bb9c5c 100644
--- a/desktop/win32/source/guistdio/guistdio.inc
+++ b/desktop/win32/source/guistdio/guistdio.inc
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define UNICODE
#define WIN32_LEAN_AND_MEAN
#ifdef _MSC_VER
#pragma warning(push,1) // disable warnings within system headers
@@ -27,9 +26,6 @@
#pragma warning(pop)
#endif
-#define _UNICODE
-#include <tchar.h>
-
#include <string.h>
#include <stdlib.h>
#include <systools/win32/uwinapi.h>
@@ -250,7 +246,7 @@ DWORD WINAPI WaitForUIThread( LPVOID pParam )
#ifndef UNOPKG
HANDLE hProcess = (HANDLE)pParam;
- if ( !_tgetenv( TEXT("UNOPKG") ) )
+ if ( !wgetenv( L"UNOPKG" ) )
WaitForInputIdle( hProcess, INFINITE );
#else
(void) pParam;
@@ -274,10 +270,10 @@ BOOL WINAPI CtrlBreakHandler(
return TRUE;
}
-int _tmain( int, _TCHAR ** )
+int wmain( int, wchar_t** )
{
- TCHAR szTargetFileName[MAX_PATH] = TEXT("");
- STARTUPINFO aStartupInfo;
+ WCHAR szTargetFileName[MAX_PATH] = L"";
+ STARTUPINFOW aStartupInfo;
PROCESS_INFORMATION aProcessInfo;
ZeroMemory( &aStartupInfo, sizeof(aStartupInfo) );
@@ -331,23 +327,23 @@ int _tmain( int, _TCHAR ** )
// Get image path with same name but with .exe extension
- TCHAR szModuleFileName[MAX_PATH];
+ WCHAR szModuleFileName[MAX_PATH];
- GetModuleFileName( nullptr, szModuleFileName, MAX_PATH );
- _TCHAR *lpLastDot = _tcsrchr( szModuleFileName, '.' );
- if ( lpLastDot && 0 == _tcsicmp( lpLastDot, _T(".COM") ) )
+ GetModuleFileNameW( nullptr, szModuleFileName, MAX_PATH );
+ WCHAR *lpLastDot = wcsrchr( szModuleFileName, '.' );
+ if ( lpLastDot && 0 == wcsicmp( lpLastDot, L".COM" ) )
{
size_t len = lpLastDot - szModuleFileName;
- _tcsncpy( szTargetFileName, szModuleFileName, len );
- _tcsncpy( szTargetFileName + len, _T(".EXE"), SAL_N_ELEMENTS(szTargetFileName) - len );
+ wcsncpy( szTargetFileName, szModuleFileName, len );
+ wcsncpy( szTargetFileName + len, L".EXE", SAL_N_ELEMENTS(szTargetFileName) - len );
}
// Create process with same command line, environment and stdio handles which
// are directed to the created pipes
- BOOL fSuccess = CreateProcess(
+ BOOL fSuccess = CreateProcessW(
szTargetFileName,
- GetCommandLine(),
+ GetCommandLineW(),
nullptr,
nullptr,
TRUE,
diff --git a/dtrans/source/win32/clipb/MtaOleClipb.cxx b/dtrans/source/win32/clipb/MtaOleClipb.cxx
index e80b048d7101..91585935c5b9 100644
--- a/dtrans/source/win32/clipb/MtaOleClipb.cxx
+++ b/dtrans/source/win32/clipb/MtaOleClipb.cxx
@@ -35,7 +35,10 @@
// characters in the debug information
#endif
-//#define UNICODE
+#if !defined WINVER
+#define WINVER 0x0400
+#endif
+
#include <osl/diagnose.h>
#include <sal/log.hxx>
@@ -54,8 +57,8 @@ using osl::ClearableMutexGuard;
namespace /* private */
{
- char CLIPSRV_DLL_NAME[] = "sysdtrans.dll";
- char g_szWndClsName[] = "MtaOleReqWnd###";
+ wchar_t CLIPSRV_DLL_NAME[] = L"sysdtrans.dll";
+ wchar_t g_szWndClsName[] = L"MtaOleReqWnd###";
// messages constants
@@ -86,7 +89,7 @@ namespace /* private */
// ctor
Win32Condition()
{
- m_hEvent = CreateEvent(
+ m_hEvent = CreateEventW(
nullptr, /* no security */
true, /* manual reset */
false, /* initial state not signaled */
@@ -119,7 +122,7 @@ namespace /* private */
queue that's what we want, messages from the PostMessage
queue stay untouched */
MSG msg;
- PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE);
+ PeekMessageW(&msg, nullptr, 0, 0, PM_NOREMOVE);
break;
}
@@ -248,7 +251,7 @@ CMtaOleClipboard::CMtaOleClipboard( ) :
m_ClipboardChangedEventCount( 0 )
{
// signals that the thread was successfully setup
- m_hEvtThrdReady = CreateEventA( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr );
+ m_hEvtThrdReady = CreateEventW( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr );
OSL_ASSERT( nullptr != m_hEvtThrdReady );
@@ -260,10 +263,10 @@ CMtaOleClipboard::CMtaOleClipboard( ) :
// setup the clipboard changed notifier thread
- m_hClipboardChangedNotifierEvents[0] = CreateEventA( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr );
+ m_hClipboardChangedNotifierEvents[0] = CreateEventW( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr );
OSL_ASSERT( nullptr != m_hClipboardChangedNotifierEvents[0] );
- m_hClipboardChangedNotifierEvents[1] = CreateEventA( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr );
+ m_hClipboardChangedNotifierEvents[1] = CreateEventW( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr );
OSL_ASSERT( nullptr != m_hClipboardChangedNotifierEvents[1] );
unsigned uThreadId;
@@ -315,7 +318,7 @@ CMtaOleClipboard::~CMtaOleClipboard( )
CloseHandle( m_hEvtThrdReady );
if ( m_MtaOleReqWndClassAtom )
- UnregisterClassA( g_szWndClsName, nullptr );
+ UnregisterClassW( g_szWndClsName, nullptr );
OSL_ENSURE( ( nullptr == m_pfncClipViewerCallback ) &&
!IsWindow( m_hwndNextClipViewer ),
@@ -516,7 +519,7 @@ LRESULT CMtaOleClipboard::onChangeCBChain( HWND hWndRemove, HWND hWndNext )
{
// forward the message to the next one
DWORD_PTR dwpResult;
- SendMessageTimeoutA(
+ SendMessageTimeoutW(
m_hwndNextClipViewer,
WM_CHANGECBCHAIN,
reinterpret_cast<WPARAM>(hWndRemove),
@@ -549,7 +552,7 @@ LRESULT CMtaOleClipboard::onDrawClipboard( )
if ( IsWindow( m_hwndNextClipViewer ) )
{
DWORD_PTR dwpResult;
- SendMessageTimeoutA(
+ SendMessageTimeoutW(
m_hwndNextClipViewer,
WM_DRAWCLIPBOARD,
static_cast< WPARAM >( 0 ),
@@ -567,7 +570,7 @@ LRESULT CMtaOleClipboard::onDrawClipboard( )
LRESULT CMtaOleClipboard::sendMessage( UINT msg, WPARAM wParam, LPARAM lParam )
{
- return ::SendMessageA( m_hwndMtaOleReqWnd, msg, wParam, lParam );
+ return ::SendMessageW( m_hwndMtaOleReqWnd, msg, wParam, lParam );
}
// PostMessage so we don't need to supply the HWND if we send
@@ -575,7 +578,7 @@ LRESULT CMtaOleClipboard::sendMessage( UINT msg, WPARAM wParam, LPARAM lParam )
bool CMtaOleClipboard::postMessage( UINT msg, WPARAM wParam, LPARAM lParam )
{
- BOOL const ret = PostMessageA(m_hwndMtaOleReqWnd, msg, wParam, lParam);
+ BOOL const ret = PostMessageW(m_hwndMtaOleReqWnd, msg, wParam, lParam);
SAL_WARN_IF(0 == ret, "dtrans", "ERROR: PostMessage() failed!");
return ret;
}
@@ -658,7 +661,7 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA
break;
default:
- lResult = DefWindowProcA( hWnd, uMsg, wParam, lParam );
+ lResult = DefWindowProcW( hWnd, uMsg, wParam, lParam );
break;
}
@@ -667,14 +670,14 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA
void CMtaOleClipboard::createMtaOleReqWnd( )
{
- WNDCLASSEXA wcex;
+ WNDCLASSEXW wcex;
- HINSTANCE hInst = GetModuleHandleA( CLIPSRV_DLL_NAME );
+ HINSTANCE hInst = GetModuleHandleW( CLIPSRV_DLL_NAME );
OSL_ENSURE( nullptr != hInst, "The name of the clipboard service dll must have changed" );
- ZeroMemory( &wcex, sizeof( WNDCLASSEXA ) );
+ ZeroMemory( &wcex, sizeof(wcex) );
- wcex.cbSize = sizeof(WNDCLASSEXA);
+ wcex.cbSize = sizeof(wcex);
wcex.style = 0;
wcex.lpfnWndProc = static_cast< WNDPROC >( CMtaOleClipboard::mtaOleReqWndProc );
wcex.cbClsExtra = 0;
@@ -687,10 +690,10 @@ void CMtaOleClipboard::createMtaOleReqWnd( )
wcex.lpszClassName = g_szWndClsName;
wcex.hIconSm = nullptr;
- m_MtaOleReqWndClassAtom = RegisterClassExA( &wcex );
+ m_MtaOleReqWndClassAtom = RegisterClassExW( &wcex );
if ( 0 != m_MtaOleReqWndClassAtom )
- m_hwndMtaOleReqWnd = CreateWindowA(
+ m_hwndMtaOleReqWnd = CreateWindowW(
g_szWndClsName, nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, hInst, nullptr );
}
@@ -710,8 +713,8 @@ unsigned int CMtaOleClipboard::run( )
// pumping messages
MSG msg;
- while( GetMessageA( &msg, nullptr, 0, 0 ) )
- DispatchMessageA( &msg );
+ while( GetMessageW( &msg, nullptr, 0, 0 ) )
+ DispatchMessageW( &msg );
nRet = 0;
}
diff --git a/dtrans/source/win32/workbench/XTDo.cxx b/dtrans/source/win32/workbench/XTDo.cxx
index 2aecc0c5bf22..f8da707d92e3 100644
--- a/dtrans/source/win32/workbench/XTDo.cxx
+++ b/dtrans/source/win32/workbench/XTDo.cxx
@@ -32,7 +32,6 @@
#pragma warning(pop)
#endif
#include <memory>
-#include <tchar.h>
using namespace ::std;
diff --git a/dtrans/test/win32/dnd/dndTest.cxx b/dtrans/test/win32/dnd/dndTest.cxx
index 16d16f74f891..b9f1d841e1c5 100644
--- a/dtrans/test/win32/dnd/dndTest.cxx
+++ b/dtrans/test/win32/dnd/dndTest.cxx
@@ -22,7 +22,6 @@
#endif
#include <windows.h>
#include <comdef.h>
-#include <tchar.h>
#include <atlbase.h>
CComModule _Module;
#include <atlcom.h>
@@ -59,11 +58,11 @@ int main( int argc, char *argv[ ], char *envp[ ] )
HRESULT hr;
if( FAILED( hr=CoInitialize(NULL )))
{
- _tprintf(_T("CoInitialize failed \n"));
+ printf("CoInitialize failed \n");
return -1;
}
- _Module.Init( ObjectMap, GetModuleHandle( NULL));
+ _Module.Init( ObjectMap, GetModuleHandleA( NULL));
if( FAILED(hr=doTest()))
{
@@ -82,7 +81,7 @@ HRESULT doTest()
// create the MTA thread that is used to realize MTA calls to the services
// We create the thread and wait until the thread has created its message queue
- HANDLE evt= CreateEvent(NULL, FALSE, FALSE, NULL);
+ HANDLE evt= CreateEventA(NULL, FALSE, FALSE, NULL);
DWORD threadIdMTA=0;
HANDLE hMTAThread= CreateThread( NULL, 0, MTAFunc, &evt, 0, &threadIdMTA);
WaitForSingleObject( evt, INFINITE);
@@ -90,27 +89,27 @@ HRESULT doTest()
HRESULT hr= S_OK;
RECT pos1={0,0,300,200};
- AWindow win(_T("DnD starting in Ole STA"), threadIdMTA, pos1);
+ AWindow win("DnD starting in Ole STA", threadIdMTA, pos1);
RECT pos2={ 0, 205, 300, 405};
- AWindow win2( _T("DnD starting in MTA"), threadIdMTA, pos2, true);
+ AWindow win2("DnD starting in MTA", threadIdMTA, pos2, true);
// win3 and win4 call initialize from an MTA but they are created in an STA
RECT pos3={300,0,600,200};
- AWindow win3(_T("DnD starting in OLE STA"), threadIdMTA, pos3, false, true);
+ AWindow win3("DnD starting in OLE STA", threadIdMTA, pos3, false, true);
RECT pos4={ 300, 205, 600, 405};
- AWindow win24( _T("DnD starting in Ole MTA"), threadIdMTA, pos4, true, true);
+ AWindow win24("DnD starting in Ole MTA", threadIdMTA, pos4, true, true);
MSG msg;
- while( GetMessage(&msg, (HWND)NULL, 0, 0) )
+ while( GetMessageA(&msg, (HWND)NULL, 0, 0) )
{
TranslateMessage( &msg);
- DispatchMessage( &msg);
+ DispatchMessageA( &msg);
}
// Shut down the MTA thread
- PostThreadMessage( threadIdMTA, WM_QUIT, 0, 0);
+ PostThreadMessageA( threadIdMTA, WM_QUIT, 0, 0);
WaitForSingleObject(hMTAThread, INFINITE);
CloseHandle(hMTAThread);
@@ -124,13 +123,13 @@ DWORD WINAPI MTAFunc( void* threadData)
ATLASSERT( FAILED(hr) );
MSG msg;
// force the creation of a message queue
- PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
+ PeekMessageA(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
SetEvent( *(HANDLE*)threadData );
RECT pos={0, 406, 300, 605};
- AWindow win(_T("DnD, full MTA"), GetCurrentThreadId(), pos, false, true);
+ AWindow win("DnD, full MTA", GetCurrentThreadId(), pos, false, true);
- while( GetMessage(&msg, (HWND)NULL, 0, 0) )
+ while( GetMessageA(&msg, (HWND)NULL, 0, 0) )
{
switch( msg.message)
{
@@ -168,7 +167,7 @@ DWORD WINAPI MTAFunc( void* threadData)
} // end switch
TranslateMessage( &msg);
- DispatchMessage( &msg);
+ DispatchMessageA( &msg);
}
CoUninitialize();
diff --git a/extensions/source/activex/so_activex.cxx b/extensions/source/activex/so_activex.cxx
index 0f523c1e8b16..b9858d01ec6b 100644
--- a/extensions/source/activex/so_activex.cxx
+++ b/extensions/source/activex/so_activex.cxx
@@ -64,8 +64,8 @@ END_OBJECT_MAP()
#pragma clang diagnostic pop
#endif
-#define X64_LIB_NAME "so_activex_x64.dll"
-#define X32_LIB_NAME "so_activex.dll"
+#define X64_LIB_NAME L"so_activex_x64.dll"
+#define X32_LIB_NAME L"so_activex.dll"
// to provide windows xp as build systems for mingw we need to define KEY_WOW64_64KEY
// in mingw 3.13 KEY_WOW64_64KEY isn't available < Win2003 systems.
@@ -196,7 +196,7 @@ const char* const aLocalPrefix = "Software\\Classes\\";
BOOL createKey( HKEY hkey,
const char* aKeyToCreate,
- REGSAM nKeyAccess,
+ REGSAM nKeyAccess,
const char* aValue = nullptr,
const char* aChildName = nullptr,
const char* aChildValue = nullptr )
@@ -220,8 +220,34 @@ BOOL createKey( HKEY hkey,
}
+BOOL createKey( HKEY hkey,
+ const wchar_t* aKeyToCreate,
+ REGSAM nKeyAccess,
+ const wchar_t* aValue = nullptr,
+ const wchar_t* aChildName = nullptr,
+ const wchar_t* aChildValue = nullptr )
+{
+ HKEY hkey1;
+
+ return ( ERROR_SUCCESS == RegCreateKeyExW( hkey, aKeyToCreate, 0, nullptr, REG_OPTION_NON_VOLATILE, nKeyAccess, nullptr, &hkey1 , nullptr )
+ && ( !aValue || ERROR_SUCCESS == RegSetValueExW( hkey1,
+ L"",
+ 0,
+ REG_SZ,
+ reinterpret_cast<const BYTE*>(aValue),
+ sal::static_int_cast<DWORD>(wcslen(aValue)*sizeof(wchar_t))))
+ && ( !aChildName || ERROR_SUCCESS == RegSetValueExW( hkey1,
+ aChildName,
+ 0,
+ REG_SZ,
+ reinterpret_cast<const BYTE*>(aChildValue),
+ sal::static_int_cast<DWORD>(wcslen(aChildValue)*sizeof(wchar_t))))
+ && ERROR_SUCCESS == RegCloseKey( hkey1 ) );
+
+}
+
STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit );
-STDAPI DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess, const char* pProgramPath, const char* pLibName )
+HRESULT DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess, const wchar_t* pProgramPath, const wchar_t* pLibName )
{
BOOL aResult = FALSE;
@@ -230,7 +256,7 @@ STDAPI DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAc
HKEY hkey2 = nullptr;
HKEY hkey3 = nullptr;
HKEY hkey4 = nullptr;
- char aSubKey[513];
+ char aSubKey[513];
int ind;
const char* aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
@@ -241,13 +267,13 @@ STDAPI DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAc
if ( bForAllUsers )
DllUnregisterServerNative( nMode, false, false );
- if ( pProgramPath && strlen( pProgramPath ) < 1024 )
+ if ( pProgramPath && wcslen( pProgramPath ) < 1024 )
{
- char pActiveXPath[1124];
- char pActiveXPath101[1124];
+ wchar_t pActiveXPath[1124];
+ wchar_t pActiveXPath101[1124];
- sprintf( pActiveXPath, "%s\\%s", pProgramPath, pLibName );
- sprintf( pActiveXPath101, "%s\\%s, 101", pProgramPath, pLibName );
+ swprintf( pActiveXPath, L"%s\\%s", pProgramPath, pLibName );
+ swprintf( pActiveXPath101, L"%s\\%s, 101", pProgramPath, pLibName );
{
wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
@@ -256,12 +282,12 @@ STDAPI DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAc
&& ERROR_SUCCESS == RegSetValueExA( hkey, "", 0, REG_SZ, reinterpret_cast<const BYTE*>("SOActiveX Class"), 17 )
&& createKey( hkey, "Control", nKeyAccess )
&& createKey( hkey, "EnableFullPage", nKeyAccess )
- && createKey( hkey, "InprocServer32", nKeyAccess, pActiveXPath, "ThreadingModel", "Apartment" )
+ && createKey( hkey, L"InprocServer32", nKeyAccess, pActiveXPath, L"ThreadingModel", L"Apartment" )
&& createKey( hkey, "MiscStatus", nKeyAccess, "0" )
&& createKey( hkey, "MiscStatus\\1", nKeyAccess, "131473" )
&& createKey( hkey, "ProgID", nKeyAccess, "so_activex.SOActiveX.1" )
&& createKey( hkey, "Programmable", nKeyAccess )
- && createKey( hkey, "ToolboxBitmap32", nKeyAccess, pActiveXPath101 )
+ && createKey( hkey, L"ToolboxBitmap32", nKeyAccess, pActiveXPath101 )
&& createKey( hkey, "TypeLib", nKeyAccess, aTypeLib )
&& createKey( hkey, "Version", nKeyAccess, "1.0" )
&& createKey( hkey, "VersionIndependentProgID", nKeyAccess, "so_activex.SOActiveX" )
@@ -281,10 +307,10 @@ STDAPI DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAc
&& createKey( hkey2, "1.0", nKeyAccess, "wrap_activex 1.0 Type Library" )
&& ERROR_SUCCESS == RegCreateKeyExA( hkey2, "1.0", 0, nullptr, REG_OPTION_NON_VOLATILE, nKeyAccess, nullptr, &hkey3 , nullptr )
&& ERROR_SUCCESS == RegCreateKeyExA( hkey3, "0", 0, nullptr, REG_OPTION_NON_VOLATILE, nKeyAccess, nullptr, &hkey4 , nullptr )
- && createKey( hkey4, "win32", nKeyAccess, pActiveXPath )
+ && createKey( hkey4, L"win32", nKeyAccess, pActiveXPath )
&& ERROR_SUCCESS == RegCloseKey( hkey4 )
&& createKey( hkey3, "FLAGS", nKeyAccess, "0" )
- && createKey( hkey3, "HELPDIR", nKeyAccess, pProgramPath )
+ && createKey( hkey3, L"HELPDIR", nKeyAccess, pProgramPath )
&& ERROR_SUCCESS == RegCloseKey( hkey3 )
&& ERROR_SUCCESS == RegCloseKey( hkey2 )
&& ERROR_SUCCESS == RegCloseKey( hkey1 )
@@ -363,7 +389,7 @@ STDAPI DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAc
return HRESULT(aResult);
}
-STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit, const char* pProgramPath )
+STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit, const wchar_t* pProgramPath )
{
HRESULT hr = S_OK;
if ( bFor64Bit )
@@ -418,10 +444,10 @@ STDAPI DllUnregisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKey
fErr = TRUE;
else
{
- if ( ERROR_SUCCESS != RegDeleteValue( hkey, "CLSID" ) )
+ if ( ERROR_SUCCESS != RegDeleteValueA( hkey, "CLSID" ) )
fErr = TRUE;
- if ( ERROR_SUCCESS != RegQueryInfoKey( hkey, nullptr, nullptr, nullptr,
+ if ( ERROR_SUCCESS != RegQueryInfoKeyA( hkey, nullptr, nullptr, nullptr,
&nSubKeys, nullptr, nullptr,
&nValues, nullptr, nullptr, nullptr, nullptr ) )
{
@@ -443,7 +469,7 @@ STDAPI DllUnregisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKey
fErr = TRUE;
else
{
- if ( ERROR_SUCCESS != RegQueryInfoKey( hkey, nullptr, nullptr, nullptr,
+ if ( ERROR_SUCCESS != RegQueryInfoKeyA( hkey, nullptr, nullptr, nullptr,
&nSubKeys, nullptr, nullptr,
&nValues, nullptr, nullptr, nullptr, nullptr ) )
{
@@ -637,15 +663,15 @@ STDAPI DllUnregisterServerDoc_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAcc
fErr = TRUE;
else
{
- if ( ERROR_SUCCESS != RegDeleteValue( hkey, "Extension" ) )
+ if ( ERROR_SUCCESS != RegDeleteValueA( hkey, "Extension" ) )
fErr = TRUE;
- if ( ERROR_SUCCESS != RegDeleteValue( hkey, "CLSID" ) )
+ if ( ERROR_SUCCESS != RegDeleteValueA( hkey, "CLSID" ) )
fErr = TRUE;
- if ( ERROR_SUCCESS != RegQueryInfoKey( hkey, nullptr, nullptr, nullptr,
- &nSubKeys, nullptr, nullptr,
- &nValues, nullptr, nullptr, nullptr, nullptr ) )
+ if ( ERROR_SUCCESS != RegQueryInfoKeyA( hkey, nullptr, nullptr, nullptr,
+ &nSubKeys, nullptr, nullptr,
+ &nValues, nullptr, nullptr, nullptr, nullptr ) )
{
RegCloseKey( hkey );
hkey = nullptr;
@@ -665,12 +691,12 @@ STDAPI DllUnregisterServerDoc_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAcc
fErr = TRUE;
else
{
- if ( ERROR_SUCCESS != RegDeleteValue( hkey, "Content Type" ) )
+ if ( ERROR_SUCCESS != RegDeleteValueA( hkey, "Content Type" ) )
fErr = TRUE;
- if ( ERROR_SUCCESS != RegQueryInfoKey( hkey, nullptr, nullptr, nullptr,
- &nSubKeys, nullptr, nullptr,
- &nValues, nullptr, nullptr, nullptr, nullptr ) )
+ if ( ERROR_SUCCESS != RegQueryInfoKeyA( hkey, nullptr, nullptr, nullptr,
+ &nSubKeys, nullptr, nullptr,
+ &nValues, nullptr, nullptr, nullptr, nullptr ) )
{
RegCloseKey( hkey );
hkey = nullptr;
@@ -709,14 +735,14 @@ STDAPI DllRegisterServer()
{
HRESULT aResult = E_FAIL;
- HMODULE aCurModule = GetModuleHandleA( bX64 ? X64_LIB_NAME : X32_LIB_NAME );
+ HMODULE aCurModule = GetModuleHandleW( bX64 ? X64_LIB_NAME : X32_LIB_NAME );
DWORD nLibNameLen = sal::static_int_cast<DWORD>(
- strlen((bX64) ? X64_LIB_NAME : X32_LIB_NAME));
+ wcslen((bX64) ? X64_LIB_NAME : X32_LIB_NAME));
if( aCurModule )
{
- char pProgramPath[1024];
- DWORD nLen = GetModuleFileNameA( aCurModule, pProgramPath, 1024 );
+ wchar_t pProgramPath[1024];
+ DWORD nLen = GetModuleFileNameW( aCurModule, pProgramPath, 1024 );
if ( nLen && nLen > nLibNameLen + 1 )
{
pProgramPath[ nLen - nLibNameLen - 1 ] = 0;
diff --git a/extensions/source/ole/wincrap.hxx b/extensions/source/ole/wincrap.hxx
index 426195a8d38b..485c8c0aef67 100644
--- a/extensions/source/ole/wincrap.hxx
+++ b/extensions/source/ole/wincrap.hxx
@@ -34,7 +34,6 @@
#pragma warning (disable:4005)
#pragma warning (disable:4548)
-#include <tchar.h>
#include <dispex.h>
#include <prewin.h>
diff --git a/extensions/source/update/check/onlinecheck.cxx b/extensions/source/update/check/onlinecheck.cxx
index 1568f848a2ed..be6912f17afb 100644
--- a/extensions/source/update/check/onlinecheck.cxx
+++ b/extensions/source/update/check/onlinecheck.cxx
@@ -30,19 +30,14 @@
#include <windows.h>
#include <wininet.h>
-#ifdef UNICODE
-#define _UNICODE
-#endif
-#include <tchar.h>
-
// #i71984
extern "C" bool SAL_CALL WNT_hasInternetConnection()
{
DWORD dwFlags;
- TCHAR szConnectionName[1024];
+ WCHAR szConnectionName[1024];
__try {
- BOOL fIsConnected = InternetGetConnectedStateEx(
+ BOOL fIsConnected = InternetGetConnectedStateExW(
&dwFlags,
szConnectionName,
SAL_N_ELEMENTS(szConnectionName),
diff --git a/extensions/test/ole/AxTestComponents/StdAfx.h b/extensions/test/ole/AxTestComponents/StdAfx.h
index eed60448a599..da6810aea051 100644
--- a/extensions/test/ole/AxTestComponents/StdAfx.h
+++ b/extensions/test/ole/AxTestComponents/StdAfx.h
@@ -39,7 +39,6 @@
extern CComModule _Module;
#include <atlcom.h>
#include <stdio.h>
-#include <tchar.h>
#include <string.h>
//{{AFX_INSERT_LOCATION}}
diff --git a/extensions/test/ole/OleConverterVar1/convTest.cxx b/extensions/test/ole/OleConverterVar1/convTest.cxx
index a3ac2a23d45d..c0acc3152abf 100644
--- a/extensions/test/ole/OleConverterVar1/convTest.cxx
+++ b/extensions/test/ole/OleConverterVar1/convTest.cxx
@@ -24,7 +24,6 @@
#endif
#include <windows.h>
#include <comdef.h>
-#include <tchar.h>
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
@@ -63,23 +62,23 @@ void printResultVariantArray( VARIANT & var);
void printVariant( VARIANT & var);
-int SAL_CALL _tmain( int argc, _TCHAR * argv[] )
+int SAL_CALL main( int argc, char* argv[] )
{
HRESULT hr;
if( FAILED( hr=CoInitialize(NULL)))
{
- _tprintf(_T("CoInitialize failed \n"));
+ printf("CoInitialize failed \n");
return -1;
}
- _Module.Init( ObjectMap, GetModuleHandle( NULL));
+ _Module.Init( ObjectMap, GetModuleHandleA( NULL));
if( FAILED(hr=doTest()))
{
_com_error err( hr);
- const TCHAR * errMsg= err.ErrorMessage();
- MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
+ const CHAR * errMsg= err.ErrorMessage();
+ MessageBoxA( NULL, errMsg, "Test failed", MB_ICONERROR);
}
@@ -292,8 +291,8 @@ HRESULT doTest()
V_DISPATCHREF(&varOutXInterface)= &dispOut.p;
// In Parameter ( all of type Sequence ###########################################################
- OutputDebugString( _T("In parameter of type Sequence ###########################################\n"
- "The functions return the Sequence parameter \n\n"));
+ OutputDebugStringA( "In parameter of type Sequence ###########################################\n"
+ "The functions return the Sequence parameter \n\n");
OutputDebugStringA("methodByte | Params: \n");
printVariant( varByteArray);
@@ -338,48 +337,48 @@ HRESULT doTest()
printVariant( varRet);
// Out Parameter ###########################################################################
- OutputDebugString( _T("Out parameter ###########################################\n\n"));
+ OutputDebugStringA("Out parameter ###########################################\n\n");
- OutputDebugString(_T("testout_methodByte \n"));
+ OutputDebugStringA("testout_methodByte \n");
hr= oletest.InvokeN(static_cast<LPCOLESTR>(L"testout_methodByte"), &varOutByte, 1, &varRet);
- OutputDebugString(_T("testout_methodByte | out value: \n"));
+ OutputDebugStringA("testout_methodByte | out value: \n");
printVariant( varOutByte);
- OutputDebugString(_T("testout_methodShort \n"));
+ OutputDebugStringA("testout_methodShort \n");
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodShort"), &varOutShort, &varRet);
- OutputDebugString(_T("testout_methodShort | out value: \n"));
+ OutputDebugStringA("testout_methodShort | out value: \n");
printVariant( varOutShort);
- OutputDebugString(_T("testout_methodLong \n"));
+ OutputDebugStringA("testout_methodLong \n");
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodLong"), &varOutLong, &varRet);
- OutputDebugString(_T("testout_methodLong | out value: \n"));
+ OutputDebugStringA("testout_methodLong | out value: \n");
printVariant( varOutLong);
- OutputDebugString(_T("testout_methodDouble \n"));
+ OutputDebugStringA("testout_methodDouble \n");
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodDouble"), &varOutDouble, &varRet);
- OutputDebugString(_T("testout_methodDouble | out value: \n"));
+ OutputDebugStringA("testout_methodDouble | out value: \n");
printVariant( varOutDouble);
- OutputDebugString(_T("testout_methodString \n"));
+ OutputDebugStringA("testout_methodString \n");
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodString"), &varOutString, &varRet);
- OutputDebugString(_T("testout_methodString | out value: \n"));
+ OutputDebugStringA("testout_methodString | out value: \n");
printVariant( varOutString);
- OutputDebugString(_T("testout_methodAny \n"));
+ OutputDebugStringA("testout_methodAny \n");
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodAny"), &varOutAny, &varRet);
- OutputDebugString(_T("methodAny | out value: \n"));
+ OutputDebugStringA("methodAny | out value: \n");
printVariant( varOutAny);
- OutputDebugString(_T("testout_methodXInterface \n"));
+ OutputDebugStringA("testout_methodXInterface \n");
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodXInterface"), &varOutXInterface, &varRet);
- OutputDebugString(_T("methodAny | out value: \n"));
+ OutputDebugStringA("methodAny | out value: \n");
printVariant( varOutXInterface);
CComDispatchDriver outDisp( *varOutXInterface.ppdispVal);
CComVariant varAttr3;
outDisp.GetPropertyByName(L"AttrAny2", &varAttr3);
- ATLTRACE("property OleTest.AttrAny2: %s", W2T(varAttr3.bstrVal));
+ ATLTRACE("property OleTest.AttrAny2: %s", W2A(varAttr3.bstrVal));
- OutputDebugString(_T("testout_methodMulParams1 ( 2 out Parameter) \n"));
+ OutputDebugStringA("testout_methodMulParams1 ( 2 out Parameter) \n");
long longOut2=0;
CComVariant _params[2];
longOut=0;
@@ -387,72 +386,72 @@ HRESULT doTest()
_params[1].vt= VT_BYREF | VT_I4;
V_I4REF(& _params[1])= &longOut2;
hr= oletest.InvokeN( static_cast<LPCOLESTR>(L"testout_methodMulParams1"), (VARIANT*)&_params, 2);
- OutputDebugString(_T("testout_methodMulParams1 | out values: \n"));
+ OutputDebugStringA("testout_methodMulParams1 | out values: \n");
printVariant( _params[1]);
printVariant( _params[0]);
- OutputDebugString(_T("testout_methodMulParams2 ( 3 out Parameter) \n"));
+ OutputDebugStringA("testout_methodMulParams2 ( 3 out Parameter) \n");
CComVariant _params2[3];
_params2[2]= varOutLong;
_params2[1].vt= VT_BYREF | VT_I4;
V_I4REF(& _params2[1])= &longOut2;
_params2[0]= varOutString;
hr= oletest.InvokeN( static_cast<LPCOLESTR>( L"testout_methodMulParams2"), (VARIANT*)&_params2, 3);
- OutputDebugString(_T("testout_methodMulParams2 | out values: \n"));
+ OutputDebugStringA("testout_methodMulParams2 | out values: \n");
printVariant( _params2[2]);
printVariant( _params2[1]);
printVariant( _params2[0]);
- OutputDebugString(_T("testout_methodMulParams3 ( 1 in and 1 out Parameter) \n"));
+ OutputDebugStringA("testout_methodMulParams3 ( 1 in and 1 out Parameter) \n");
CComVariant _params3[2];
_params3[1]= CComBSTR(L" In string");
_params3[0]= varOutString;
hr= oletest.InvokeN( static_cast<LPCOLESTR>( L"testout_methodMulParams3"), (VARIANT*)&_params3, 2);
- OutputDebugString(_T("testout_methodMulParams3 | out values: \n"));
+ OutputDebugStringA("testout_methodMulParams3 | out values: \n");
printVariant( _params3[1]);
printVariant( _params3[0]);
//In Out Parameter ###########################################################################
- OutputDebugString( _T("In Out parameter ###########################################\n\n"));
+ OutputDebugStringA("In Out parameter ###########################################\n\n");
*V_I1REF(&varOutByte)= 5;
- ATLTRACE(_T("testinout_methodByte | in value: %d \n"), *V_I1REF(&varOutByte));
+ ATLTRACE("testinout_methodByte | in value: %d \n", *V_I1REF(&varOutByte));
hr= oletest.InvokeN(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varOutByte, 1, &varRet);
- OutputDebugString(_T("testinout_methodByte | out value: \n"));
+ OutputDebugStringA("testinout_methodByte | out value: \n");
printVariant( varOutByte);
- OutputDebugString(_T("testinout_methodShort | in value= 1000 \n"));
+ OutputDebugStringA("testinout_methodShort | in value= 1000 \n");
*V_UI2REF(&varOutShort)= 1000;
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodShort"), &varOutShort, &varRet);
- OutputDebugString(_T("testinout_methodShort | out value: \n"));
+ OutputDebugStringA("testinout_methodShort | out value: \n");
printVariant( varOutShort);
- OutputDebugString(_T("testinout_methodLong | in value= 10000 \n"));
+ OutputDebugStringA("testinout_methodLong | in value= 10000 \n");
*V_UI4REF(&varOutLong)= 10000;
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodLong"), &varOutLong, &varRet);
- OutputDebugString(_T("testinout_methodLong | out value: \n"));
+ OutputDebugStringA("testinout_methodLong | out value: \n");
printVariant( varOutLong);
*V_R8REF(&varOutDouble)= 3.14;
- ATLTRACE(_T("testinou_methodDouble in value: %f \n"),*V_R8REF(&varOutDouble));
+ ATLTRACE("testinou_methodDouble in value: %f \n",*V_R8REF(&varOutDouble));
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodDouble"), &varOutDouble, &varRet);
- OutputDebugString(_T("testinout_methodDouble | out value: \n"));
+ OutputDebugStringA("testinout_methodDouble | out value: \n");
printVariant( varOutDouble);
SysFreeString( *V_BSTRREF(&varOutString));
*V_BSTRREF(&varOutString)= SysAllocString( L"this is a in string");
- ATLTRACE(_T("testinout_methodString | value: %s \n"), W2T(*V_BSTRREF(&varOutString)));
+ ATLTRACE("testinout_methodString | value: %s \n", W2A(*V_BSTRREF(&varOutString)));
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodString"), &varOutString, &varRet);
- OutputDebugString(_T("testinout_methodString | out value: \n"));
+ OutputDebugStringA("testinout_methodString | out value: \n");
printVariant( varOutString);
CComVariant var1(CComBSTR(L" this is a string in a VARIANT"));
CComVariant outVar1;
outVar1.vt= VT_BYREF | VT_VARIANT;
outVar1.pvarVal= &var1;
- ATLTRACE(_T("testinout_methodAny | parameter: %s\n"), W2T(var1.bstrVal));
+ ATLTRACE("testinout_methodAny | parameter: %s\n", W2A(var1.bstrVal));
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodAny"), &varOutAny, &varRet);
- OutputDebugString(_T("testinout_methodAny | out value: \n"));
+ OutputDebugStringA("testinout_methodAny | out value: \n");
printVariant( varOutAny);
CComPtr< IUnknown > objectIn = unk1;
@@ -460,22 +459,22 @@ HRESULT doTest()
varOutIFace.vt= VT_BYREF | VT_UNKNOWN;
varOutIFace.ppunkVal= &objectIn.p;
(*varOutIFace.ppunkVal)->AddRef();
- OutputDebugString(_T("testinout_methodXInterface | in value: \n"));
+ OutputDebugStringA("testinout_methodXInterface | in value: \n");
printVariant(varOutIFace);
hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodXInterface"), &varOutIFace, &varRet);
- OutputDebugString(_T("testinout_methodXInterface | out value: \n"));
+ OutputDebugStringA("testinout_methodXInterface | out value: \n");
printVariant( varOutIFace);
// Properties ######################################################################
- OutputDebugString( _T(" Properties ###########################################\n\n"));
+ OutputDebugStringA(" Properties ###########################################\n\n");
- OutputDebugString(_T("set property \"AttrByte\" | value"));
+ OutputDebugStringA("set property \"AttrByte\" | value");
//CComVariant propArByte;
//propArByte.vt= VT_ARRAY | VT_I1;
varParam1.parray= (SAFEARRAY*)arByte;
printVariant( varParam1);
hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1);
- OutputDebugString(_T("get property \"AttrByte\" | value:"));
+ OutputDebugStringA("get property \"AttrByte\" | value:");
varRet.Clear();
hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varRet);
printVariant( varRet);
@@ -509,13 +508,13 @@ void printVariant( VARIANT & _var)
double doubleValue;
IUnknown* unkValue;
BSTR bstrValue;
- OutputDebugString( _T("# Array \n"));
+ OutputDebugStringA("# Array \n");
for( long i= 0; i < count; i++)
{
// CComVariant variantValue;
- TCHAR *buf[256];
- wsprintf( (TCHAR*)buf, _T("%d : "), i);
- OutputDebugString( (TCHAR*)buf);
+ CHAR buf[256];
+ wsprintfA( buf, "%d : ", i);
+ OutputDebugStringA( buf);
VARIANT varTemp;
VariantInit( &varTemp);
VARIANT variantValue;
@@ -580,17 +579,17 @@ void printVariant( VARIANT & _var)
}
else
{
- TCHAR buf[256];
+ CHAR buf[256];
switch (var.vt)
{
- case VT_I1: wsprintf( (TCHAR*)buf, _T(" VT_I1: %d \n"), V_I1( &var) );
+ case VT_I1: wsprintfA( buf, " VT_I1: %d \n", V_I1( &var) );
break;
- case VT_UI1: wsprintf( (TCHAR*)buf, _T(" VT_UI1: %d \n"), V_I1( &var) );
+ case VT_UI1: wsprintfA( buf, " VT_UI1: %d \n", V_I1( &var) );
break;
- case VT_I2: wsprintf( (TCHAR*)buf, _T(" VT_I2: %d \n"), V_I2( &var) );
+ case VT_I2: wsprintfA( buf, " VT_I2: %d \n", V_I2( &var) );
break;
- case VT_I4: wsprintf( (TCHAR*)buf, _T(" VT_I4: %d \n"), V_I4( &var) );
+ case VT_I4: wsprintfA( buf, " VT_I4: %d \n", V_I4( &var) );
break;
case VT_R8:
{
@@ -601,7 +600,7 @@ void printVariant( VARIANT & _var)
// double source = 3.1415926535;
// buffer = _ecvt( V_R8(&var), precision, &decimal, &sign );
- sprintf( (TCHAR*)buf, _T(" VT_R8: %f \n"),V_R8( &var) );
+ sprintf( buf, " VT_R8: %f \n",V_R8( &var) );
break;
}
case VT_UNKNOWN:
@@ -610,7 +609,7 @@ void printVariant( VARIANT & _var)
CComDispatchDriver disp( var.punkVal);
CComVariant ret;
hr= disp.GetPropertyByName( static_cast<LPCOLESTR>(L"Name"), &ret);
- wsprintf( (TCHAR*)buf, _T(" VT_UNKNOWN: property \"Name\": %s \n"), W2T(ret.bstrVal));
+ wsprintfA( buf, " VT_UNKNOWN: property \"Name\": %s \n", W2A(ret.bstrVal));
break;
}
case VT_DISPATCH:
@@ -619,9 +618,9 @@ void printVariant( VARIANT & _var)
CComDispatchDriver disp( var.punkVal);
CComVariant ret;
if( SUCCEEDED( hr= disp.GetPropertyByName( static_cast<LPCOLESTR>(L"Name"), &ret)))
- wsprintf( (TCHAR*)buf, _T(" VT_DISPATCH: property \"Name\": %s \n"), W2T(ret.bstrVal));
+ wsprintfA( buf, " VT_DISPATCH: property \"Name\": %s \n", W2A(ret.bstrVal));
else
- wsprintf( (TCHAR*)buf, _T(" VT_DISPATCH \n"));
+ wsprintfA( buf, " VT_DISPATCH \n");
break;
}
@@ -629,16 +628,16 @@ void printVariant( VARIANT & _var)
case VT_BSTR:
{
- TCHAR* str= W2T( var.bstrVal);
- wsprintf( (TCHAR*)buf, _T(" VT_BSTR: %s \n"), str);
+ CHAR* str= W2A( var.bstrVal);
+ wsprintfA( buf, " VT_BSTR: %s \n", str);
}
break;
default:
- wsprintf( (TCHAR*)buf, _T("\n"));
+ wsprintfA( buf, "\n");
}
- OutputDebugString( (TCHAR*) buf);
+ OutputDebugStringA( buf);
}
return;
diff --git a/extensions/test/ole/cppToUno/testcppuno.cxx b/extensions/test/ole/cppToUno/testcppuno.cxx
index 0b06d694cde3..563e2d0acc06 100644
--- a/extensions/test/ole/cppToUno/testcppuno.cxx
+++ b/extensions/test/ole/cppToUno/testcppuno.cxx
@@ -24,7 +24,6 @@
#endif
#include <windows.h>
#include <comdef.h>
-#include <tchar.h>
#include <atlbase.h>
#include <atlcom.h>
#include <stdio.h>
@@ -49,12 +48,12 @@ bool incrementMultidimensionalIndex(
const sal_Int32 * parDimensionLengths,
sal_Int32 * parMultidimensionalIndex);
-int SAL_CALL _tmain( int /*argc*/, _TCHAR * /*argv[]*/ )
+int SAL_CALL main( int /*argc*/, char** /*argv*/ )
{
HRESULT hr;
if( FAILED( hr=CoInitialize(NULL)))
{
- _tprintf(_T("CoInitialize failed \n"));
+ printf("CoInitialize failed \n");
return -1;
}
@@ -62,8 +61,8 @@ int SAL_CALL _tmain( int /*argc*/, _TCHAR * /*argv[]*/ )
if( FAILED(hr=doTest()))
{
_com_error err( hr);
- const TCHAR * errMsg= err.ErrorMessage();
- MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
+ const CHAR * errMsg= err.ErrorMessage();
+ MessageBoxA( NULL, errMsg, "Test failed", MB_ICONERROR);
}
CoUninitialize();
diff --git a/extensions/test/ole/cpptest/cpptest.cxx b/extensions/test/ole/cpptest/cpptest.cxx
index 2fd41394e923..d97489847399 100644
--- a/extensions/test/ole/cpptest/cpptest.cxx
+++ b/extensions/test/ole/cpptest/cpptest.cxx
@@ -25,7 +25,6 @@
#endif
#pragma warning(disable: 4917)
#include <comdef.h>
-#include <tchar.h>
#include <atlbase.h>
#include <atlcom.h>
@@ -36,15 +35,15 @@ int main(int /*argc*/, char** /*argv*/)
HRESULT hr;
if( FAILED( hr=CoInitialize(NULL)))
{
- _tprintf(_T("CoInitialize failed \n"));
+ printf("CoInitialize failed \n");
return -1;
}
if( FAILED(hr=doTest()))
{
_com_error err( hr);
- const TCHAR * errMsg= err.ErrorMessage();
- MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
+ const CHAR * errMsg= err.ErrorMessage();
+ MessageBoxA( NULL, errMsg, "Test failed", MB_ICONERROR);
}
CoUninitialize();
diff --git a/extensions/test/ole/unoTocomCalls/Test/StdAfx.h b/extensions/test/ole/unoTocomCalls/Test/StdAfx.h
index 93e2da1c0c88..e60a425b2502 100644
--- a/extensions/test/ole/unoTocomCalls/Test/StdAfx.h
+++ b/extensions/test/ole/unoTocomCalls/Test/StdAfx.h
@@ -33,7 +33,6 @@
#include <stdio.h>
#include <windows.h>
#include <comdef.h>
-#include <tchar.h>
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h
index 8124560e5e5f..d7262d1ec595 100644
--- a/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h
@@ -39,7 +39,6 @@
//something, but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
-#include <tchar.h>
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
diff --git a/include/systools/win32/qswin32.h b/include/systools/win32/qswin32.h
index 3cee187e6818..d9c386e17bdd 100644
--- a/include/systools/win32/qswin32.h
+++ b/include/systools/win32/qswin32.h
@@ -20,29 +20,9 @@
#ifndef INCLUDED_SYSTOOLS_WIN32_QSWIN32_H
#define INCLUDED_SYSTOOLS_WIN32_QSWIN32_H
-#define QUICKSTART_CLASSNAMEA "LO Listener Class"
-#define QUICKSTART_WINDOWNAMEA "LO Listener Window"
-#define SHUTDOWN_QUICKSTART_MESSAGEA "LO KillTray"
-
-#define QUICKSTART_CLASSNAMEW L##QUICKSTART_CLASSNAMEA
-#define QUICKSTART_WINDOWNAMEW L##QUICKSTART_WINDOWNAMEA
-#define SHUTDOWN_QUICKSTART_MESSAGEW L##SHUTDOWN_QUICKSTART_MESSAGEA
-
-#ifdef UNICODE
-# define QUICKSTART_CLASSNAME QUICKSTART_CLASSNAMEW
-# define QUICKSTART_WINDOWNAME QUICKSTART_WINDOWNAMEW
-# define SHUTDOWN_QUICKSTART_MESSAGE SHUTDOWN_QUICKSTART_MESSAGEW
-# ifndef FindWindow
-# define FindWindow FindWindowW
-# endif
-#else
-# define QUICKSTART_CLASSNAME QUICKSTART_CLASSNAMEA
-# define QUICKSTART_WINDOWNAME QUICKSTART_WINDOWNAMEA
-# define SHUTDOWN_QUICKSTART_MESSAGE SHUTDOWN_QUICKSTART_MESSAGEA
-# ifndef FindWindow
-# define FindWindow FindWindowA
-# endif
-#endif
+#define QUICKSTART_CLASSNAME L"LO Listener Class"
+#define QUICKSTART_WINDOWNAME L"LO Listener Window"
+#define SHUTDOWN_QUICKSTART_MESSAGE L"LO KillTray"
#endif // INCLUDED_SYSTOOLS_WIN32_QSWIN32_H
diff --git a/sal/qa/osl/file/osl_File_Const.h b/sal/qa/osl/file/osl_File_Const.h
index 1d3b0bdc5b97..ac9c7aab0a52 100644
--- a/sal/qa/osl/file/osl_File_Const.h
+++ b/sal/qa/osl/file/osl_File_Const.h
@@ -83,7 +83,6 @@ const sal_Char pBuffer_Blank[] = "";
#endif
#if defined(_WIN32) // Windows
-# include <tchar.h>
# include <io.h>
# define PATH_MAX MAX_PATH
# define TEST_PLATFORM "c:/"
diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx
index 06709c9c6677..b7997209bd09 100644
--- a/sal/qa/osl/process/osl_process.cxx
+++ b/sal/qa/osl/process/osl_process.cxx
@@ -43,13 +43,7 @@
#define RUNNING_ON_VALGRIND false
#endif
-#if defined(_WIN32) // Windows
-#if !defined WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-#endif
-# include <windows.h>
-# include <tchar.h>
-#else
+#if !defined(_WIN32) // Windows
#include <unistd.h>
#endif
diff --git a/sal/qa/osl/process/osl_process_child.cxx b/sal/qa/osl/process/osl_process_child.cxx
index 36729ee1b968..90d4d6dc4eb0 100644
--- a/sal/qa/osl/process/osl_process_child.cxx
+++ b/sal/qa/osl/process/osl_process_child.cxx
@@ -18,11 +18,8 @@
*/
#if defined(_WIN32) // Windows
-# define UNICODE
-# define _UNICODE
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
-# include <tchar.h>
#else
# include <unistd.h>
#endif
@@ -55,28 +52,26 @@ void wait_for_seconds(char* time)
#ifdef _WIN32
-void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size)
+void w_to_a(LPCWSTR strW, LPSTR strA, DWORD size)
{
- LPCWSTR strW = reinterpret_cast<LPCWSTR>(_strW);
WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, size, nullptr, nullptr);
}
void dump_env(char* file_path)
{
- LPTSTR env = reinterpret_cast<LPTSTR>(
- GetEnvironmentStrings());
- LPTSTR p = env;
+ LPWSTR env = GetEnvironmentStringsW();
+ LPWSTR p = env;
std::ofstream file(file_path);
char buffer[32767];
- while (size_t l = _tcslen(reinterpret_cast<wchar_t*>(p)))
+ while (size_t l = wcslen(p))
{
w_to_a(p, buffer, sizeof(buffer));
file << buffer << '\0';
p += l + 1;
}
- FreeEnvironmentStrings(env);
+ FreeEnvironmentStringsW(env);
}
#else
void dump_env(char* file_path)
diff --git a/setup_native/source/win32/customactions/quickstarter/shutdown_quickstart.cxx b/setup_native/source/win32/customactions/quickstarter/shutdown_quickstart.cxx
index 7a841bdbe221..f3ec02a7772b 100644
--- a/setup_native/source/win32/customactions/quickstarter/shutdown_quickstart.cxx
+++ b/setup_native/source/win32/customactions/quickstarter/shutdown_quickstart.cxx
@@ -24,11 +24,11 @@
static BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
{
MSIHANDLE hMSI = static_cast< MSIHANDLE >( lParam );
- CHAR szClassName[sizeof(QUICKSTART_CLASSNAMEA) + 1];
+ WCHAR szClassName[sizeof(QUICKSTART_CLASSNAME)/sizeof(WCHAR) + 1];
- int nCharsCopied = GetClassNameA( hWnd, szClassName, sizeof( szClassName ) );
+ int nCharsCopied = GetClassNameW( hWnd, szClassName, sizeof(szClassName)/sizeof(szClassName[0]) );
- if ( nCharsCopied && !_stricmp( QUICKSTART_CLASSNAMEA, szClassName ) )
+ if ( nCharsCopied && !_wcsicmp( QUICKSTART_CLASSNAME, szClassName ) )
{
DWORD dwProcessId;
@@ -39,10 +39,10 @@ static BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
if ( !_wcsnicmp( sImagePath.c_str(), sOfficeImageDir.c_str(), sOfficeImageDir.length() ) )
{
- UINT uMsgShutdownQuickstart = RegisterWindowMessageA( SHUTDOWN_QUICKSTART_MESSAGEA );
+ UINT uMsgShutdownQuickstart = RegisterWindowMessageW( SHUTDOWN_QUICKSTART_MESSAGE );
if ( uMsgShutdownQuickstart )
- SendMessageA( hWnd, uMsgShutdownQuickstart, 0, 0 );
+ SendMessageW( hWnd, uMsgShutdownQuickstart, 0, 0 );
HANDLE hProcess = OpenProcess( SYNCHRONIZE, FALSE, dwProcessId );
diff --git a/setup_native/source/win32/customactions/regactivex/regactivex.cxx b/setup_native/source/win32/customactions/regactivex/regactivex.cxx
index b7e4cedf6a8c..00739ac4f9c6 100644
--- a/setup_native/source/win32/customactions/regactivex/regactivex.cxx
+++ b/setup_native/source/win32/customactions/regactivex/regactivex.cxx
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define UNICODE
-
#ifdef _MSC_VER
#pragma warning(push, 1) /* disable warnings within system headers */
#endif
@@ -41,7 +39,7 @@
#define WRITER_COMPONENT 16
#define MATH_COMPONENT 32
-typedef int ( __stdcall * DllNativeRegProc ) ( int, BOOL, BOOL, const char* );
+typedef int ( __stdcall * DllNativeRegProc ) ( int, BOOL, BOOL, const wchar_t* );
typedef int ( __stdcall * DllNativeUnregProc ) ( int, BOOL, BOOL );
BOOL UnicodeEquals( wchar_t const * pStr1, wchar_t const * pStr2 )
@@ -61,34 +59,20 @@ BOOL UnicodeEquals( wchar_t const * pStr1, wchar_t const * pStr2 )
}
-char* UnicodeToAnsiString( wchar_t const * pUniString )
-{
- int len = WideCharToMultiByte(
- CP_ACP, 0, pUniString, -1, nullptr, 0, nullptr, nullptr );
-
- char* buff = static_cast<char*>( malloc( len ) );
-
- WideCharToMultiByte(
- CP_ACP, 0, pUniString, -1, buff, len, nullptr, nullptr );
-
- return buff;
-}
-
-
-void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit )
+void RegisterActiveXNative( const wchar_t* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit )
{
- HINSTANCE hModule = LoadLibraryExA( pActiveXPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
+ HINSTANCE hModule = LoadLibraryExW( pActiveXPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
if( hModule )
{
DllNativeRegProc pNativeProc = reinterpret_cast<DllNativeRegProc>(GetProcAddress( hModule, "DllRegisterServerNative" ));
if( pNativeProc!=nullptr )
{
- int nLen = strlen( pActiveXPath );
+ int nLen = wcslen( pActiveXPath );
int nRemoveLen = strlen( "\\so_activex.dll" );
if ( nLen > nRemoveLen )
{
- char* pProgramPath = static_cast<char*>( malloc( nLen - nRemoveLen + 1 ) );
- strncpy( pProgramPath, pActiveXPath, nLen - nRemoveLen );
+ wchar_t* pProgramPath = static_cast<wchar_t*>( malloc( (nLen - nRemoveLen + 1) * sizeof(wchar_t) ) );
+ wcsncpy( pProgramPath, pActiveXPath, nLen - nRemoveLen );
pProgramPath[ nLen - nRemoveLen ] = 0;
( *pNativeProc )( nMode, InstallForAllUser, InstallFor64Bit, pProgramPath );
@@ -102,9 +86,9 @@ void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallFor
}
-void UnregisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit )
+void UnregisterActiveXNative( const wchar_t* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit )
{
- HINSTANCE hModule = LoadLibraryExA( pActiveXPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
+ HINSTANCE hModule = LoadLibraryExW( pActiveXPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
if( hModule )
{
DllNativeUnregProc pNativeProc = reinterpret_cast<DllNativeUnregProc>(GetProcAddress( hModule, "DllUnregisterServerNative" ));
@@ -135,27 +119,20 @@ BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
}
-BOOL GetActiveXControlPath( MSIHANDLE hMSI, char** ppActiveXPath )
+BOOL GetActiveXControlPath( MSIHANDLE hMSI, wchar_t** ppActiveXPath )
{
wchar_t* pProgPath = nullptr;
if ( GetMsiPropW( hMSI, L"INSTALLLOCATION", &pProgPath ) && pProgPath )
- {
- char* pCharProgPath = UnicodeToAnsiString( pProgPath );
-
- if ( pCharProgPath )
- {
- int nLen = strlen( pCharProgPath );
- *ppActiveXPath = static_cast<char*>( malloc( nLen + 23 ) );
- strncpy( *ppActiveXPath, pCharProgPath, nLen );
- strncpy( (*ppActiveXPath) + nLen, "program\\so_activex.dll", 22 );
- (*ppActiveXPath)[nLen+22] = 0;
-
- free( pCharProgPath );
+ {
+ int nLen = wcslen( pProgPath );
+ *ppActiveXPath = static_cast<wchar_t*>( malloc( (nLen + 23) * sizeof(wchar_t) ) );
+ wcsncpy( *ppActiveXPath, pProgPath, nLen );
+ wcsncpy( (*ppActiveXPath) + nLen, L"program\\so_activex.dll", 22 );
+ (*ppActiveXPath)[nLen+22] = 0;
- return TRUE;
- }
+ free(pProgPath);
- free( pProgPath );
+ return TRUE;
}
return FALSE;
@@ -172,7 +149,7 @@ BOOL GetDelta( MSIHANDLE hMSI, int& nOldInstallMode, int& nInstallMode, int& nDe
INSTALLSTATE current_state;
INSTALLSTATE future_state;
- if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Wrt_Bin", &current_state, &future_state ) )
+ if ( ERROR_SUCCESS == MsiGetFeatureStateW( hMSI, L"gm_p_Wrt_Bin", &current_state, &future_state ) )
{
// analyze writer installation mode
if ( current_state == INSTALLSTATE_LOCAL )
@@ -189,7 +166,7 @@ BOOL GetDelta( MSIHANDLE hMSI, int& nOldInstallMode, int& nInstallMode, int& nDe
// assert( FALSE );
}
- if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Calc_Bin", &current_state, &future_state ) )
+ if ( ERROR_SUCCESS == MsiGetFeatureStateW( hMSI, L"gm_p_Calc_Bin", &current_state, &future_state ) )
{
// analyze calc installation mode
if ( current_state == INSTALLSTATE_LOCAL )
@@ -206,7 +183,7 @@ BOOL GetDelta( MSIHANDLE hMSI, int& nOldInstallMode, int& nInstallMode, int& nDe
// assert( FALSE );
}
- if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Draw_Bin", &current_state, &future_state ) )
+ if ( ERROR_SUCCESS == MsiGetFeatureStateW( hMSI, L"gm_p_Draw_Bin", &current_state, &future_state ) )
{
// analyze draw installation mode
if ( current_state == INSTALLSTATE_LOCAL )
@@ -223,7 +200,7 @@ BOOL GetDelta( MSIHANDLE hMSI, int& nOldInstallMode, int& nInstallMode, int& nDe
// assert( FALSE );
}
- if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Impress_Bin", &current_state, &future_state ) )
+ if ( ERROR_SUCCESS == MsiGetFeatureStateW( hMSI, L"gm_p_Impress_Bin", &current_state, &future_state ) )
{
// analyze impress installation mode
if ( current_state == INSTALLSTATE_LOCAL )
@@ -240,7 +217,7 @@ BOOL GetDelta( MSIHANDLE hMSI, int& nOldInstallMode, int& nInstallMode, int& nDe
// assert( FALSE );
}
- if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_p_Math_Bin", &current_state, &future_state ) )
+ if ( ERROR_SUCCESS == MsiGetFeatureStateW( hMSI, L"gm_p_Math_Bin", &current_state, &future_state ) )
{
// analyze math installation mode
if ( current_state == INSTALLSTATE_LOCAL )
@@ -293,7 +270,7 @@ extern "C" UINT __stdcall InstallActiveXControl( MSIHANDLE hMSI )
INSTALLSTATE current_state;
INSTALLSTATE future_state;
- if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_o_Activexcontrol", &current_state, &future_state ) )
+ if ( ERROR_SUCCESS == MsiGetFeatureStateW( hMSI, L"gm_o_Activexcontrol", &current_state, &future_state ) )
{
int nOldInstallMode = 0;
int nInstallMode = 0;
@@ -301,7 +278,7 @@ extern "C" UINT __stdcall InstallActiveXControl( MSIHANDLE hMSI )
BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI );
BOOL bInstallFor64Bit = MakeInstallFor64Bit( hMSI );
- char* pActiveXPath = nullptr;
+ wchar_t* pActiveXPath = nullptr;
if ( GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath
&& GetDelta( hMSI, nOldInstallMode, nInstallMode, nDeinstallMode ) )
{
@@ -340,9 +317,9 @@ extern "C" UINT __stdcall DeinstallActiveXControl( MSIHANDLE hMSI )
INSTALLSTATE current_state;
INSTALLSTATE future_state;
- if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_o_Activexcontrol", &current_state, &future_state ) )
+ if ( ERROR_SUCCESS == MsiGetFeatureStateW( hMSI, L"gm_o_Activexcontrol", &current_state, &future_state ) )
{
- char* pActiveXPath = nullptr;
+ wchar_t* pActiveXPath = nullptr;
if ( current_state == INSTALLSTATE_LOCAL && GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath )
{
BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI );
diff --git a/setup_native/source/win32/customactions/tools/checkversion.cxx b/setup_native/source/win32/customactions/tools/checkversion.cxx
index 2ad7267b571f..8de46807a579 100644
--- a/setup_native/source/win32/customactions/tools/checkversion.cxx
+++ b/setup_native/source/win32/customactions/tools/checkversion.cxx
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define UNICODE
-
#ifdef _MSC_VER
#pragma warning(push,1) // disable warnings within system headers
#endif
diff --git a/setup_native/source/win32/customactions/tools/seterror.cxx b/setup_native/source/win32/customactions/tools/seterror.cxx
index d7aa3639fb00..5e06a14a98e7 100644
--- a/setup_native/source/win32/customactions/tools/seterror.cxx
+++ b/setup_native/source/win32/customactions/tools/seterror.cxx
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define UNICODE
-
#ifdef _MSC_VER
#pragma warning(push,1) // disable warnings within system headers
#endif
diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx
index d0fa1b9dccb1..f384339f25f2 100644
--- a/sfx2/source/appl/shutdowniconw32.cxx
+++ b/sfx2/source/appl/shutdowniconw32.cxx
@@ -16,6 +16,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#if !defined WINVER
+#define WINVER 0x0400
+#endif
+
#include <sal/macros.h>
// necessary to include system headers without warnings
@@ -45,8 +49,8 @@ using ::com::sun::star::uno::Sequence;
using ::com::sun::star::beans::PropertyValue;
-#define EXECUTER_WINDOWCLASS "SO Executer Class"
-#define EXECUTER_WINDOWNAME "SO Executer Window"
+#define EXECUTER_WINDOWCLASS L"SO Executer Class"
+#define EXECUTER_WINDOWNAME L"SO Executer Window"
#define ID_QUICKSTART 1
@@ -121,7 +125,7 @@ static void addMenuItem( HMENU hMenu, UINT id, UINT iconId, const OUString& text
mi.fType=MFT_STRING;
mi.fState=MFS_ENABLED;
mi.wID = id;
- mi.dwTypeData = reinterpret_cast<wchar_t *>(
+ mi.dwTypeData = SAL_W(
const_cast<sal_Unicode *>(text.getStr()));
mi.cch = text.getLength();
}
@@ -244,11 +248,11 @@ static void addTaskbarIcon( HWND hWnd )
// add taskbar icon
NOTIFYICONDATAW nid;
- nid.hIcon = static_cast<HICON>(LoadImageA( GetModuleHandle( nullptr ), MAKEINTRESOURCE( ICON_LO_DEFAULT ),
+ nid.hIcon = static_cast<HICON>(LoadImageW( GetModuleHandleW( nullptr ), MAKEINTRESOURCEW( ICON_LO_DEFAULT ),
IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ),
LR_DEFAULTCOLOR | LR_SHARED ));
- wcsncpy( nid.szTip, reinterpret_cast<LPCWSTR>(strTip.getStr()), 64 );
+ wcsncpy( nid.szTip, SAL_W(strTip.getStr()), 64 );
nid.cbSize = sizeof(nid);
nid.hWnd = hWnd;
@@ -273,8 +277,8 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
{
// request notification when taskbar is recreated
// we then have to add our icon again
- s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
- s_uMsgKillTray = RegisterWindowMessage( SHUTDOWN_QUICKSTART_MESSAGE );
+ s_uTaskbarRestart = RegisterWindowMessageW(L"TaskbarCreated");
+ s_uMsgKillTray = RegisterWindowMessageW( SHUTDOWN_QUICKSTART_MESSAGE );
// create the menu
if( !popupMenu )
@@ -303,7 +307,7 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
{
case WM_LBUTTONDBLCLK:
{
- BOOL const ret = PostMessage(aExecuterWindow, WM_COMMAND, IDM_TEMPLATE, reinterpret_cast<LPARAM>(hWnd));
+ BOOL const ret = PostMessageW(aExecuterWindow, WM_COMMAND, IDM_TEMPLATE, reinterpret_cast<LPARAM>(hWnd));
SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!");
break;
}
@@ -348,7 +352,7 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
break;
}
- BOOL const ret2 = PostMessage(aExecuterWindow, WM_COMMAND, m, reinterpret_cast<LPARAM>(hWnd));
+ BOOL const ret2 = PostMessageW(aExecuterWindow, WM_COMMAND, m, reinterpret_cast<LPARAM>(hWnd));
SAL_WARN_IF(0 == ret2, "sfx.appl", "ERROR: PostMessage() failed!");
}
break;
@@ -358,7 +362,7 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
deleteSystrayMenu( popupMenu );
// We don't need the Systray Thread anymore
PostQuitMessage( 0 );
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
default:
if( uMsg == s_uTaskbarRestart )
{
@@ -374,11 +378,11 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
nid.uID = ID_QUICKSTART;
Shell_NotifyIconA(NIM_DELETE, &nid);
- BOOL const ret = PostMessage(aExecuterWindow, WM_COMMAND, IDM_EXIT, reinterpret_cast<LPARAM>(hWnd));
+ BOOL const ret = PostMessageW(aExecuterWindow, WM_COMMAND, IDM_EXIT, reinterpret_cast<LPARAM>(hWnd));
SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!");
}
else
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
return 0;
}
@@ -435,7 +439,7 @@ LRESULT CALLBACK executerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
break;
case WM_DESTROY:
default:
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
return 0;
}
@@ -445,26 +449,26 @@ DWORD WINAPI SystrayThread( LPVOID /*lpParam*/ )
{
osl_setThreadName("SystrayThread");
- aListenerWindow = CreateWindowExA(0,
- QUICKSTART_CLASSNAME, // registered class name
- QUICKSTART_WINDOWNAME, // window name
- 0, // window style
- CW_USEDEFAULT, // horizontal position of window
- CW_USEDEFAULT, // vertical position of window
- CW_USEDEFAULT, // window width
- CW_USEDEFAULT, // window height
- nullptr, // handle to parent or owner window
- nullptr, // menu handle or child identifier
- GetModuleHandle( nullptr ), // handle to application instance
- nullptr // window-creation data
+ aListenerWindow = CreateWindowExW(0,
+ QUICKSTART_CLASSNAME, // registered class name
+ QUICKSTART_WINDOWNAME, // window name
+ 0, // window style
+ CW_USEDEFAULT, // horizontal position of window
+ CW_USEDEFAULT, // vertical position of window
+ CW_USEDEFAULT, // window width
+ CW_USEDEFAULT, // window height
+ nullptr, // handle to parent or owner window
+ nullptr, // menu handle or child identifier
+ GetModuleHandleW( nullptr ), // handle to application instance
+ nullptr // window-creation data
);
MSG msg;
- while ( GetMessage( &msg, nullptr, 0, 0 ) )
+ while ( GetMessageW( &msg, nullptr, 0, 0 ) )
{
TranslateMessage( &msg );
- DispatchMessage( &msg );
+ DispatchMessageW( &msg );
}
return msg.wParam; // Exit code of WM_QUIT
@@ -475,13 +479,13 @@ void win32_init_sys_tray()
{
if ( ShutdownIcon::IsQuickstarterInstalled() )
{
- WNDCLASSEXA listenerClass;
- listenerClass.cbSize = sizeof(WNDCLASSEX);
+ WNDCLASSEXW listenerClass;
+ listenerClass.cbSize = sizeof(listenerClass);
listenerClass.style = 0;
listenerClass.lpfnWndProc = listenerWndProc;
listenerClass.cbClsExtra = 0;
listenerClass.cbWndExtra = 0;
- listenerClass.hInstance = GetModuleHandle( nullptr );
+ listenerClass.hInstance = GetModuleHandleW( nullptr );
listenerClass.hIcon = nullptr;
listenerClass.hCursor = nullptr;
listenerClass.hbrBackground = nullptr;
@@ -489,15 +493,15 @@ void win32_init_sys_tray()
listenerClass.lpszClassName = QUICKSTART_CLASSNAME;
listenerClass.hIconSm = nullptr;
- RegisterClassExA(&listenerClass);
+ RegisterClassExW(&listenerClass);
- WNDCLASSEXA executerClass;
- executerClass.cbSize = sizeof(WNDCLASSEX);
+ WNDCLASSEXW executerClass;
+ executerClass.cbSize = sizeof(executerClass);
executerClass.style = 0;
executerClass.lpfnWndProc = executerWndProc;
executerClass.cbClsExtra = 0;
executerClass.cbWndExtra = 0;
- executerClass.hInstance = GetModuleHandle( nullptr );
+ executerClass.hInstance = GetModuleHandleW( nullptr );
executerClass.hIcon = nullptr;
executerClass.hCursor = nullptr;
executerClass.hbrBackground = nullptr;
@@ -505,20 +509,20 @@ void win32_init_sys_tray()
executerClass.lpszClassName = EXECUTER_WINDOWCLASS;
executerClass.hIconSm = nullptr;
- RegisterClassExA( &executerClass );
-
- aExecuterWindow = CreateWindowExA(0,
- EXECUTER_WINDOWCLASS, // registered class name
- EXECUTER_WINDOWNAME, // window name
- 0, // window style
- CW_USEDEFAULT, // horizontal position of window
- CW_USEDEFAULT, // vertical position of window
- CW_USEDEFAULT, // window width
- CW_USEDEFAULT, // window height
- nullptr, // handle to parent or owner window
- nullptr, // menu handle or child identifier
- GetModuleHandle( nullptr ), // handle to application instance
- nullptr // window-creation data
+ RegisterClassExW( &executerClass );
+
+ aExecuterWindow = CreateWindowExW(0,
+ EXECUTER_WINDOWCLASS, // registered class name
+ EXECUTER_WINDOWNAME, // window name
+ 0, // window style
+ CW_USEDEFAULT, // horizontal position of window
+ CW_USEDEFAULT, // vertical position of window
+ CW_USEDEFAULT, // window width
+ CW_USEDEFAULT, // window height
+ nullptr, // handle to parent or owner window
+ nullptr, // menu handle or child identifier
+ GetModuleHandleW( nullptr ), // handle to application instance
+ nullptr // window-creation data
);
DWORD dwThreadId;
@@ -538,8 +542,8 @@ void win32_shutdown_sys_tray()
DestroyWindow( aExecuterWindow );
aExecuterWindow = nullptr;
}
- UnregisterClassA( QUICKSTART_CLASSNAME, GetModuleHandle( nullptr ) );
- UnregisterClassA( EXECUTER_WINDOWCLASS, GetModuleHandle( nullptr ) );
+ UnregisterClassW( QUICKSTART_CLASSNAME, GetModuleHandleW( nullptr ) );
+ UnregisterClassW( EXECUTER_WINDOWCLASS, GetModuleHandleW( nullptr ) );
}
}
@@ -550,18 +554,18 @@ void OnMeasureItem(HWND hwnd, LPMEASUREITEMSTRUCT lpmis)
HDC hdc = GetDC(hwnd);
SIZE size;
- NONCLIENTMETRICS ncm;
+ NONCLIENTMETRICSW ncm;
memset(&ncm, 0, sizeof(ncm));
ncm.cbSize = sizeof(ncm);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
+ SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
// Assume every menu item can be default and printed bold
ncm.lfMenuFont.lfWeight = FW_BOLD;
- HFONT hfntOld = static_cast<HFONT>(SelectObject(hdc, CreateFontIndirect( &ncm.lfMenuFont )));
+ HFONT hfntOld = static_cast<HFONT>(SelectObject(hdc, CreateFontIndirectW( &ncm.lfMenuFont )));
- GetTextExtentPoint32W(hdc, reinterpret_cast<LPCWSTR>(pMyItem->text.getStr()),
+ GetTextExtentPoint32W(hdc, SAL_W(pMyItem->text.getStr()),
pMyItem->text.getLength(), &size);
lpmis->itemWidth = size.cx + 4 + GetSystemMetrics( SM_CXSMICON );
@@ -611,11 +615,11 @@ void OnDrawItem(HWND /*hwnd*/, LPDRAWITEMSTRUCT lpdis)
int cx = GetSystemMetrics( SM_CXSMICON );
int cy = GetSystemMetrics( SM_CYSMICON );
HICON hIcon( nullptr );
- HMODULE hModule( GetModuleHandle( nullptr ) );
+ HMODULE hModule( GetModuleHandleW( nullptr ) );
if ( pMyItem->module.getLength() > 0 )
{
- LPCWSTR pModuleName = reinterpret_cast<LPCWSTR>( pMyItem->module.getStr() );
+ LPCWSTR pModuleName = SAL_W( pMyItem->module.getStr() );
hModule = GetModuleHandleW( pModuleName );
if ( hModule == nullptr )
{
@@ -638,21 +642,21 @@ void OnDrawItem(HWND /*hwnd*/, LPDRAWITEMSTRUCT lpdis)
x += cx + 4; // space for icon
aRect.left = x;
- NONCLIENTMETRICS ncm;
+ NONCLIENTMETRICSW ncm;
memset(&ncm, 0, sizeof(ncm));
ncm.cbSize = sizeof(ncm);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
+ SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
// Print default menu entry with bold font
if ( lpdis->itemState & ODS_DEFAULT )
ncm.lfMenuFont.lfWeight = FW_BOLD;
- hfntOld = static_cast<HFONT>(SelectObject(lpdis->hDC, CreateFontIndirect( &ncm.lfMenuFont )));
+ hfntOld = static_cast<HFONT>(SelectObject(lpdis->hDC, CreateFontIndirectW( &ncm.lfMenuFont )));
SIZE size;
- GetTextExtentPointW( lpdis->hDC, reinterpret_cast<LPCWSTR>(pMyItem->text.getStr()), pMyItem->text.getLength(), &size );
+ GetTextExtentPointW( lpdis->hDC, SAL_W(pMyItem->text.getStr()), pMyItem->text.getLength(), &size );
DrawStateW( lpdis->hDC, nullptr, nullptr, reinterpret_cast<LPARAM>(pMyItem->text.getStr()), (WPARAM)0, aRect.left, aRect.top + (height - size.cy)/2, 0, 0, DST_TEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) );
@@ -693,7 +697,7 @@ static OUString SHGetSpecialFolder( int nFolderID )
lpFolderA = ALLOC( WCHAR, 16000 );
SHGetPathFromIDListW( pidl, lpFolderA );
- aFolder = OUString( reinterpret_cast<const sal_Unicode*>(lpFolderA) );
+ aFolder = SAL_U( lpFolderA );
FREE( lpFolderA );
SHFree_( pidl );
@@ -709,7 +713,7 @@ OUString ShutdownIcon::GetAutostartFolderNameW32()
static HRESULT WINAPI SHCoCreateInstance( LPVOID lpszReserved, REFCLSID clsid, LPUNKNOWN pUnkUnknown, REFIID iid, LPVOID *ppv )
{
HRESULT hResult = E_NOTIMPL;
- HMODULE hModShell = GetModuleHandle( "SHELL32" );
+ HMODULE hModShell = GetModuleHandleW( L"SHELL32" );
if ( hModShell != nullptr )
{
@@ -727,9 +731,9 @@ BOOL CreateShortcut( const OUString& rAbsObject, const OUString& rAbsObjectPath,
const OUString& rAbsShortcut, const OUString& rDescription, const OUString& rParameter )
{
HRESULT hres;
- IShellLink* psl;
+ IShellLinkW* psl;
CLSID clsid_ShellLink = CLSID_ShellLink;
- CLSID clsid_IShellLink = IID_IShellLink;
+ CLSID clsid_IShellLink = IID_IShellLinkW;
hres = CoCreateInstance( clsid_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
clsid_IShellLink, reinterpret_cast<void**>(&psl) );
@@ -739,11 +743,11 @@ BOOL CreateShortcut( const OUString& rAbsObject, const OUString& rAbsObjectPath,
if( SUCCEEDED(hres) )
{
IPersistFile* ppf;
- psl->SetPath( OUStringToOString(rAbsObject, osl_getThreadTextEncoding()).getStr() );
- psl->SetWorkingDirectory( OUStringToOString(rAbsObjectPath, osl_getThreadTextEncoding()).getStr() );
- psl->SetDescription( OUStringToOString(rDescription, osl_getThreadTextEncoding()).getStr() );
+ psl->SetPath( SAL_W(rAbsObject.getStr()) );
+ psl->SetWorkingDirectory( SAL_W(rAbsObjectPath.getStr()) );
+ psl->SetDescription( SAL_W(rDescription.getStr()) );
if( rParameter.getLength() )
- psl->SetArguments( OUStringToOString(rParameter, osl_getThreadTextEncoding()).getStr() );
+ psl->SetArguments( SAL_W(rParameter.getStr()) );
CLSID clsid_IPersistFile = IID_IPersistFile;
hres = psl->QueryInterface( clsid_IPersistFile, reinterpret_cast<void**>(&ppf) );
@@ -782,7 +786,7 @@ bool ShutdownIcon::IsQuickstarterInstalled()
wchar_t aPath[_MAX_PATH];
GetModuleFileNameW( nullptr, aPath, _MAX_PATH-1);
- OUString aOfficepath( reinterpret_cast<const sal_Unicode*>(aPath) );
+ OUString aOfficepath( SAL_U(aPath) );
int i = aOfficepath.lastIndexOf('\\');
if( i != -1 )
aOfficepath = aOfficepath.copy(0, i);
@@ -790,7 +794,7 @@ bool ShutdownIcon::IsQuickstarterInstalled()
OUString quickstartExe(aOfficepath);
quickstartExe += "\\quickstart.exe";
- return FileExistsW( reinterpret_cast<LPCWSTR>(quickstartExe.getStr()) );
+ return FileExistsW( SAL_W(quickstartExe.getStr()) );
}
void ShutdownIcon::EnableAutostartW32( const OUString &aShortcut )
@@ -798,7 +802,7 @@ void ShutdownIcon::EnableAutostartW32( const OUString &aShortcut )
wchar_t aPath[_MAX_PATH];
GetModuleFileNameW( nullptr, aPath, _MAX_PATH-1);
- OUString aOfficepath( reinterpret_cast<const sal_Unicode*>(aPath) );
+ OUString aOfficepath( SAL_U(aPath) );
int i = aOfficepath.lastIndexOf('\\');
if( i != -1 )
aOfficepath = aOfficepath.copy(0, i);
diff --git a/shell/inc/config.hxx b/shell/inc/config.hxx
index eda0cfb06f9f..a888745ba5cd 100644
--- a/shell/inc/config.hxx
+++ b/shell/inc/config.hxx
@@ -24,8 +24,6 @@
#pragma warning (disable : 4786 4503 4917)
#endif
-#include <tchar.h>
-
#ifdef _AMD64_
#define MODULE_NAME L"shlxthdl_x64.dll"
#else
diff --git a/shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx b/shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx
index caaf1e5222cc..156eb49f017c 100644
--- a/shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx
+++ b/shell/source/win32/shlxthandler/propsheets/listviewbuilder.cxx
@@ -28,9 +28,24 @@
#include "config.hxx"
#include <commctrl.h>
-#include <tchar.h>
#include "resource.h"
+// Unicode-only defines to break dependance on UNICODE define
+#if !defined ListView_InsertColumnW
+#define ListView_InsertColumnW(hwnd, iCol, pcol) \
+ (int)SNDMSG((hwnd), LVM_INSERTCOLUMNW, (WPARAM)(int)(iCol), (LPARAM)(const LV_COLUMNW *)(pcol))
+#endif
+
+#if !defined ListView_InsertItemW
+#define ListView_InsertItemW(hwnd, pitem) \
+ (int)SNDMSG((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LV_ITEMW *)(pitem))
+#endif
+
+#if !defined ListView_SetItemW
+#define ListView_SetItemW(hwnd, pitem) \
+ (BOOL)SNDMSG((hwnd), LVM_SETITEMW, 0, (LPARAM)(const LV_ITEMW *)(pitem))
+#endif
+
list_view_builder_ptr create_list_view_builder(
HWND hwnd_lv, const std::wstring& col1, const std::wstring& col2)
@@ -83,17 +98,17 @@ void list_view_builder::build(statistic_group_list_t& gl)
void list_view_builder::setup_list_view()
{
HIMAGELIST h_ils = ImageList_Create(16,15,ILC_MASK, 7, 0);
- HBITMAP h_bmp = LoadBitmap(GetModuleHandle(MODULE_NAME), MAKEINTRESOURCE(IDB_PROPERTY_IMAGES));
+ HBITMAP h_bmp = LoadBitmapW(GetModuleHandleW(MODULE_NAME), MAKEINTRESOURCEW(IDB_PROPERTY_IMAGES));
ImageList_AddMasked(h_ils, h_bmp, RGB(255, 0, 255));
(void) ListView_SetImageList(hwnd_list_view_, h_ils, LVSIL_SMALL);
std::wstring header = GetResString(IDS_PROPERTY);
- LVCOLUMN lvc;
+ LVCOLUMNW lvc;
lvc.mask = LVCF_FMT |
LVCF_WIDTH |
- LVCF_TEXT |
+ LVCF_TEXT |
LVCF_SUBITEM;
lvc.iSubItem = 0;
@@ -101,11 +116,11 @@ void list_view_builder::setup_list_view()
lvc.cx = 120;
lvc.fmt = LVCFMT_LEFT;
- ListView_InsertColumn(hwnd_list_view_, 0, &lvc);
+ ListView_InsertColumnW(hwnd_list_view_, 0, &lvc);
lvc.iSubItem = 1;
header = GetResString(IDS_PROPERTY_VALUE);
lvc.pszText = const_cast<wchar_t*>(header.c_str());
- ListView_InsertColumn(hwnd_list_view_, 1, &lvc);
+ ListView_InsertColumnW(hwnd_list_view_, 1, &lvc);
}
@@ -117,7 +132,7 @@ void list_view_builder::insert_group(const std::wstring& /*title*/)
void list_view_builder::insert_item(const std::wstring& title, const std::wstring& value, bool is_editable)
{
- LVITEM lvi;
+ LVITEMW lvi;
lvi.iItem = ++row_index_;
lvi.iSubItem = 0;
@@ -137,13 +152,13 @@ void list_view_builder::insert_item(const std::wstring& title, const std::wstrin
lvi.iImage = 3;
}
- ListView_InsertItem(hwnd_list_view_, &lvi);
+ ListView_InsertItemW(hwnd_list_view_, &lvi);
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 1;
lvi.pszText = const_cast<wchar_t*>(value.c_str());
- ListView_SetItem(hwnd_list_view_, &lvi);
+ ListView_SetItemW(hwnd_list_view_, &lvi);
}
@@ -193,7 +208,7 @@ void winxp_list_view_builder::insert_group(const std::wstring& name)
void winxp_list_view_builder::insert_item(
const std::wstring& title, const std::wstring& value, bool is_editable)
{
- LVITEM lvi;
+ LVITEMW lvi;
lvi.iItem = ++row_index_;
lvi.iSubItem = 0;
@@ -213,13 +228,13 @@ void winxp_list_view_builder::insert_item(
lvi.iImage = 3;
}
- ListView_InsertItem(get_list_view(), &lvi);
+ ListView_InsertItemW(get_list_view(), &lvi);
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 1;
lvi.pszText = const_cast<wchar_t*>(value.c_str());
- ListView_SetItem(get_list_view(), &lvi);
+ ListView_SetItemW(get_list_view(), &lvi);
row_count_++;
}
diff --git a/shell/source/win32/shlxthandler/shlxthdl.cxx b/shell/source/win32/shlxthandler/shlxthdl.cxx
index 24833812d821..ff8b83670904 100644
--- a/shell/source/win32/shlxthandler/shlxthdl.cxx
+++ b/shell/source/win32/shlxthandler/shlxthdl.cxx
@@ -25,7 +25,6 @@
#include "fileextensions.hxx"
#include "utilities.hxx"
-#include <tchar.h>
#include <string>
#include <shlobj.h>
diff --git a/shell/source/win32/simplemail/senddoc.cxx b/shell/source/win32/simplemail/senddoc.cxx
index b911a3b9cc5b..f0dfe8f547ea 100644
--- a/shell/source/win32/simplemail/senddoc.cxx
+++ b/shell/source/win32/simplemail/senddoc.cxx
@@ -26,8 +26,6 @@
#include "simplemapi.hxx"
-#include <tchar.h>
-
#include <iostream>
#include <vector>
#include <sstream>
@@ -340,7 +338,7 @@ int main(int argc, char* argv[])
if (gMapiFlags & MAPI_LOGON_UI)
oss << "--mapi-logon-ui" << std::endl;
- MessageBox(nullptr, oss.str().c_str(), "Arguments", MB_OK | MB_ICONINFORMATION);
+ MessageBoxA(nullptr, oss.str().c_str(), "Arguments", MB_OK | MB_ICONINFORMATION);
}
#endif
diff --git a/svl/source/svdde/ddecli.cxx b/svl/source/svdde/ddecli.cxx
index d97a9cdf4fe6..c84bb92592de 100644
--- a/svl/source/svdde/ddecli.cxx
+++ b/svl/source/svdde/ddecli.cxx
@@ -18,7 +18,6 @@
*/
-#define UNICODE
#include <string.h>
#include <algorithm>
#include "ddeimp.hxx"
@@ -157,12 +156,12 @@ DdeConnection::DdeConnection( const OUString& rService, const OUString& rTopic )
pInst->nInstanceCli++;
if ( !pInst->hDdeInstCli )
{
- pImp->nStatus = DdeInitialize( &pInst->hDdeInstCli,
- DdeInternal::CliCallback,
- APPCLASS_STANDARD | APPCMD_CLIENTONLY |
- CBF_FAIL_ALLSVRXACTIONS |
- CBF_SKIP_REGISTRATIONS |
- CBF_SKIP_UNREGISTRATIONS, 0L );
+ pImp->nStatus = DdeInitializeW( &pInst->hDdeInstCli,
+ DdeInternal::CliCallback,
+ APPCLASS_STANDARD | APPCMD_CLIENTONLY |
+ CBF_FAIL_ALLSVRXACTIONS |
+ CBF_SKIP_REGISTRATIONS |
+ CBF_SKIP_UNREGISTRATIONS, 0L );
}
pService = new DdeString( pInst->hDdeInstCli, rService );
diff --git a/svl/source/svdde/ddedata.cxx b/svl/source/svdde/ddedata.cxx
index 44817c3d03d8..5ee335ee67ec 100644
--- a/svl/source/svdde/ddedata.cxx
+++ b/svl/source/svdde/ddedata.cxx
@@ -22,8 +22,6 @@
// Format numbers to be the same! If that's not the case, we need to
// adapt the code here. The implementation uses the conversions here.
-#define UNICODE
-
#include <string.h>
#include "ddeimp.hxx"
#include <svl/svdde.hxx>
@@ -136,7 +134,7 @@ sal_uLong DdeData::GetExternalFormat(SotClipboardFormatId nFmt)
#if defined(_WIN32)
OUString aName( SotExchange::GetFormatName( nFmt ) );
if( !aName.isEmpty() )
- return RegisterClipboardFormat( reinterpret_cast<LPCWSTR>(aName.getStr()) );
+ return RegisterClipboardFormatW( SAL_W(aName.getStr()) );
#endif
}
}
@@ -157,10 +155,10 @@ SotClipboardFormatId DdeData::GetInternalFormat(sal_uLong nFmt)
#if defined(_WIN32)
if( nFmt >= CF_MAX )
{
- TCHAR szName[ 256 ];
+ WCHAR szName[ 256 ];
- if(GetClipboardFormatName( nFmt, szName, sizeof(szName) ))
- return SotExchange::RegisterFormatName( OUString(reinterpret_cast<const sal_Unicode*>(szName)) );
+ if(GetClipboardFormatNameW( nFmt, szName, SAL_N_ELEMENTS(szName) ))
+ return SotExchange::RegisterFormatName( SAL_U(szName) );
}
#endif
break;
diff --git a/svl/source/svdde/ddestrg.cxx b/svl/source/svdde/ddestrg.cxx
index 841c3d7e8e28..70cde9aa8594 100644
--- a/svl/source/svdde/ddestrg.cxx
+++ b/svl/source/svdde/ddestrg.cxx
@@ -18,15 +18,13 @@
*/
-#define UNICODE
-
#include "ddeimp.hxx"
#include <svl/svdde.hxx>
DdeString::DdeString( DWORD hDdeInst, const OUString& r)
: m_aString(r)
{
- hString = DdeCreateStringHandle( hDdeInst, reinterpret_cast<wchar_t const *>(r.getStr()), CP_WINUNICODE );
+ hString = DdeCreateStringHandleW( hDdeInst, SAL_W(r.getStr()), CP_WINUNICODE );
hInst = hDdeInst;
}
diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx
index 36fd9da26d90..5fa56f50f5ad 100644
--- a/svl/source/svdde/ddesvr.cxx
+++ b/svl/source/svdde/ddesvr.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define UNICODE
#include "ddeimp.hxx"
#include <algorithm>
#include <memory>
@@ -79,10 +78,10 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
{
int nTopics = 0;
- TCHAR chTopicBuf[250];
+ WCHAR chTopicBuf[250];
if( hText1 )
- DdeQueryString( pInst->hDdeInstSvr, hText1, chTopicBuf,
- sizeof(chTopicBuf)/sizeof(TCHAR), CP_WINUNICODE );
+ DdeQueryStringW( pInst->hDdeInstSvr, hText1, chTopicBuf,
+ SAL_N_ELEMENTS(chTopicBuf), CP_WINUNICODE );
for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI)
{
@@ -98,7 +97,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
while( -1 != n )
{
OUString s( sTopics.getToken( 0, '\t', n ));
- if( s == reinterpret_cast<const sal_Unicode*>(chTopicBuf) )
+ if( s == SAL_U(chTopicBuf) )
++nTopics;
}
}
@@ -125,7 +124,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
{
OUString s( sTopics.getToken( 0, '\t', n ));
s = s.replaceAll("\n", "").replaceAll("\r", "");
- if( !hText1 || s == reinterpret_cast<const sal_Unicode*>(chTopicBuf) )
+ if( !hText1 || s == SAL_U(chTopicBuf) )
{
DdeString aDStr( pInst->hDdeInstSvr, s );
pTopic = FindTopic( *pService, aDStr.getHSZ() );
@@ -233,15 +232,15 @@ found:
OUString aRes; // Must be free not until the end!
if ( pTopic->IsSystemTopic() )
{
- if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_TOPICS) )
+ if ( pTopic->aItem == SZDDESYS_ITEM_TOPICS )
aRes = pService->Topics();
- else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_SYSITEMS) )
+ else if ( pTopic->aItem == SZDDESYS_ITEM_SYSITEMS )
aRes = pService->SysItems();
- else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_STATUS) )
+ else if ( pTopic->aItem == SZDDESYS_ITEM_STATUS )
aRes = pService->Status();
- else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_FORMATS) )
+ else if ( pTopic->aItem == SZDDESYS_ITEM_FORMATS )
aRes = pService->Formats();
- else if ( pTopic->aItem == reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_HELP) )
+ else if ( pTopic->aItem == SZDDESYS_ITEM_HELP )
aRes = OUString();
else
aRes = OUString();
@@ -392,8 +391,8 @@ DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic )
break;
// Let's query our subclass
- TCHAR chBuf[250];
- DdeQueryString(pInst->hDdeInstSvr,hTopic,chBuf,sizeof(chBuf)/sizeof(TCHAR),CP_WINUNICODE );
+ WCHAR chBuf[250];
+ DdeQueryStringW(pInst->hDdeInstSvr,hTopic,chBuf,SAL_N_ELEMENTS(chBuf),CP_WINUNICODE );
bContinue = false;
// We need to search again
}
@@ -422,9 +421,9 @@ DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem )
break;
// Let's query our subclass
- TCHAR chBuf[250];
- DdeQueryString(pInst->hDdeInstSvr,hItem,chBuf,sizeof(chBuf)/sizeof(TCHAR),CP_WINUNICODE );
- bContinue = rTopic.MakeItem( reinterpret_cast<const sal_Unicode*>(chBuf) );
+ WCHAR chBuf[250];
+ DdeQueryStringW(pInst->hDdeInstSvr,hItem,chBuf,SAL_N_ELEMENTS(chBuf),CP_WINUNICODE );
+ bContinue = rTopic.MakeItem( SAL_U(chBuf) );
// We need to search again
}
while( bContinue );
@@ -443,11 +442,11 @@ DdeService::DdeService( const OUString& rService )
if ( !pInst->hDdeInstSvr )
{
nStatus = sal::static_int_cast< short >(
- DdeInitialize( &pInst->hDdeInstSvr,
- DdeInternal::SvrCallback,
- APPCLASS_STANDARD |
- CBF_SKIP_REGISTRATIONS |
- CBF_SKIP_UNREGISTRATIONS, 0L ) );
+ DdeInitializeW( &pInst->hDdeInstSvr,
+ DdeInternal::SvrCallback,
+ APPCLASS_STANDARD |
+ CBF_SKIP_REGISTRATIONS |
+ CBF_SKIP_UNREGISTRATIONS, 0L ) );
pInst->pServicesSvr = new DdeServices;
}
else
@@ -468,12 +467,12 @@ DdeService::DdeService( const OUString& rService )
}
}
AddFormat( SotClipboardFormatId::STRING );
- pSysTopic = new DdeTopic( reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC) );
- pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_TOPICS) ) );
- pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_SYSITEMS) ) );
- pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_STATUS) ) );
- pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_FORMATS) ) );
- pSysTopic->AddItem( DdeItem( reinterpret_cast<const sal_Unicode*>(SZDDESYS_ITEM_HELP) ) );
+ pSysTopic = new DdeTopic( SZDDESYS_TOPIC );
+ pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_TOPICS ) );
+ pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_SYSITEMS ) );
+ pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_STATUS ) );
+ pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_FORMATS ) );
+ pSysTopic->AddItem( DdeItem( SZDDESYS_ITEM_HELP ) );
AddTopic( *pSysTopic );
}
@@ -608,7 +607,7 @@ const OUString DdeTopic::GetName() const
bool DdeTopic::IsSystemTopic()
{
- return GetName() == reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC);
+ return GetName() == SZDDESYS_TOPIC;
}
DdeItem* DdeTopic::AddItem( const DdeItem& r )
@@ -859,7 +858,7 @@ OUString DdeService::SysItems()
std::vector<DdeItem*>::iterator iterItem;
for ( iter = aTopics.begin(); iter != aTopics.end(); ++iter )
{
- if ( (*iter)->GetName() == reinterpret_cast<const sal_Unicode*>(SZDDESYS_TOPIC) )
+ if ( (*iter)->GetName() == SZDDESYS_TOPIC )
{
short n = 0;
for ( iterItem = (*iter)->aItems.begin(); iterItem != (*iter)->aItems.end(); ++iterItem, n++ )
@@ -913,9 +912,9 @@ OUString DdeService::Formats()
break;
default:
{
- TCHAR buf[128];
- GetClipboardFormatName( (UINT)f, buf, sizeof(buf) / sizeof(TCHAR) );
- s += OUString(reinterpret_cast<sal_Unicode*>(buf));
+ WCHAR buf[128];
+ GetClipboardFormatNameW( (UINT)f, buf, SAL_N_ELEMENTS(buf) );
+ s += SAL_U(buf);
}
break;
}
diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx
index f8e34c2d40b8..90f9dc746cc8 100644
--- a/svx/inc/pch/precompiled_svx.hxx
+++ b/svx/inc/pch/precompiled_svx.hxx
@@ -20,11 +20,6 @@
./bin/update_pch_bisect ./svx/inc/pch/precompiled_svx.hxx "/opt/lo/bin/make svx.build" --find-conflicts
*/
-#ifdef _WIN32
-#define UNICODE
-#define _UNICODE
-#endif
-
#include <algorithm>
#include <cassert>
#include <climits>
diff --git a/sw/source/ui/vba/vbasystem.cxx b/sw/source/ui/vba/vbasystem.cxx
index c98df33e3595..7781f6660c65 100644
--- a/sw/source/ui/vba/vbasystem.cxx
+++ b/sw/source/ui/vba/vbasystem.cxx
@@ -29,6 +29,9 @@
#pragma warning (push, 1)
#pragma warning (disable: 4005)
#endif
+#if !defined WINVER
+# define WINVER 0x0400
+#endif
#if !defined WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
@@ -36,7 +39,6 @@
#if defined _MSC_VER
#pragma warning (pop)
#endif
-#include <tchar.h>
#endif
using namespace ::ooo::vba;
@@ -97,7 +99,7 @@ uno::Any PrivateProfileStringListener::getValueEvent()
}
else
{
- // get key/value from windows register
+ // get key/value from Windows registry
#ifdef _WIN32
HKEY hBaseKey = nullptr;
OString sSubKey;
@@ -105,21 +107,23 @@ uno::Any PrivateProfileStringListener::getValueEvent()
if( hBaseKey != nullptr )
{
HKEY hKey = nullptr;
- LONG lResult;
- LPCTSTR lpSubKey = TEXT( sSubKey.getStr());
- TCHAR szBuffer[1024];
- DWORD cbData = sizeof( szBuffer );
- lResult = RegOpenKeyEx( hBaseKey, lpSubKey, 0, KEY_QUERY_VALUE, &hKey );
+ LPCSTR lpSubKey = sSubKey.getStr();
+ // We use RegOpenKeyExA here for convenience, because we already have subkey name as 8-bit string
+ LONG lResult = RegOpenKeyExA( hBaseKey, lpSubKey, 0, KEY_QUERY_VALUE, &hKey );
if( ERROR_SUCCESS == lResult )
{
- LPCTSTR lpValueName = TEXT(maKey.getStr());
- lResult = RegQueryValueEx( hKey, lpValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &cbData );
+ OUString sUValName = OStringToOUString(maKey, RTL_TEXTENCODING_DONTKNOW);
+ LPCWSTR lpValueName = SAL_W(sUValName.getStr());
+ WCHAR szBuffer[1024];
+ DWORD cbData = sizeof(szBuffer);
+ lResult = RegQueryValueExW( hKey, lpValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &cbData );
RegCloseKey( hKey );
- sValue = OUString::createFromAscii(szBuffer);
+ // https://msdn.microsoft.com/en-us/ms724911 mentions that
+ // "the string may not have been stored with the proper terminating null characters"
+ szBuffer[std::min(size_t(cbData / sizeof(szBuffer[0])), SAL_N_ELEMENTS(szBuffer)-1)] = 0;
+ sValue = SAL_U(szBuffer);
}
}
-
- return uno::makeAny( sValue );
#else
throw uno::RuntimeException("Only support on Windows" );
#endif
@@ -142,7 +146,7 @@ void PrivateProfileStringListener::setValueEvent( const css::uno::Any& value )
}
else
{
- //set value into windows register
+ //set value into Windows registry
#ifdef _WIN32
HKEY hBaseKey = nullptr;
OString sSubKey;
@@ -150,15 +154,15 @@ void PrivateProfileStringListener::setValueEvent( const css::uno::Any& value )
if( hBaseKey != nullptr )
{
HKEY hKey = nullptr;
- LONG lResult;
- LPCTSTR lpSubKey = TEXT( sSubKey.getStr());
- lResult = RegCreateKeyEx( hBaseKey, lpSubKey, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &hKey, nullptr );
+ LPCSTR lpSubKey = sSubKey.getStr();
+ // We use RegCreateKeyExA here for convenience, because we already have subkey name as 8-bit string
+ LONG lResult = RegCreateKeyExA( hBaseKey, lpSubKey, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &hKey, nullptr );
if( ERROR_SUCCESS == lResult )
{
- OString aUTF8Value = OUStringToOString( aValue, RTL_TEXTENCODING_UTF8 );
- DWORD cbData = sizeof(TCHAR) * (_tcslen(aUTF8Value.getStr()) + 1);
- LPCTSTR lpValueName = TEXT(maKey.getStr());
- lResult = RegSetValueEx( hKey, lpValueName, 0 /* Reserved */, REG_SZ, reinterpret_cast<BYTE const *>(aUTF8Value.getStr()), cbData );
+ DWORD cbData = sizeof(WCHAR) * (aValue.getLength() + 1);
+ OUString sUValName = OStringToOUString(maKey, RTL_TEXTENCODING_DONTKNOW);
+ LPCWSTR lpValueName = SAL_W(sUValName.getStr());
+ lResult = RegSetValueExW( hKey, lpValueName, 0 /* Reserved */, REG_SZ, reinterpret_cast<BYTE const *>(aValue.getStr()), cbData );
RegCloseKey( hKey );
}
}