Last active
September 9, 2015 16:06
-
-
Save drewsberry/fe3b0d11618d3a57b0a5 to your computer and use it in GitHub Desktop.
Get argv equivalent in WinMain()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <atlstr.h> | |
#include <cstdlib> | |
#define NOTUSED(var) (void)(var) | |
#define FLAG_STR "--help" | |
int CALLBACK WinMain( | |
_In_ HINSTANCE hInstance, | |
_In_ HINSTANCE hPrevInstance, | |
_In_ LPST lpCmdLine, | |
_In_ int nCmdShow | |
) | |
{ | |
NOTUSED(hInstance); | |
NOTUSED(hPrevInstance); | |
NOTUSED(lpCmdLine); | |
NOTUSED(nCmdShow); | |
LPWSTR *argList; | |
int argCount; | |
argList = CommandLineToArgW(GetCommandLine(), &argCount); | |
std::string argListStr[argCount]; | |
for (int i = 0; i < argCount; i++) | |
{ | |
std::stream argStr = CW2A(argList[i]); | |
if (!argStr.compare(FLAG_STR)) | |
{ | |
exit(10); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment