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

后端 未结 1 349
旧巷少年郎
旧巷少年郎 2021-01-27 09:03

I have read this and achieved the opening of my C# application. My C# application opens a folder and draws a graph. Is it possible for me to tell my C# application which folder

相关标签:
1条回答
  • 2021-01-27 09:23

    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

    0 讨论(0)
提交回复
热议问题