fn parse_lp_cmd_line<'a, F: Fn() -> OsString>(
    lp_cmd_line: Option<WStrUnits<'a>>,
    exe_name: F
) -> Vec<OsString>
Expand description

Implements the Windows command-line argument parsing algorithm.

Microsoft’s documentation for the Windows CLI argument format can be found at https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=msvc-160#parsing-c-command-line-arguments

A more in-depth explanation is here: https://daviddeley.com/autohotkey/parameters/parameters.htm#WIN

Windows includes a function to do command line parsing in shell32.dll. However, this is not used for two reasons:

  1. Linking with that DLL causes the process to be registered as a GUI application. GUI applications add a bunch of overhead, even if no windows are drawn. See https://randomascii.wordpress.com/2018/12/03/a-not-called-function-can-cause-a-5x-slowdown/.

  2. It does not follow the modern C/C++ argv rules outlined in the first two links above.

This function was tested for equivalence to the C/C++ parsing rules using an extensive test suite available at https://github.com/ChrisDenton/winarg/tree/std.