none
Test Case 30: Visual Basic 6 Application

    Question

  • My VB6 application (unmanaged application) doesn’t shutdown!!

     

    Only for test, I tested an application (Blank application with VB6, no code, only one Form), and the application doesn't shutdown and doesn't restart!!!!!

     

    So, my question is about VB6 (unmanaged application), Do I need add code to my application for pass this test????? What should I do????? I think the problem is with Visual Basic.

     

    Thank you.

    Friday, January 12, 2007 10:26 PM

Answers

  • Mo Nail and I have been doing a lot of research on this. Eventually a reasonable solution was found to the cause of the problem.

    Without getting into a lot of detail: The VB6 runtime is getting stuck in an infinite loop by the rmtool windows message. This is because the VB application is not handling the windows message as one would expect.

    Our initial research found that only through subclassing could this be accomplished. Subclassing in VB6 is not a recommend practice. However, recently code was shared with us on how to accomplish this in a different manner.  This second work around is acceptable because is simply implements the Form Query Unload event and listens for the UnloadMode=2. Then it directly calls the Unload Me.

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

        '   For Vista Certification requirement.
        '   Handles TEST CASE 30. Verify the application is Restart Manager Aware.

        If UnloadMode = 2 Then
            Unload Me

        End If

    End Sub

     


    Our testing indicates this only needs to be on the startup form. However our results should not be relied upon. You should only trust your own testing efforts.

    ******** Important  Disclaimer************

    Any sample code is provided for the purpose of illustration only and is not intended to be used in a production environment. We grant you a nonexclusive, royalty-free right to use and modify the sample code and to reproduce and distribute the object code form of the sample code, provided that you agree: (i) to not use Microsoft's name, logo, or trademarks to market your software produced in which the sample code is embedded; (ii) to include a valid copyright notice on your software product in which the sample code is embedded; (iii) to provide on behalf of and for the benefit of your subcontractors a disclaimer of warranties, exclusion of liability for indirect and consequential damages and a responsible limitation of liability; and (iv) to indemnify, hold harmless, and defend Microsoft, its affiliates and suppliers from and against any third party claims or lawsuits, including attorney's fees, that arise or result from the use or distribution of the sample code.

    Thursday, February 15, 2007 11:01 PM

All replies

  • I was unable to reproduce this problem using the steps you mentioned.  Are you having the problem on the development machine or on a test machine?  I tested on a Vista RTM with Visual Studio 6 installed.
    Monday, January 15, 2007 5:35 PM
  • Hello

    My VB6 Application is crashed when I run rmtool.exe -p dwIP -S.

    The problem is with a development machine and test machine.

    I'm using Windows Vista RTM.

    Thank you

     

    Saturday, January 20, 2007 3:43 PM
  • I am now able to reproduce with this additional information, and will research the problem.
    Monday, January 22, 2007 4:55 PM
  • I wanted to update you that this issue is still being investigated, and I hope to provide more information soon.
    Friday, February 02, 2007 11:18 PM
  • Mo Nail and I have been doing a lot of research on this. Eventually a reasonable solution was found to the cause of the problem.

    Without getting into a lot of detail: The VB6 runtime is getting stuck in an infinite loop by the rmtool windows message. This is because the VB application is not handling the windows message as one would expect.

    Our initial research found that only through subclassing could this be accomplished. Subclassing in VB6 is not a recommend practice. However, recently code was shared with us on how to accomplish this in a different manner.  This second work around is acceptable because is simply implements the Form Query Unload event and listens for the UnloadMode=2. Then it directly calls the Unload Me.

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

        '   For Vista Certification requirement.
        '   Handles TEST CASE 30. Verify the application is Restart Manager Aware.

        If UnloadMode = 2 Then
            Unload Me

        End If

    End Sub

     


    Our testing indicates this only needs to be on the startup form. However our results should not be relied upon. You should only trust your own testing efforts.

    ******** Important  Disclaimer************

    Any sample code is provided for the purpose of illustration only and is not intended to be used in a production environment. We grant you a nonexclusive, royalty-free right to use and modify the sample code and to reproduce and distribute the object code form of the sample code, provided that you agree: (i) to not use Microsoft's name, logo, or trademarks to market your software produced in which the sample code is embedded; (ii) to include a valid copyright notice on your software product in which the sample code is embedded; (iii) to provide on behalf of and for the benefit of your subcontractors a disclaimer of warranties, exclusion of liability for indirect and consequential damages and a responsible limitation of liability; and (iv) to indemnify, hold harmless, and defend Microsoft, its affiliates and suppliers from and against any third party claims or lawsuits, including attorney's fees, that arise or result from the use or distribution of the sample code.

    Thursday, February 15, 2007 11:01 PM
  • My VB6 application doesn't even get to the Form_QueryUnload event when I run:

    rmtool -p dwPID -S

    (I substitute the process id for dwPID)


    Wednesday, March 07, 2007 4:09 PM
  • Do you get the same results when the application is not running under debugger?

    You also added the code to the main startup form correct? The main startup form remains visible the entire time you application is running? Any other informaion about your applications design will be useful too......
    Wednesday, March 07, 2007 4:42 PM
  • Interestingly, I ran the rmtool for calc.exe and notepad.exe, and neither one of them unloaded, either. I restarted and it seemed to fix the problem with my app, calc, and notepad.

    TC31 also required a revert to a previous snapshot because our app just closed with no popup window - same behavior as calc and notepad too.

    PS - have an off topic question, can you send me a PM?
    Wednesday, March 07, 2007 4:52 PM
  • I'm not with MSFT anymore. I just come out here for fun now...
    Thursday, March 08, 2007 5:14 PM
  • The RM code I sent you before you left doesn't work in VB6 consistently.

    The solution seems to be to run rmtool.exe in two steps:

    rmtool -p <PID>
    rmtool -p <PID> -S

    Running "rmtool -p <PID> -S doesn't shut down the app.
    Monday, March 12, 2007 8:01 PM
  • I have been working on this problem for some time now and still don't have a suitable solution. Sometimes the rmtool works and sometimes it doesn't (more often than not it doesn't work). What can we do to get Windows Vista Certification with a VB6 program?

    I am using a message hook to listen for the messages. When I close a session it always picks up the message, but with the RMtool it rarely does. Why is this happening?

     

     

     

    Saturday, March 17, 2007 2:28 PM
  • Just an update on this. I finally found the problem. An OCX had a form which was not shown, but was loaded and didn't have

    If UnloadMode = 2 then Unload Me

    in the QueryUnload event.

    All EXEs, OCXs & DLLs must have this in the QueryUnload event in order to pass Test Case 30.

    Gary

     

    Thursday, March 22, 2007 12:19 PM