473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Returning Exit Codes

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?
Nov 16 '05 #1
14 2583
On Wed, 14 Apr 2004 00:26:03 -0700, =?Utf-8?B?QW5kcmV3IEhheWVz?=
<an*******@discussions.microsoft.com> wrote:
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

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
Nov 16 '05 #2
On Wed, 14 Apr 2004 07:41:00 +0000 (UTC), J French <er*****@nowhere.com>
wrote:
On Wed, 14 Apr 2004 00:26:03 -0700, =?Utf-8?B?QW5kcmV3IEhheWVz?=
<an*******@discussions.microsoft.com> wrote:
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


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

<-snip->

Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
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/

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
Nov 16 '05 #4
On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik
<Mo************@hotmail.com> wrote:

<snip>

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


I'm using FreeAgent, and just this guy's posts stand out
Nov 16 '05 #5
J French wrote:

On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik
<Mo************@hotmail.com> wrote:

<snip>

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


I'm using FreeAgent, and just this guy's posts stand out

Do you mean the "=?Utf-8?B?QW5kcmV3IEhheWVz?=" or the 200+ character wide formatting?

I'm using a plain text newsreader, and the From looks like the same garbage that
almost all "an*******@discussions.microsoft.com" users produce. Which is why I have
my newsreader set to just skip past them, and most of the time I won't even see it
unless someone else posts a followup first _and_ I choose to follow the references.

I certainly do agree with the assertion that
"There is something very wrong with your news reader"
and that something is "X-Newsreader: Microsoft CDO for Windows 2000"
Bob
--
Nov 16 '05 #6
<-snip->

Do you mean the "=?Utf-8?B?QW5kcmV3IEhheWVz?=" or the 200+ character
wide formatting?


Opera reports this as 'text/plain; charset="Utf-8"', and I don't really
notice the character wide formatting either as the messages will be
wrapped to the size of my window. Then again, I suppose this line will be
200+ characters long too.

<-snip->

Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #7
On Wed, 14 Apr 2004 01:27:27 -0700, Bob O`Bob
<fi*******@yahoogroups.com> wrote:

<snip>
I'm using FreeAgent, and just this guy's posts stand out

Do you mean the "=?Utf-8?B?QW5kcmV3IEhheWVz?=" or the 200+ character wide formatting?


Both - they really drive me nuts
I'm using a plain text newsreader, and the From looks like the same garbage that
almost all "an*******@discussions.microsoft.com" users produce. Which is why I have
my newsreader set to just skip past them, and most of the time I won't even see it
unless someone else posts a followup first _and_ I choose to follow the references.
Thats odd, most posts look just fine to me
I certainly do agree with the assertion that
"There is something very wrong with your news reader"
and that something is "X-Newsreader: Microsoft CDO for Windows 2000"


Ah - some perversion of an established standard ?
Nov 16 '05 #8
J French wrote:
On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik
<Mo************@hotmail.com> wrote:

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

I'm using FreeAgent, and just this guy's posts stand out


Try turning on word-wrapping on your end.

If I turn it off here, his paragraphs are all one huge line. When I
turn it on, they wrap.
Nov 16 '05 #9
Bob O`Bob wrote:
[...]
I certainly do agree with the assertion that
"There is something very wrong with your news reader"
and that something is "X-Newsreader: Microsoft CDO for Windows 2000"


It seems that if X-Newsreader or User-Agent is Microsoft-anything, you
can expect a post that doesn't comply to standards :-|
Nov 16 '05 #10
On Wed, 14 Apr 2004 11:32:20 +0100, C# Learner <cs****@learner.here>
wrote:
J French wrote:
On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik
<Mo************@hotmail.com> wrote:

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

I'm using FreeAgent, and just this guy's posts stand out


Try turning on word-wrapping on your end.

If I turn it off here, his paragraphs are all one huge line. When I
turn it on, they wrap.


Yes, that helps - thanks
- but he is the only one in the NGs like this
- normally when I've seen the same behaviour before, the messages are
from spammers

Nov 16 '05 #11
Don
On Wed, 14 Apr 2004 08:14:19 +0000 (UTC), er*****@nowhere.com (J French) wrote:
On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik
<Mo************@hotmail.com> wrote:

