运行时进程名称更改(C ++)

时间:2021-12-03 16:25:21

Is it possible to change the name(the one that apears under 'processes' in Task Manager) of a process at runtime in win32? I want the program to be able to change it's own name, not other program's. Help would be appreciated, preferably in C++. And to dispel any thoughts of viruses, no this isn't a virus, yes I know what I'm doing, it's for my own use.

是否可以在win32中更改运行时进程的名称(在任务管理器中的'进程'下面的名称)?我希望程序能够改变它自己的名字,而不是其他程序。感谢帮助,最好是用C ++。并且消除任何病毒的想法,这不是病毒,是的,我知道我在做什么,这是我自己使用的。

3 个解决方案

#1


I know you're asking for Win32, but under most *nixes, this can be accomplished by just changing argv[0]

我知道你要求Win32,但在大多数* nixes下,这可以通过改变argv [0]来实现。

#2


I would like to submit what i believe IS a valid reason for changing the process name at runtime:

我想提交我认为是在运行时更改进程名称的正当理由:

I have an exe that runs continuously on a server -- though it is not a service. Several instances of this process can run on the server. The process is a scheduling system. An instance of the process runs for each line that is being scheduled, monitored and controlled. Imagine a factory with 7 lines to be scheduled. Main Assembly line, 3 sub assembly lines, and 3 machining lines.

我有一个在服务器上连续运行的exe - 虽然它不是服务。此过程的多个实例可以在服务器上运行。该过程是一个调度系统。对于正在调度,监视和控制的每条线路运行该过程的实例。想象一下,有7条线路的工厂要安排。主装配线,3条子装配线和3条加工线。

Rather than see sched.exe 7 times in task manager, it would be more helpful to see: sched-main sched-sub1 sched-sub2 sched-sub3 sched-mach1 sched-mach2 sched-mach3

看到sched-main sched-sub1 sched-sub2 sched-sub3 sched-mach1 sched-mach2 sched-mach3,而不是在任务管理器中看到7次sched.exe,会更有帮助。

This would be much more helpful to the Administrator ( the user in this situation should never see task manager). If one process is hung, the Administrator can easily know which one to kill and restart.

这对管理员来说会更有帮助(在这种情况下,用户永远不应该看到任务管理器)。如果一个进程挂起,管理员可以很容易地知道要杀死哪个进程并重新启动。

#3


I found code for doing that in VB. I believe it won't be too hard to convert it to C++ code.

我找到了在VB中执行此操作的代码。我相信将它转换为C ++代码并不会太难。

A good book about low level stuff is Microsoft Windows Internals.

关于低级别东西的好书是Microsoft Windows Internals。

And I agree with Peter Ruderman

我同意彼得鲁德曼的观点

This is not something you should do.

这不是你应该做的事情。

#1


I know you're asking for Win32, but under most *nixes, this can be accomplished by just changing argv[0]

我知道你要求Win32,但在大多数* nixes下,这可以通过改变argv [0]来实现。

#2


I would like to submit what i believe IS a valid reason for changing the process name at runtime:

我想提交我认为是在运行时更改进程名称的正当理由:

I have an exe that runs continuously on a server -- though it is not a service. Several instances of this process can run on the server. The process is a scheduling system. An instance of the process runs for each line that is being scheduled, monitored and controlled. Imagine a factory with 7 lines to be scheduled. Main Assembly line, 3 sub assembly lines, and 3 machining lines.

我有一个在服务器上连续运行的exe - 虽然它不是服务。此过程的多个实例可以在服务器上运行。该过程是一个调度系统。对于正在调度,监视和控制的每条线路运行该过程的实例。想象一下,有7条线路的工厂要安排。主装配线,3条子装配线和3条加工线。

Rather than see sched.exe 7 times in task manager, it would be more helpful to see: sched-main sched-sub1 sched-sub2 sched-sub3 sched-mach1 sched-mach2 sched-mach3

看到sched-main sched-sub1 sched-sub2 sched-sub3 sched-mach1 sched-mach2 sched-mach3,而不是在任务管理器中看到7次sched.exe,会更有帮助。

This would be much more helpful to the Administrator ( the user in this situation should never see task manager). If one process is hung, the Administrator can easily know which one to kill and restart.

这对管理员来说会更有帮助(在这种情况下,用户永远不应该看到任务管理器)。如果一个进程挂起,管理员可以很容易地知道要杀死哪个进程并重新启动。

#3


I found code for doing that in VB. I believe it won't be too hard to convert it to C++ code.

我找到了在VB中执行此操作的代码。我相信将它转换为C ++代码并不会太难。

A good book about low level stuff is Microsoft Windows Internals.

关于低级别东西的好书是Microsoft Windows Internals。

And I agree with Peter Ruderman

我同意彼得鲁德曼的观点

This is not something you should do.

这不是你应该做的事情。