summaryrefslogtreecommitdiff
path: root/desktop/win32
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-20 20:20:44 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-09-22 20:53:30 +0200
commiteef4c133e9649ebd690918bd7b83c2d5dc0dfcff (patch)
tree1a8d084c5b16056a15258770a05b9cd2d53a40bc /desktop/win32
parentbb406680cebd6fa1e1bdb9e2de430cd9a1f44da0 (diff)
Windows: avoid dependence on UNICODE define; prefer W functions
Change-Id: I95b90128e93f0d88ed73601bcc5a7ca9279d4cf1 Reviewed-on: https://gerrit.libreoffice.org/42560 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'desktop/win32')
-rw-r--r--desktop/win32/source/QuickStart/QuickStart.cxx40
-rw-r--r--desktop/win32/source/guistdio/guistdio.inc28
2 files changed, 34 insertions, 34 deletions
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,