locked
Using LoadPicture function to load an corrupted jpg hang my application RRS feed

  • Question

  • I have two problems of using LoadPicture function. The first one is when load a corrupted picture, VB6 can return invalid picture run-time error under IDE. However if the code compiled to an exe file, it with hangs my application when loading a corrupted picture.

    The second one is it will casue access violation at memory reading

    The following is the code:

    Private Sub Command1_Click()
    On Error GoTo trap:
        Picture1 = LoadPicture("invalidpic.jpg") 'the corrupted file
    Exit Sub
    trap:
    MsgBox Err.Description, vbExclamation, "Error"
    End Sub

    When executive the compiled .exe file, it can goto to the error handler when command button was clicked first time. When click the button at the second time, it will cause access violation to shutdown the application.

    I'm using VB 6 SP6 + Windows Server 2003 (x86) SP2 with 4GB ram (PAE enabled)


    I've tested the OleLoadPicture function to load a picture under C++. It give me the same result. I found that the error is cause by the OleLoadPicture function. It seems that this function cause memory corruption or infinely looping when reading the corruption images.

    This is a know issue in Windows 98, 2000 and XP. Does anybody know how to fix this under Windows Server 2003?


    Monday, February 2, 2009 3:57 PM