Returning Exit Codes

G

Guest

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?
 
J

J French

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
 
M

Morten Wennevik

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]
 
B

Bob O`Bob

J said:
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
 
J

J French

On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik

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
 
B

Bob O`Bob

J said:
On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik



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 "(e-mail address removed)" 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
--
 
M

Morten Wennevik

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]
 
J

J French

On Wed, 14 Apr 2004 01:27:27 -0700, Bob O`Bob

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 "(e-mail address removed)" 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 ?
 
C

C# Learner

J said:
On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik




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.
 
C

C# Learner

Bob said:
[...]
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 :-|
 
J

J French

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
 
D

Don

On Wed, 14 Apr 2004 09:50:49 +0200, Morten Wennevik



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
 
J

J French

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
 
J

Jeff Johnson [MVP: VB]

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.
 
B

Bob O`Bob

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========
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
 
B

Bonj

what, literally *lethal* ?

"You WILL *die* if you use this function!!! "


component and I was wondering if the VB6 EXE can return an exit code
different than 0?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.the registry, so does anyone know if it's even possible in VB6? Maybe with a
Win32 API call?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top