Launch a C# Application from C++ and performing a task on that application

ⅰ亾dé卋堺 提交于 2019-12-02 09:10:44

It certainly is possible.

The C++ CreateProcess() has a parameter called lpCommandLine.

What you need to do in the C++ is to pass as lpCommandLine a string that has the name of the folder that you want to open. You will need to enclose the string in double quotes if the folder path contains any spaces.

Inside your C# program you will have a static void Main(string[] args). The args parameter will contain the folder name that you passed from the C++ program so that you can act on it appropriately.

For the C++ program to wait for the C# program to exit, it will need to use WaitForSingleObject() to wait for it to exit, using the process handle returned from CreateProcess().

This is described here: http://www.codeproject.com/Tips/333559/CreateProcess-and-wait-for-result

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!