Saqib
Saqib

Reputation: 2273

How To Clear A Picture Box Image?

I'm creating a key logger in vb 2008 for my home computer that can send keys

records & screen shoots at my E-mail. It has a textbox, 3 buttons, a picturebox and some

timers,

actually the process is that in every 3 minutes button1 take a screen shoot (at 2.90 minutes)

OK, then button2 save it in "C:/mydir/hidden folder/" (at 2.95 minutes) then button3 send it

via Email as a attachment (at 3.00 minutes), its work fine in first round or first 3 minutes.

but in Repeating Process or in 2nd round or after 3 minutes it give error that means image is

in use, I want to break the link between image and my program (key logger) there for my

keylogger can delete or REPLACE old Screen Shoot With New One.

and the process repeat again & again, and send Screen Shoots With NO error.

My English is not so good. Sorry for Spell and grammatical Mistakes.

Upvotes: 1

Views: 1292

Answers (1)

HndlCode
HndlCode

Reputation: 115

The following code will dispose the image after saving it

Using b As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
    'Do some code to fill the image
    b.Save("C:\Somewhere\image.jpg")
End Using

Upvotes: 1

Related Questions