obtain win desktop picture

  • Thread starter Thread starter MuZZy
  • Start date Start date
M

MuZZy

Hello,

How do i get Windows Desktop picture to further put it into pictureBox
component?

Thank you,
Andrey
 
The path used for the current wallpaper is stored in the registry, I don't
remember the exact key, you'll have to search for it.

So, read this key and then assign it to the pictureBox.Image property...
 
Well, I didn't men wallpaper, i meant everything you see on the screen.

On Delphi i've done it this way:

Class Procedure TMuzzyServer.getScreen( ABitmap : TBitmap );
Var
dc : Integer;
srect : TRect;
scanvas : TCanvas;
Begin
// get desktop HDC
dc := GetWindowDC(0);
// Create a rectangle with screen size
srect := Rect(0, 0, Screen.Width, Screen.Height);
// Create a canvas for desktop HDC
scanvas := TCanvas.Create();
scanvas.Handle := dc;
ABitmap.Height := srect.Bottom;
ABitmap.Width := srect.Right;
ABitmap.Canvas.CopyRect(srect, scanvas, srect);
ReleaseDC(0, dc);
scanvas.Free;
End;

/////

So i obtained HDC of desktop window which has HANDLE = 0, and then played
around.

How do i do in .NET?

Thank you,
Andrey
 
MuZZy said:
Well, I didn't men wallpaper, i meant everything you see on the screen.

On Delphi i've done it this way:

Class Procedure TMuzzyServer.getScreen( ABitmap : TBitmap );
Var
dc : Integer;
srect : TRect;
scanvas : TCanvas;
Begin
// get desktop HDC
dc := GetWindowDC(0);
// Create a rectangle with screen size
srect := Rect(0, 0, Screen.Width, Screen.Height);
// Create a canvas for desktop HDC
scanvas := TCanvas.Create();
scanvas.Handle := dc;
ABitmap.Height := srect.Bottom;
ABitmap.Width := srect.Right;
ABitmap.Canvas.CopyRect(srect, scanvas, srect);
ReleaseDC(0, dc);
scanvas.Free;
End;

/////

So i obtained HDC of desktop window which has HANDLE = 0, and then played
around.

How do i do in .NET?

Thank you,
Andrey

Basicly what i want to do is to capture screen images in certain intervals
of time or on certain event, and put it in a database. So i need a screen
image, same as if i pressed [PrintScreen] button.
 
Back
Top