LibreOffice Module comphelper (master)  1
Macros | Functions
windows_process.cxx File Reference
#include <windows.h>
#include <cstring>
#include <wchar.h>
#include <comphelper/windowsStart.hxx>
#include <userenv.h>
Include dependency graph for windows_process.cxx:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Functions

static int ArgStrLen (const wchar_t *s)
 Get the length that the string will take and takes into account the additional length if the string needs to be quoted and if characters need to be escaped. More...
 
static wchar_t * ArgToString (wchar_t *d, const wchar_t *s)
 Copy string "s" to string "d", quoting the argument as appropriate and escaping doublequotes along with any backslashes that immediately precede doublequotes. More...
 
wchar_t * MakeCommandLine (int argc, wchar_t **argv)
 Creates a command line from a list of arguments. More...
 
BOOL WinLaunchChild (const wchar_t *exePath, int argc, wchar_t **argv, HANDLE userToken, HANDLE *hProcess)
 Launch a child process with the specified arguments. More...
 

Macro Definition Documentation

#define WIN32_LEAN_AND_MEAN

Definition at line 5 of file windows_process.cxx.

Function Documentation

static int ArgStrLen ( const wchar_t *  s)
static

Get the length that the string will take and takes into account the additional length if the string needs to be quoted and if characters need to be escaped.

Definition at line 22 of file windows_process.cxx.

References i.

Referenced by MakeCommandLine().

static wchar_t* ArgToString ( wchar_t *  d,
const wchar_t *  s 
)
static

Copy string "s" to string "d", quoting the argument as appropriate and escaping doublequotes along with any backslashes that immediately precede doublequotes.

The CRT parses this to retrieve the original argc/argv that we meant, see STDARGV.C in the MSVC CRT sources.

Returns
the end of the string

Definition at line 70 of file windows_process.cxx.

References i.

Referenced by MakeCommandLine().

wchar_t* MakeCommandLine ( int  argc,
wchar_t **  argv 
)

Creates a command line from a list of arguments.

The returned string is allocated with "malloc" and should be "free"d.

argv is UTF8

Definition at line 133 of file windows_process.cxx.

References ArgStrLen(), ArgToString(), and i.

Referenced by WinLaunchChild().

BOOL WinLaunchChild ( const wchar_t *  exePath,
int  argc,
wchar_t **  argv,
HANDLE  userToken = nullptr,
HANDLE *  hProcess = nullptr 
)

Launch a child process with the specified arguments.

Note
argv[0] is ignored

Definition at line 167 of file windows_process.cxx.

References FALSE, MakeCommandLine(), and TRUE.