Skip to content

Commit

Permalink
fixed missing argv[0]
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas O'Connor committed Jan 1, 2016
1 parent 70df9c7 commit 0179bd7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Tilandis/Tilandis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Tilandis/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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'-') {
Expand Down

0 comments on commit 0179bd7

Please sign in to comment.