When parsing the command line arguments of a process whose path contains a space, the path is split up into multiple pieces by CommandLineToArgvW.
There exists a folder on all Windows' C: drives called "Program Files."
...wat
The MSDN page mentions nothing about this being a problem. Am I just using the function wrong? How am I supposed to predict what words are part of the path otherwise?
CommandLineToArgvW
splits the line on spaces - if you need an argument (or the program name) to contain spaces you need to surround it with quotation marks.
C:\Program Files
- argv[0] = C:\Program, argv[1] = Files"C:\Program Files"
- argv[0] = C:\Program FilesNote that you can get the file path of your process using GetModuleFileName
- you can do this to determine whether the path contains a space, and insert the quotes in the command line if needed before parsing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With