[Win] Fix the command line spliting code.
This commit is contained in:
parent
d0b4800282
commit
beb62566e4
1 changed files with 7 additions and 6 deletions
|
@ -13,22 +13,23 @@ int Start(int argc, char *argv[]);
|
|||
#if defined(OS_WIN)
|
||||
|
||||
#include <windows.h> // NOLINT
|
||||
#include <shellapi.h> // NOLINT
|
||||
|
||||
#include "app/atom_main_delegate.h"
|
||||
#include "content/public/app/startup_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
|
||||
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* wargv, int argc) {
|
||||
const wchar_t* wargv1 = reinterpret_cast<const wchar_t*>(wargv[1]);
|
||||
if (argc > 1 && wcscmp(wargv1, L"--atom-child_process-fork") == 0) {
|
||||
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
int argc = 0;
|
||||
wchar_t** wargv = ::CommandLineToArgvW(cmd, &argc);
|
||||
if (argc > 1 && wcscmp(wargv[1], L"--atom-child_process-fork") == 0) {
|
||||
// Convert argv to to UTF8
|
||||
char** argv = new char*[argc];
|
||||
for (int i = 0; i < argc; i++) {
|
||||
const wchar_t* wargvi = reinterpret_cast<const wchar_t*>(wargv[i]);
|
||||
// Compute the size of the required buffer
|
||||
DWORD size = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
wargvi,
|
||||
wargv[i],
|
||||
-1,
|
||||
NULL,
|
||||
0,
|
||||
|
@ -43,7 +44,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* wargv, int argc) {
|
|||
argv[i] = new char[size];
|
||||
DWORD result = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
wargvi,
|
||||
wargv[i],
|
||||
-1,
|
||||
argv[i],
|
||||
size,
|
||||
|
|
Loading…
Add table
Reference in a new issue