如何创建崩溃程序? [英] How to create a crash program?

查看:103
本文介绍了如何创建崩溃程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试开发一个程序来崩溃运行大型机器的大型程序。

我知道崩溃它听起来很糟糕但是如果由于某种原因机器失控我们可以停止机器,但它不会停止程序.C#写入plc,所以程序运行机器.Windows 10不是一个选项因为我们都讨厌它。



我尝试过的事情:



我真的不知道从哪里开始。我是c#和编程的新手。提前谢谢

Hi I am trying to develop a program to crash a large program that runs a big machine.
I know it sounds bad to crash it but if for some reason the machine gets out of hand we can stop the machine but it doesn't stop the program.The C# writes to a plc so the program runs the machine.Windows 10 isn't an option cuz we all hate it.

What I have tried:

I really don't know where to start. I am new to c# and programming in general.Thanks in advance

推荐答案

从Windows XP开始,在win 2000或更低版本中不可用:



这是最快的方法:

Works starting with windows XP, not available in win 2000 or lower:

This is the quickest way to do it:
Process.Start("shutdown","/s /t 0");





否则请像其他人一样使用P / Invoke或WMI。



编辑:如何避免创建窗口



Otherwise use P/Invoke or WMI like others have said.

how to avoid creating a window

var psi = new ProcessStartInfo("shutdown","/s /t 0");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);



感谢Pop Catalin

.net - 如何从C#关闭计算机 - 堆栈溢出 [ ^ ]


将其升级到Windows 10.
Upgrade it to Windows 10.


首先,您需要对编程有一个很好的理解,如何构建程序,如何运行以及它们如何对外部做出反应事件。接下来,您需要充分了解程序将运行的操作系统,以及如何与其进行交互以及与其他正在运行的程序进行交互。那么你需要一种适合这种任务的编程语言,C或C ++可能是比C#更好的选择。最后你需要明白,如果大程序运行不正常,或机器运行不正常,你的'crasher'很可能无法正常运行。



为了记录,如果你停止机器,这个其他程序如何继续运行?
Firstly you need a good understanding of programming in general, how programs are built, how they run, and how they react to external events. Next you need a good understanding of the Operating System that your program will run on, and how you can interact with it and with other running programs. Then you need a programming language that lends itself to this sort of task, C or C++ are likely better choices than C#. Finally you need to understand that if the big program is not running correctly, or the machine is not running correctly, your 'crasher' will most likely not run correctly.

And for the record, if you stop the machine how does this other program keep running?


这篇关于如何创建崩溃程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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