473,396 Members | 2,129 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,396 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 2584
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.