<snip>

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


I'm using FreeAgent, and just this guy's posts stand out


I'm also using FreeAgent and the post looks, hmmm, ok to me..
J, right click the message window and see if Word Wrap is checked...

Have a good day...

Don
Nov 16 '05 #12
On Wed, 14 Apr 2004 11:37:37 GMT, Do*@home.com wrote:
On Wed, 14 Apr 2004 08:14:19 +0000 (UTC), er*****@nowhere.com (J French) wrote:
On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik
<Mo************@hotmail.com> wrote:

<snip>

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


I'm using FreeAgent, and just this guy's posts stand out


I'm also using FreeAgent and the post looks, hmmm, ok to me..
J, right click the message window and see if Word Wrap is checked...


Thanks Don, as C# suggested , I've done it, and it helps
- but why this is the /only/ guy whose News Poster narks me
.... well baffles me
Nov 16 '05 #13

"J French" <er*****@nowhere.com> wrote in message
news:40***************@news.btclick.com...
I'm also using FreeAgent and the post looks, hmmm, ok to me..
J, right click the message window and see if Word Wrap is checked...


Thanks Don, as C# suggested , I've done it, and it helps
- but why this is the /only/ guy whose News Poster narks me
... well baffles me


I don't have a problem READING most of the Web-based posts, but it really
screws up the quoting during a REPLY.
Nov 16 '05 #14
Morten Wennevik wrote:
Do you mean the "=?Utf-8?B?QW5kcmV3IEhheWVz?=" or the 200+ character
wide formatting?
Opera reports this as 'text/plain; charset="Utf-8"', and I don't really
notice the character wide formatting either as the messages will be
wrapped to the size of my window. Then again, I suppose this line will be
200+ characters long too.

Oddly formatted, yes. But wide? No.
In fact, here's what it looks like to me in raw NNTP:

========quote========
<-snip->
Do you mean the "=3D?Utf-8?B?QW5kcmV3IEhheWVz?=3D" or the 200+ charact= er =
wide formatting?


Opera reports this as 'text/plain; charset=3D"Utf-8"', and I don't reall=
y =

notice the character wide formatting either as the messages will be =

wrapped to the size of my window. Then again, I suppose this line will =
be =

200+ characters long too.

<-snip->
========end quote========

a bit strange, eh?

Most days I wish NNTP had NOT been so amenable to "rich text" extensions; there's
no actual need for it in the message portion, anything required could have been
attached or posted separately as data.

Bob
Nov 16 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mark Oueis | last post by:
I've been struggling with this question for a while. What is better design? To design functions to return error codes when an error occures, or to have them throw exceptions. If you chose the...
15
by: Andrew Hayes | last post by:
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...
3
by: darrel | last post by:
This might be a really dumb question, but when should/shouldn't one use the exit function command? If I have this: function() if something then do this return that else
3
by: oktave | last post by:
Hi, Anybody would like to tell me ther defference between Application.Exit() and End? I can use End to end my application no matter how many forms and codes after the End statement. But since...
8
by: Zeno Lee | last post by:
What is the best way to return an exit code from a VB.NET windows forms app? My Forms application is dual purpose. It is an interactive windows app. It is also automated and run via a script and...
3
by: asearle | last post by:
Hallo everyone, I have a perl script which can return error codes. I have done this with, for example, 'exit 11;', which would (I imagine) send the exit code 11 (instead of 0) back to the calling...
8
by: Patrick Hill | last post by:
Hi there, I have a small little console application that has a function that returns a string. is there anyway for me to have this string variable returned to another process? I was doing some...
8
by: Michal Nazarewicz | last post by:
Hi, What does returning 0 from main() mean according to C89/C90 standard? I've found that in C99 it means successful termination (7.20.4.3p5) however as I'm editing book on C at Polish Wikibooks...
3
by: =?ISO-8859-1?B?R+ln6Q==?= | last post by:
Hi all, I'd like to know the meaning of this exit code : ( c++ program compiled with vc++) "Exit Code -1073741819." Is there a table for exit codes ? Thanks
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.