MoloF Asked:2020-11-19 18:54:58 +0000 UTC2020-11-19 18:54:58 +0000 UTC 2020-11-19 18:54:58 +0000 UTC 电子和 C++ / C# | 直接数据交换 772 这个问题只是理论上的。 如何连接Electron应用程序和一些C++或C#程序,关键是即时数据交换。当然,理想情况下,监听Electron上的事件以进行异步数据处理操作。 有什么选择? 也许有一些方法可以为应用程序编写一个模块来工作? c# 1 个回答 Voted Best Answer user236980 2020-11-20T00:48:30Z2020-11-20T00:48:30Z Electronuses nodejs,因此可以将 cpp 代码打包为node module然后用作应用程序中的依赖项(参见示例:Hello World)。 以下代码等价于 JavaScript 中的 this: module.exports.hello = () => 'world'; 你好.cc(C++): #include <node.h> namespace demo { using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; using v8::Object; using v8::String; using v8::Value; void Method(const FunctionCallbackInfo<Value>& args) { Isolate* isolate = args.GetIsolate(); args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world")); } void init(Local<Object> exports) { NODE_SET_METHOD(exports, "hello", Method); } NODE_MODULE(addon, init) } // namespace demo 参见 EnSO 上的原文:Is it possible to use c++ as back-end for Electron.js?
Electron
usesnodejs
,因此可以将 cpp 代码打包为node module
然后用作应用程序中的依赖项(参见示例:Hello World)。以下代码等价于 JavaScript 中的 this:
你好.cc(C++):
参见 EnSO 上的原文:Is it possible to use c++ as back-end for Electron.js?