Results 1 to 3 of 3

Thread: Return an exit code with ExitProcess

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    France
    Posts
    7

    Question

    In my Application, I have the following code :
    Code:
    Private Declare Sub ExitProcess Lib "kernel32" _
          (ByVal uExitCode As Long)
    Private lExitCode As Long
    
    Private Sub Form_Load()
       lExitCode = 0&
    End Sub
    
    Private Sub mnuExport_Click()       
       mnuExport.Checked = IIf(mnuExport.Checked, vbUnchecked,
    vbChecked)
       If (mnuExport.Checked) Then lExitCode = 1&          
    End Sub
    
    Private Sub Form_Terminate()
       ExitProcess lExitCode    
    End Sub
    But this return always 0 even if I check the item in my menu
    And when I try to place a breakpoint on ExitProcess and execute, it causes a GPF(General Protection Fault) and VB crashes....

    Anyone has knowledge of this bug or know a solution ?

    Nicolas Joannidès
    Visual Basic, C, ASP
    [email protected]

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    could try using mnuExport.value with true false options instead?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Lively Member
    Join Date
    Aug 2000
    Location
    Ontario, Canada
    Posts
    79
    Try using the ExitProcess with the actual exit value instead of a variable containing the exit value:

    Code:
    Private Sub Form_Terminate()
    
      If(mnuExport.Checked) then
        ExitProcess 1&
      Else
        ExitProcess 0&
      EndIf
    
    End Sub
    I think that will work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width