Does the API call ExitProcess () in VB6 in order if you follow MS warnings?

Microsoft indicates that VB6 does not support ExitProcess (for exiting and returning a value).

However, this indicates that this call may fail in certain circumstances (if the thread was not completed, etc.)

so I wonder if this call will work fine (sequentially :-) as long as you obey the disclaimers in the article.

I could take another step and call ExitProcess () from the Sub Main or Form that the application was watching.

Update : after some more reading (I did examine this a bit before the request), I found a suggestion to use the TerminateProcess API . I am exploring this option.

Any thoughts?

+3
source share
3 answers

The best option is probably to create a Sub Main entry point anyway and call ExitProcess from there, not from a class or form. Or (this is what I'm doing) call ExitProcess from the Form Unload event and have a main entry point, for example:

Sub Main Code Launch Form Exit Home

Then: Form_Unload code ExitProcess End sub 'Form_Unload

Thus, ExitProcess will be the last bit of code that you execute. It won't be pretty, and you probably miss some pens and more, but NT4 and above do a pretty good job of this. In other words, launch the application from Sub Main and call the API before you exit.

: Kprobst, , . .

+1

Karl Peterson VB6? Con.ExitCode = 1 ( ).

vbAdvance, .

+2

: vb6

Public ErrorLevel As Long

:

Public Sub UnloadAll()

Dim f As Integer

f = Forms.Count

Do While f > 0

  Unload Forms(f - 1)

  If f = Forms.Count Then Exit Do

  f = f - 1

ExitProcess ErrorLevel

Sub

"" :

UnloadAll

0

Source: https://habr.com/ru/post/1750540/


All Articles