我如何发现如何我进程启动 [英] How do I discover how my process was started

查看:126
本文介绍了我如何发现如何我进程启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经有了一个WinForms LOB应用程序,正常情况下应该从发射开始,应该做的基本版本检查并下载所有更新的组件,产卵的主要过程之前。

We've got a winforms LOB application, which under normal circumstances should be started from a launcher that should do basic version checks and download any updated components, before spawning the main process.

我们所看到的一个问题是,工作人员的一些成员发现它加载更快没有运行更新应用程序,但是这可能会导致人们不具有最新的功能,并导致头痛,支持所有的方式。

One problem we're seeing is that some members of staff have found it loads faster by not running the update application, however this can lead to people not having the latest features and causes all manner of headache to support.

我希望能够做的就是扔了一个警告,如果他们没有通过INITIALISE应用了研究。理想情况下,我希望能够做到这一点,而无需更改更新的应用程序(因为这意味着要和每个客户端上安装一个新的MSI),并且涌出来的办法是找到找到关于此信息的一些方法的过程,开始我,并核对白/黑名单,永远我似乎无法找到一个方法来做到这一点?

What I'd like to be able to do is to throw up a warning if they haven't gone in through the initialise application. Ideally, I'd like to be able to do this without having to change the update application (as that means going and installing a new MSI on each client), and the approach that springs out is to find some way of finding information about the process that started "me" and check against a white/black list, forever I can't seem to find a way to do this?


旁白:的。当然,如果我没有诉诸修改更新的应用程序,我可能会改变它要么通过一个pre-共享密钥作为命令行参数,或更好不过,更改应用程序,这样我可以只加载它作为一个类库,并通过反射实例化相关类。 ClickOnce的已经被排除,因为它不支持正在安装多个用户

Aside: Of course, if I did resort to changing the update application, I'd probably change it to either pass a pre-shared secret as a command line argument, or better still, change the application such that I could just load it as a class library and instantiate the relevant class via reflection. ClickOnce has been ruled out as it does not support being installed for multiple users

推荐答案

下面参见:<一href="http://stackoverflow.com/questions/394816/how-to-get-parent-process-in-net-in-managed-way">http://stackoverflow.com/questions/394816/how-to-get-parent-process-in-net-in-managed-way

从链接:

using System.Diagnostics;
PerformanceCounter pc = new PerformanceCounter("Process",
"Creating Process ID", Process.GetCurrentProcess().ProcessName);
return Process.GetProcessById((int)pc.NextValue());

这篇关于我如何发现如何我进程启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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