APK 是用 RAD Studio C++Builder 11.2 编写的。
比如我试了很多方法都编译出错
代码如下:
UnicodeString command = "test_run";
TFileName fullPath = TPath::Combine(TPath::GetDocumentsPath(), command);
TProcess* process = new TProcess(NULL);
process->Executable = fullPath;
TStreamReader* output = new TStreamReader(process->Output);
process->Execute();
Memo1->Lines->Add(output->ReadLine());
output->Free();
process->Free();
TProcess
在 RAD Studio 11.2 中不存在
另一种方式:
#define TArray System::TArray__1
#define TJavaArray TJavaArray__1
#define JString Androidapi::Jni::Javatypes::_di_JString
JString jCommand = StringToJString("test_run");
JString jOutput = StringToJString("");
TArray<System::Byte> *jResult = NULL;
try {
_di_JRuntime rt = TJRuntime::JavaClass->getRuntime();
_di_JProcess proc = rt->exec(jCommand);
_di_JInputStream is = proc->getInputStream();
TJavaArray<System::Byte> *jdata = new TJavaArray<System::Byte>(1024);
while (is->available() > 0) {
int count = is->read(jdata,0,jdata->Length);
jOutput = jOutput + JStringToString(TJString::JavaClass->init(jdata,count));
}
jResult = new TArray<System::Byte>(jdata);
} catch (...) {
ShowMessage("Error: cannot run command");
jOutput = "";
}
卡在
JRuntime
.
我不知道如何使用 FMX 框架运行控制台命令。
有人能帮忙吗?