I'm trying to execute a .jar file from my own C++ .dll code with parameters and get result string which will be printed. Unfortunately, code doesn't find the popen
or _popen
command although I already tried to find the right imports like #include <stdio.h>
or #include <stdlib.h>
.
Is it even possible to execute a .jar from a .dll with an acceptable performance and how is this possible? I didn't find an example which worked for me.
The .jar file will just be called like java -jar test.jar "samplestring"
. Is it possible to do what the console does when I type this command and get the result?
I tried this example (problem: popen and pclose aren't defined): popen() writes output of command executed to cout
Edit: UWP doesn't support popen or _popen
Now i got this:
STARTUPINFOW siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
if (CreateProcess(TEXT("C:\\Program Files (x86)\\Java\\jdk1.8.0_161\\bin\\java.exe"), TEXT("-jar decode.jar"), NULL, NULL, false, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &siStartupInfo, &piProcessInfo) == false) {
return -1; //Error
}
CloseHandle(piProcessInfo.hProcess);
CloseHandle(piProcessInfo.hThread);
How can I get the output of the CreateProcess command? Is this possible?