Hi all,
I've tried to create a simple win32 application that takes a filename as input parameter, using lpCmdLine:
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
std::string inputCmdLine = lpCmdLine;
std::wstring inputFilename;
inputFilename.append(inputCmdLine.begin(), inputCmdLine.end());
std::ifstream exists(inputFilename);
if(exists)
{
// do stuff
This kinda works, when I place the release executable in a folder and from that same folder I drag a file to the executable.
But there are 2 situations where the filename is not found/ is not interpreted correctly:
- use a input file with spaces in it's filename or it's folder where it's stored
- use the 'open with' function in windows explorer
In both these cases the result is that the string gets a " (quote) at the beginning and at the end, causing the filename not to be processed anymore.
I've tried to go through to the string and if I encounter a " (quote) remove it from the string, for example:
"test.dds" becomes test.dds.
But I still get the same symptons, aka not working.
Do you have any idea how to tackle this?