Solved

exception code 0xc0000005 help

Posted on 2008-10-28
2
1,228 Views
Last Modified: 2012-05-05
Exception Code 0xc0000005

I am having a problem that I cannot completely understand.  I have written a VB 6 program that will create an image from a bytearray without writing it to a file on the hard drive.  It is very important that all of this is done in memory and the image is not written to a file.

The function I use to do this is from Edanmo's OLE Interfaces & Functions v1.81 (from http://www.mvps.org/emorcillo/en/index.shtml) and here is the code:

Public Function LoadImage( _
   ImageBytes() As Byte) As StdPicture
Dim oPersist As IPersistStream
Dim oStream As IStream
Dim lSize As Long
 
   ' Calculate the array size
   lSize = UBound(ImageBytes) - LBound(ImageBytes) + 1
   
   ' Create a stream object
   ' in global memory
   Set oStream = CreateStreamOnHGlobal(0, True)
   
   ' Write the header to the stream
   oStream.Write &H746C&, 4&
   
   ' Write the array size
   oStream.Write lSize, 4&
   
   ' Write the image data
   oStream.Write ImageBytes(LBound(ImageBytes)), lSize
   
   ' Move the stream position to
   ' the start of the stream
   oStream.Seek 0, STREAM_SEEK_SET
     
   ' Create a new empty picture object
   Set LoadImage = New StdPicture
   
   ' Get the IPersistStream interface
   ' of the picture object
   Set oPersist = LoadImage
   
   ' Load the picture from the stream
   oPersist.Load oStream
     
   ' Release the streamobject
   Set oStream = Nothing
   
End Function

In my program there are several different buttons that can be clicked.  Each button will load a series of images to be shown on another form.  When clicking the second of these buttons, I receive an error "Analyzer has encountered a problem and needs to close.  We are sorry about the inconvenience." and it allows me to send an error report.  Viewing the technical data it shows an exception code 0xc0000005.  By adding message boxes to the program I have narrowed the error down to the line: oPersist.Load oStream while loading the 5th picture every time.

Here is what I do not fully understand about this issue.  I get the error every time I open the program and only click the second button.  If I open the program, click the first button, click a few others and then click the second button, it works fine.  It works fine on any development machines where I could debug the code as well.  The only machines where it errors are the ones I need it to not error on.

I have made sure I have all needed license files and ocx files in the system32 folder.  Running Adaware has come up with no spyware that could have caused the error.  Any suggestions?
0
Comment
Question by:4county
  • 2
2 Comments
 

Accepted Solution

by:
4county earned 0 total points
ID: 22825469
I beat you all to the solution.  It seems that running a simple Windows Update fixed the issue.
0
 

Author Comment

by:4county
ID: 22830268
The Windows update seems to have only been a temporary solution.  This morning the error persists.  How do I mark this as an open question again?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now