Skip to content

Commit

Permalink
Support wchar_t in argv in windows
Browse files Browse the repository at this point in the history
Fix Genymobile#2932

Signed-off-by: Yu-Chen Lin <[email protected]>
  • Loading branch information
npes87184 committed Oct 23, 2022
1 parent b62424a commit a18318e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <stdbool.h>
#include <unistd.h>
#include <libavformat/avformat.h>
#ifdef __WINDOWS__
#include <windows.h>
#include "util/str.h"
#endif
#ifdef HAVE_V4L2
# include <libavdevice/avdevice.h>
#endif
Expand All @@ -20,6 +24,17 @@
int
main(int argc, char *argv[]) {
#ifdef __WINDOWS__
int wargc;
wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);

if (argc != wargc) {
return SCRCPY_EXIT_FAILURE;
}

for (int i = 0; i < wargc; ++i) {
argv[i] = sc_str_from_wchars(wargv[i]);
}

// disable buffering, we want logs immediately
// even line buffering (setvbuf() with mode _IOLBF) is not sufficient
setbuf(stdout, NULL);
Expand Down

0 comments on commit a18318e

Please sign in to comment.