From 0179bd7b1bf2ce5cc4e332df9da73575f743f4d7 Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Fri, 1 Jan 2016 13:38:06 -0800 Subject: [PATCH] fixed missing argv[0] --- Tilandis/Tilandis.cpp | 8 +++++--- Tilandis/cmdline.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Tilandis/Tilandis.cpp b/Tilandis/Tilandis.cpp index ce231d4..31fd018 100644 --- a/Tilandis/Tilandis.cpp +++ b/Tilandis/Tilandis.cpp @@ -10,14 +10,16 @@ #include "Utility.h" std::wstring Tilandis::BaseDirectory = L""; -int CALLBACK wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpCmdLine, int nShow) { +int CALLBACK wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR, int nShow) { + // Note to self: Do not EVER, under ANY circumstances, use the lpCmdLine parameter passed to wWinMain + // That parameter is full of lies and deceit and cannot be trusted LPWSTR* argv; int argc; - argv = CommandLineToArgvW(lpCmdLine, &argc); - std::wcout << argv << std::endl; + argv = CommandLineToArgvW(GetCommandLineW(), &argc); wchar_t* argvzero = new wchar_t[65535]; GetModuleFileName(NULL, argvzero, 65535); + std::wstring argvzerostr = argvzero; Tilandis::BaseDirectory = Utility::basedir(argvzerostr); diff --git a/Tilandis/cmdline.cpp b/Tilandis/cmdline.cpp index 2f40e61..581997c 100644 --- a/Tilandis/cmdline.cpp +++ b/Tilandis/cmdline.cpp @@ -27,7 +27,7 @@ bool Tilandis::UsingCommandLine(int argc, wchar_t* argv[]) { bool lookingforarg = false; // bool longstr = false; // possibly redundant std::wstring curargstr; // shorthand for developer convenience. the compiler will probably optimize this one away - for (int curarg = 0; curarg < argc; curarg++) { + for (int curarg = 1; curarg < argc; curarg++) { curargstr = argv[curarg]; if (lookingforarg) { if (curargstr[0] == L'-') {