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