News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Screen Shot

Started by sp3tsnaz, November 22, 2009, 06:40:50 PM

Previous topic - Next topic

sp3tsnaz

hi, im a new member and this is my first post..

I need to take a screen shot in windows xp sp2 or other windows, and save that screen shot to a file .
The first part is easy , i can do that by calling the keyboard event function of the windows api . But the second part is weird , i have not been able to find some solution to it.. Any help is appreciated. Thankyou in advance.

Regards,
Mohsin.

2-Bit Chip

I have attached a procedure that will do the job. It can be used like this:
    invoke GetDesktopWindow
    mov hWndDesktop, eax

    invoke GetWindowImage, hWndDesktop
    mov bitmap, eax

baltoro

The code for saving the Desktop to a bitmap file is considerably longer than what 2-bit chip has in his zip, although he starts things out correctly, that code merely pushes the HBITMAP (bitmap handle) to the stack.
Once the BitBlt copies the pixel data to a memory location, you must initialize the BITMAPINFO structure, (this information can be determined by calling GetObject, and passing the HBITMAP). Then typically, you call GetDIBits to retrieve the size of the Pixel data, passing NULL for the BITMAPINFO structure (which returns the size of the pixel data), and dynamically allocate an array to hold the copied pixel data, and call GetDIBits again (with the complete BITMAPINFO structure) to write this data into memory in the native Bitmap format. Finally, you must write the BITMAPHEADER, and then write all that data in the correct sequence to a new file. It's easy to screw it up.
Baltoro

Vortex