返回退出代码 [英] Returning Exit Codes

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

问题描述

大家好


我正在使用Process组件从C#.NET应用程序调用旧的VB6程序,我想知道VB6 EXE是否可以返回不同的退出代码比0


我知道我可以使用Environment.ExitCode属性甚至是Environment.Exit方法,如果被调用的应用程序是用VB.NET编写的,但我不是要花几个月的时间将这个应用程序移动到.NET


我也不想把退出信息写入文件或注册表,所以有人知道它是不是甚至可能在VB6中?也许使用Win32 API调用?

Hi All

I''m calling an old VB6 program from a C#.NET application using a Process component and I was wondering if the VB6 EXE can return an exit code different than 0

I know I could use the Environment.ExitCode property or even the Environment.Exit method if the called app was written using VB.NET, but I''m not looking to spend several months moving this app to .NET

I''d also rather not mess about with writing exit information to a file or the registry, so does anyone know if it''s even possible in VB6? Maybe with a Win32 API call?

推荐答案

2004年4月14日星期三00:26:03 -0700,=?Utf-8?B? QW5kcmV3IEhheWVz?=

< an ******* @ discussion.microsoft.com>写道:
On Wed, 14 Apr 2004 00:26:03 -0700, =?Utf-8?B?QW5kcmV3IEhheWVz?=
<an*******@discussions.microsoft.com> wrote:
大家好,

我正在使用Process组件从C#.NET应用程序调用旧的VB6程序,我想知道是否VB6 EXE可以返回不同于0的退出代码吗?

我知道我可以使用Environment.ExitCode属性,甚至可以使用Environment.Exit方法,如果被调用的应用程序是用VB.NET编写的,但是我我不打算花几个月的时间将这个应用程序移植到.NET。

我也不想把退出信息写入文件或注册表,所以有人都知道它是否'在VB6中甚至可能吗?也许用Win32 API调用?
Hi All,

I''m calling an old VB6 program from a C#.NET application using a Process component and I was wondering if the VB6 EXE can return an exit code different than 0?

I know I could use the Environment.ExitCode property or even the Environment.Exit method if the called app was written using VB.NET, but I''m not looking to spend several months moving this app to .NET.

I''d also rather not mess about with writing exit information to a file or the registry, so does anyone know if it''s even possible in VB6? Maybe with a Win32 API call?




我真的希望你能理清你的名字

- 和换行

你的新闻阅读器出了什么问题


关于退出代码,几个星期前讨论过这个问题

前,答案似乎你可以做到,但是那边

效果和并发症是/致命/


我不太了解C#

- 但我敢打赌,它可以干净地挂钩Windows消息


一种方法是使用

生成一个独特的消息RegisterWindowMessage

- 然后用HWND_BROADCAST做一个PostMessage


你也可以使用TCP / IP

实际上有很多方法


但是,我倾向于使用File方法

- 它可能有点笨拙,但它很容易调试



I really wish you would sort out your name
- and line wrapping
There is something very wrong with your news reader

About the Exit Code, there was a discussion about that a few weeks
ago, and the answer appeared to be that you can do it, but the side
effects and complications are /lethal/

I don''t know much about C#
- but I''ll bet that it can hook Windows messages cleanly

One method would be to generate a unique message using
RegisterWindowMessage
- and then doing a PostMessage with HWND_BROADCAST

You could also use TCP/IP
In fact there are numerous methods

However, I would be inclined to use the File method
- it may be a bit honky, but it is very easy to debug


2004年4月14日星期三07:41:00 +0000(UT C),J French< er ***** @ nowhere.com>

写道:
On Wed, 14 Apr 2004 07:41:00 +0000 (UTC), J French <er*****@nowhere.com>
wrote:
2004年4月14日星期三00:26: 03 -0700,=?Utf-8?B?QW5kcmV3IEhheWVz?=
< a ******* @ discussion.microsoft.com>写道:
On Wed, 14 Apr 2004 00:26:03 -0700, =?Utf-8?B?QW5kcmV3IEhheWVz?=
<an*******@discussions.microsoft.com> wrote:
大家好,

我正在使用
Process组件从C#.NET应用程序调用一个旧的VB6程序想知道VB6 EXE是否可以返回不同于0的退出代码?

我知道我可以使用Environment.ExitCode属性甚至是
Environment.Exit方法,如果被称为app的应用程序是使用VB.NET编写的,但是我不打算花几个月的时间将这个应用程序移植到.NET。

我也不会因为写作而烦恼退出信息到文件
或注册表,所以有人知道它是否甚至可能在VB6中?
也许有一个Win32 API调用?
Hi All,

I''m calling an old VB6 program from a C#.NET application using a
Process component and I was wondering if the VB6 EXE can return an exit
code different than 0?

I know I could use the Environment.ExitCode property or even the
Environment.Exit method if the called app was written using VB.NET, but
I''m not looking to spend several months moving this app to .NET.

I''d also rather not mess about with writing exit information to a file
or the registry, so does anyone know if it''s even possible in VB6?
Maybe with a Win32 API call?



我真的希望你能理清你的名字
- 和换行
有一些非常的错误您的新闻阅读器



I really wish you would sort out your name
- and line wrapping
There is something very wrong with your news reader




我的新闻阅读器(Opera 7.23)中的消息和名称都显示正常。


< -snip - >


快乐的编码!

Morten Wennevik [C#MVP]



Both message and name appears fine in my news reader (Opera 7.23).

<-snip->

Happy coding!
Morten Wennevik [C# MVP]


J French写道:
J French wrote:
关于退出代码,几个星期前有一个关于这个问题的讨论,答案似乎是你可以做到,但是效果和并发症是/致死/
About the Exit Code, there was a discussion about that a few weeks
ago, and the answer appeared to be that you can do it, but the side
effects and complications are /lethal/



和End Statement完全相同。

这意味着如果你真的想要你可以_can_这样做。

只要确保你完成所有清理工作,

包括卸载表格。


私有声明Sub ExitProcess Lib" KERNEL32" (ByVal uExitCode As Long)


请注意,如果你在IDE中调用它,你最好先保存

或者你会后悔< g>实际上,我通常在

中包含一些IDE保护,就像这个简单的hack:


Public Sub ExitWithCode(lCode As Long)

错误GoTo IDE

Debug.Print 1/0

ExitProcess lCode

IDE:

MsgBox"退出代码=" &安培; lCode,vbCritical,IDE

停止

结束子


(这就是为什么我有上面的声明作为私人)

Bob


In exactly the same way as the End Statement.
Which means you _can_ do it if you really want to.
Just make sure you accomplish ALL your cleanup FIRST,
including unloading forms.

Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)

And be aware that if you call it while in the IDE, you''d better have saved
first or you''ll regret it <g> Actually, I normally wrap the call in
some sort of IDE-protection, like this simple hack:

Public Sub ExitWithCode(lCode As Long)
On Error GoTo IDE
Debug.Print 1 / 0
ExitProcess lCode
IDE:
MsgBox "Exit Code = " & lCode, vbCritical, "IDE"
Stop
End Sub

(that''s why I have the Declare above as Private)
Bob


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

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