• <tfoot id='2f6kA'></tfoot>
  • <i id='2f6kA'><tr id='2f6kA'><dt id='2f6kA'><q id='2f6kA'><span id='2f6kA'><b id='2f6kA'><form id='2f6kA'><ins id='2f6kA'></ins><ul id='2f6kA'></ul><sub id='2f6kA'></sub></form><legend id='2f6kA'></legend><bdo id='2f6kA'><pre id='2f6kA'><center id='2f6kA'></center></pre></bdo></b><th id='2f6kA'></th></span></q></dt></tr></i><div id='2f6kA'><tfoot id='2f6kA'></tfoot><dl id='2f6kA'><fieldset id='2f6kA'></fieldset></dl></div>

  • <small id='2f6kA'></small><noframes id='2f6kA'>

      <bdo id='2f6kA'></bdo><ul id='2f6kA'></ul>

    <legend id='2f6kA'><style id='2f6kA'><dir id='2f6kA'><q id='2f6kA'></q></dir></style></legend>
      1. 从 C++ 启动 C# 应用程序并在该应用程序上执行任务

        Launch a C# Application from C++ and performing a task on that application(从 C++ 启动 C# 应用程序并在该应用程序上执行任务)

          <legend id='CSbUy'><style id='CSbUy'><dir id='CSbUy'><q id='CSbUy'></q></dir></style></legend>
          • <small id='CSbUy'></small><noframes id='CSbUy'>

            <tfoot id='CSbUy'></tfoot>
          • <i id='CSbUy'><tr id='CSbUy'><dt id='CSbUy'><q id='CSbUy'><span id='CSbUy'><b id='CSbUy'><form id='CSbUy'><ins id='CSbUy'></ins><ul id='CSbUy'></ul><sub id='CSbUy'></sub></form><legend id='CSbUy'></legend><bdo id='CSbUy'><pre id='CSbUy'><center id='CSbUy'></center></pre></bdo></b><th id='CSbUy'></th></span></q></dt></tr></i><div id='CSbUy'><tfoot id='CSbUy'></tfoot><dl id='CSbUy'><fieldset id='CSbUy'></fieldset></dl></div>

              <bdo id='CSbUy'></bdo><ul id='CSbUy'></ul>
                  <tbody id='CSbUy'></tbody>
                  本文介绍了从 C++ 启动 C# 应用程序并在该应用程序上执行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我已阅读this 并实现了我的C#的开放应用.我的 C# 应用程序打开一个文件夹并绘制一个图表.我是否可以告诉我的 C# 应用程序从 C++ 打开哪个文件夹,然后一旦看到图形并关闭 C# 程序,它就会返回到 C++ 应用程序.

                  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 to open from C++ and then once the graph is seen and the C# program is closed, it returns back to the C++ app.

                  谢谢 Matthew,我搞定了.

                  Thanks Matthew I got it working.

                  关于我的 CreateProcess lpCommandLine 变量的另一个查询:(下面是代码)

                  Another query in relation to my CreateProcess lpCommandLine variable: (Below is the code)

                  CString sFolderPath = "C:Documents and Settings...";
                        int nStrBuffer = sFolderPath.GetLength() + 50;
                        LPTSTR szParam = _tcsdup(sFolderPath.GetBuffer(nStrBuffer));
                  
                    nRet = ::CreateProcess(szCmdline,// pointer to name of executable module 
                    szParam,// pointer to command line string
                    NULL,// pointer to process security attributes 
                    NULL,// pointer to thread security attributes 
                    FALSE,// handle inheritance flag 
                    DETACHED_PROCESS,// creation flags 
                    NULL,// pointer to new environment block 
                    NULL,// pointer to current directory name 
                    &sui,// pointer to STARTUPINFO 
                    &pi );// pointer to PROCESS_INFORMATION
                  

                  我正确地获得了变量 szParam,但是当应用程序打开时,完整的文件名不会被复制.例如:在上述情况下,只有and Settings...."被复制到其中,因为C:Documents"部分被留下.请您指出我的错误吗?

                  I get the variable szParam properly, but when the application opens up, the complete filename is not copied across. For eg: In the above case, only " and Settings...." is copied across where as the "C:Documents" part is left behind. Could you point out on my mistake please?

                  C# 实现:

                  [STAThread]
                  static void Main(string[] args)
                  {
                      foreach (string result in args)
                      {
                          MessageBox.Show(result);
                      }
                  }
                  

                  推荐答案

                  当然可以.

                  C++ CreateProcess() 有一个名为 lpCommandLine 的参数.

                  您需要在 C++ 中做的是作为 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.

                  在您的 C# 程序中,您将有一个 static void Main(string[] args).args 参数将包含您从 C++ 程序传递的文件夹名称,以便您可以适当地对其进行操作.

                  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.

                  C++ 程序要等待 C# 程序退出,它需要使用 WaitForSingleObject() 等待它退出,使用从 CreateProcess() 返回的进程句柄.

                  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().

                  此处对此进行了描述:http://www.codeproject.com/Tips/333559/CreateProcess-and-wait-for-result

                  这篇关于从 C++ 启动 C# 应用程序并在该应用程序上执行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)

                • <legend id='egsFE'><style id='egsFE'><dir id='egsFE'><q id='egsFE'></q></dir></style></legend>

                  <small id='egsFE'></small><noframes id='egsFE'>

                    <bdo id='egsFE'></bdo><ul id='egsFE'></ul>

                            <tbody id='egsFE'></tbody>

                          <tfoot id='egsFE'></tfoot>
                            <i id='egsFE'><tr id='egsFE'><dt id='egsFE'><q id='egsFE'><span id='egsFE'><b id='egsFE'><form id='egsFE'><ins id='egsFE'></ins><ul id='egsFE'></ul><sub id='egsFE'></sub></form><legend id='egsFE'></legend><bdo id='egsFE'><pre id='egsFE'><center id='egsFE'></center></pre></bdo></b><th id='egsFE'></th></span></q></dt></tr></i><div id='egsFE'><tfoot id='egsFE'></tfoot><dl id='egsFE'><fieldset id='egsFE'></fieldset></dl></div>