Equivalent to C returning EXIT_SUCCESS or EXIT_FAILURE? 
Author Message
 Equivalent to C returning EXIT_SUCCESS or EXIT_FAILURE?

Hi Russel,

Check the ExitProcess() API in the MSDN.

Regards,
                  Stoil


Quote:

> [also posted to microsoft.public.vb.general.discussion - my newsreader
> isn't leting me crosspost]

> In C, you can explicitly indicate one of two return values:

> int main(void)
> {
>     /*** whatever ***/

>     return EXIT_SUCCESS; /*or EXIT_FAILURE */
> }

> Say if you compile the above into test.exe, then if you shelled it
> inside VB:

> Public Function ShellAndWait() As Long

>     Dim lngProcess As Long, lngRetVal As Long, lngTaskID As Long

>     lngTaskID = Shell("test.exe", vbNormalFocus)
>     lngProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False,
> lngTaskID)

>     Do
>         GetExitCodeProcess lngProcess, lngRetVal
>         DoEvents
>     Loop While lngRetVal = STILL_ACTIVE

>     ShellAndWait = lngRetVal

> End Function

> ShellAndWait would be either EXIT_SUCCESS or EXIT_FAILURE.

> Suppose test.exe were now a VB application. Is it possible to return
> EXIT_SUCCESS or EXIT_FAILURE? I'm thinking something that looks like
> this:

> Sub Form_UnloadEx(intRetVal As Integer)

>     'No such property as RetVal!
>     App.RetVal = intRetVal

>     'Or use some kind of API
>     SomeAPI App.hInstance, intRetVal

>     Unload Me

> End Sub

> Any advice would be appreciated.

> Thanks for reading...

> Russell





Sun, 23 Feb 2003 03:08:32 GMT  
 Equivalent to C returning EXIT_SUCCESS or EXIT_FAILURE?

Quote:

>Hi Russel,

>Check the ExitProcess() API in the MSDN.

>Regards,
>                  Stoil

One caveat, Russell: ExitProcess kills the app immediately.
In the IDE, this will bring down the IDE as well as the app,
and any cleanup done by your app will be bypassed;
files will be truncated, not flushed, etc.

You -must- ensure all cleanup is done manually, before
calling ExitProcess.



Sun, 23 Feb 2003 23:20:21 GMT  
 Equivalent to C returning EXIT_SUCCESS or EXIT_FAILURE?

Quote:

>This seems like a dangerous hack to me. Is there no cleaner way of doing

this?

Not at this time.

Quote:
>Has MS recognized this as an issue?

Not that I am aware of. VB does not do some things well;
this is one of them.

Quote:
>Even though I may have more than one shell
>running at a time, I'm tempted to use the registry to return the status. /R

That's not unreasonable; I was compelled to do the
same thing once in a Lotus Notes project.


Mon, 24 Feb 2003 05:26:19 GMT  
 Equivalent to C returning EXIT_SUCCESS or EXIT_FAILURE?
I don't know if I am off target here, but have you thought about shelling
the application with a command line. Then pass the handle of the
calling application to the command line. Your shelled application could
then send a message back to the main application.

I realise this is a bit naff, especially as you would have to sub class you
main application.

--

Regards,

Andrew Baker

http://www.vbusers.com


Quote:


> >This seems like a dangerous hack to me. Is there no cleaner way of doing
> this?

> Not at this time.

> >Has MS recognized this as an issue?

> Not that I am aware of. VB does not do some things well;
> this is one of them.

> >Even though I may have more than one shell
> >running at a time, I'm tempted to use the registry to return the status.
/R

> That's not unreasonable; I was compelled to do the
> same thing once in a Lotus Notes project.



Mon, 24 Feb 2003 20:43:05 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Another CS-Realizer question

2. good VB website(s) for high school CS teacher??

3. CS-RCS with VB6

4. ANNOUNCE: CS-RCS Version 1.2

5. Announce: CS-RCS Version 1.1

6. problem using component with asp page -- result of function not returned, instead original value returned

7. stored procedures: return codes and return status with rdo

8. Unable to return float, always returning int with ADO, IIS and SQLServer

9. Returning Recordset and Return Value from Command Object

10. ADO SQL Search That Returns 0 Records When it Should Return 1

11. Application Unload Equivalent

12. RES String Table Equivalent

 

 
Powered by phpBB® Forum Software