将信息传递给新流程 [英] Passing information to new Process

查看:70
本文介绍了将信息传递给新流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在我的应用程序中开始一个新过程.
我想将一些消息传递给新进程,并在新进程结束时获取消息并显示它.

我正在使用以下在Web中找到的方法


在第一个流程A中,创建一个名为myProcess
的新流程

Hi ,

I am starting a new process in my application.
I want to pass some message to new process and get the message at new process end and display it.

I am using below method which I found in web


In first Process A creating new process called myProcess

Dim myProcess As New Process

myProcess.StartInfo.FileName = "App2.exe"
myProcess.StartInfo.Arguments = "History"
myProcess.Start()



然后,第二个应用程序(即以myProcess开头)可以读取其命令行参数,如下所示



The second app (i.e started with myProcess) could then read its command line arguments as below

Dim cmndLineArg As System.Collection.ObjectModel.ReadOnlyCollection(Of String) =  My.Application.CommandLineArgs

Dim requiredMsg as string = cmndLineArg(0) 





但是当我执行主流程并尝试启动新流程时,我遇到了错误

初始化时发生错误"和无法修复URI格式".


有人请解释出什么问题了吗?还有其他方法可以从一个应用程序的进程传递信息,并在新进程中获取它.

问候,

Vijay





But when I execute main Process and try to start the new process, I am getting below error

"Error has occured in the intialization" and "Couldn''t fix the URI format".


Anyone please explain what is going wrong? Is there any other method to pass info from process of one application and get it in the new process.

Regards,

Vijay

推荐答案

没有其他方法.您是否已逐步检查代码以查看传递了哪些参数?争论通常以/开头,如/History一样,尽管我认为这不是必需的.
There is no other method. Have you stepped through your code to see what arguments are being passed in ? Arguments typically start with a /, as in /History, although I don''t think it''s required.


Hi Graus,

我用上述方法无法成功.

作为替代,我尝试了以下方法


1.在第一个进程中,在开始新进程之前,将所需数据写入txt文件并将其保存在exe路径中.

Hi Graus,

I couldn''t succeed with the above method.

As alternative I tried with below method


1.In first Process before starting new process, write the data needed in txt file and save it in exe path.

Dim u as New Uri(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
dim exepath as String = System.IO.Path.GetDirectoryName(u.LocalPath)
dim fullPath as String = System.IO.Path.Combine(exepath, "dataStore.txt") System.IO.File.WriteAllText(fullpath, "History")



2.开始新的过程

3.读取应用程序中以新过程开始的数据



2. start the new process

3. read the data in the application started with new process

Dim u as  New Uri(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
dim exepath as String = System.IO.Path.GetDirectoryName(u.LocalPath)
dim fullPath as String = System.IO.Path.Combine(exepath, "dataStore.txt") 
Dim reqData as string = System.IO.File.ReadAllText(fullpath)



4.读取数据后,删除用于存储信息的临时文件



4. After reading data delete the temp file used to store info

System.Io.File.Delete(fullPath)



问候,

Vijay



Regards,

Vijay


这篇关于将信息传递给新流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