简体   繁体   English

在C#应用程序中运行CPP文件?

[英]Running a CPP file in a C# application?

I am currently on a project where I need to take a video file name from a UI built with C#. 我目前在一个项目中,需要从使用C#构建的UI中获取视频文件名。 After that, I need to pass the file name to my C++ application where the image processing algorithms will be done. 之后,我需要将文件名传递到我的C ++应用程序中,在该应用程序中将完成图像处理算法。 After having the results from image processing algorithms, I need to pass the data to C# UI and print them on the screen. 从图像处理算法得到结果后,我需要将数据传递到C#UI并将其打印在屏幕上。 To summarize, the workflow will be like this: 总而言之,工作流程将如下所示:

1)Get filename from user(In .cs file) 1)从用户那里获取文件名(在.cs文件中)

2)Pass filename to CPP(In .cs file) 2)将文件名传递给CPP(在.cs文件中)

3)Get the filename(In .cpp file) 3)获取文件名(在.cpp文件中)

4)Do the image processing algorithms(In .cpp file) 4)做图像处理算法(在.cpp文件中)

5)Pass the video data to .cs(In.cpp file) 5)将视频数据传递到.cs(In.cpp文件)

6)Get data from .cpp(In .cs file) 6)从.cpp获取数据(在.cs文件中)

7)Print data(In .cs file) 7)打印数据(在.cs文件中)

I am not sure if this is doable, so if not, I'm open for any different ideas. 我不确定这是否可行,所以如果不是,我愿意提出任何不同的想法。 Thanks. 谢谢。

Call the C++ function from C# via PInvoke. 通过PInvoke从C#调用C ++函数。 You should read up on Pinvoke. 您应该阅读Pinvoke。

You could use the Process class in C# to run a C++ compiler on the .cpp file, execute the compiled C++ program, and then read in the output of the C++ program. 您可以使用C#中的Process类在.cpp文件上运行C ++编译器,执行已编译的C ++程序,然后读取C ++程序的输出。 How to read the output of the C++ program depends on how the C++ program outputs the data. 如何读取C ++程序的输出取决于C ++程序如何输出数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM