Windows退出代码的意义. [英] Windows Exit Code Significance.

查看:130
本文介绍了Windows退出代码的意义.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我有问题...
好吧,我不能称其为问题.
我正在使用Windows Scheduler调度我制作的应用程序,并根据受影响的记录数返回一些值.
它作为服务运行,并创建一个日志文件.我一直在偷看文件以监视输出.为此,我返回了已处理的记录数.

它会在一定程度上影响Window环境吗?

如果不是,那么应用程序的ExitCode的意义是什么.

谢谢,
Fazal

Dear Friends,

I am having a problem...
Well I cant call it a problem.
I am scheduling an Application which I have made, using Windows Scheduler, and I am returning some values depending on the number of records affected.
It runs as a service, and creates a log file. I have keep on peeking into the file to monitor the Output. For this I have returned the number of records processed.

Will it affect the Window environment in sense?

If not, then what is the significance of the ExitCode of applications.

Thanks,
Fazal

推荐答案

它可能不会起作用.

这是DOS时代的遗产:所有程序都返回一个int.零是可以的,其他任何值都是错误代码.然后,批处理程序可以测试返回码并决定要执行的处理.

最初开发Windows时,它是DOS之上的图形外壳,因此它的应用程序继承了错误代码return.

使用System.Diagnostics.Process类启动进程时,可以访问返回码(调试程序时VS的输出窗格中显示该返回码).
It probably won''t effect anything.

It is a legacy from the days of DOS: all programs returned an int. Zero was OK, any other value was an error code. Batch programs could then test return codes and decide what processing to do as a result.

When Windows was first developed, it was a Graphical shell on top of DOS, and so it''s applications inherited the error code return.

You can access a return code (it is shown in the output pane of VS when you debug a program) when you start a process using the System.Diagnostics.Process class.


这些天ExitCode非常有限.它主要是为控制台应用程序而设计的,这些实用程序将其功能视为单个函数调用,用于控制台应用程序:输出中的命令行字符串,ExitCode中的返回值,通过stdoutstderr输出到控制台的文本-这是函数的副作用.最典型的目的是返回带有错误代码的成功/错误.批处理文件(或Shell脚本文件)可以检查错误状态,并在批处理脚本代码的某些if分支中使用它.

它可以在任何地方使用(也可以在窗口应用程序中使用),并且没有任何其他作用.当您使用CreateProcessExProcess.Create创建一个进程时,可以保留该进程的句柄,加入子进程(等待直到完成),然后作为有关ExitCode的进程句柄.所获得的值可以用于与我上述的目的相同的目的.

我不会说它没有认真的应用. (一种相对流行的用法是使用一些非标准工具制作肮脏的构建脚本,但我认为此活动非常肮脏,几乎是一种犯罪-在我们获得了非常强大的MSBuild实用程序之后,该实用程序可以基于有据可查的技术.)

—SA
The significance of ExitCode is very limited these days. It was mostly designed for console applications for utilities treated in functionality as a single function calls: command line string in output, return value in ExitCode, text output to console via stdout and stderr — a function side effect. Most typical purpose is to return success/error with error code. Batch files (or shell script files) could checkup the error status and use it in some if branches of the batch script code.

It can be used anywhere (windowed applications, too) and has not other effect whatsoever. When you create a process using CreateProcessEx or Process.Create one can preserve the process handle, join the child process (wait until it is complete) and than as the process handle about the ExitCode. The obtained value could be used for the same purposes as those I described above.

I would not say it has no serious applications. (A relatively popular use is making dirty build scripts using some non-standard tools, but I consider this activity as very dirty, nearly a crime — after we got very robust MSBuild utility which allows to integrate anything at all very smoothly based on the very well documented technology.)

—SA


这篇关于Windows退出代码的意义.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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