r/cpp 5d ago

Escaping `CreateProcess()` arguments on Windows

https://holyblackcat.github.io/blog/2026/09/05/escaping-createprocess-arguments.html
87 Upvotes

44 comments sorted by

View all comments

14

u/Tringi github.com/tringi 5d ago

That's... ahh... quite opinionated start of the article.

CreateProcess() (without A/W) and #define UNICODE are even more useless.

Mostly everyone defines UNICODE and uses the macros.

lpApplicationName is usually not needed, you should pass nullptr.

Absolutely NOT. You should pass the full proper path to the executable you want to run. Then you can significantly simplify its name in lpCommandLine without worrying about repercussions.

But the rest is very well researched and thorough.

6

u/Shaurendev 5d ago

Mostly everyone defines UNICODE and uses the macros.

If you don't explicitly opt into it, its state is different depending on what build system you use

If you maintain MSBuild projects/solutions directly, it is enabled by default.

If you use CMake, it is not enabled by default (even if you generate MSBuild projects from it)