As far as I know there is no possible way to execute an Extendscript via the C++ API.
In InDesign we can do so by providing the script as a string and fetching simple output results.
Leo Quensel commented
CEP extensions can only be called in asynchronous fashion by using event triggers.
Whether the script succeeds, getting return values etc.. is impossible to determine. In some cases the script only gets triggered during the next idle time.
We need this functionality to circumvent missing features and bugs in the C++ API and call scripts during huge processing tasks.
There is no way we can wait for the next idle time.
Further, CEP is being discontinued in the future and provides a huge hassle during installation when paired with C++ plugins since CEP extensions have to be installed differently.
CEP is not an option here.
Minne Danhieux commented
This can be done via a CEP extension. Nothing extra needed for this.