Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

I am trying to verify my vhd file . I use Virtual Box Com Api c++ to do the verification job. My requirement is, i want to create a vm using the VHD and check if it is booting up, take screen shot of the VM that is running and save the screenshot in a particular screen shot as jpeg, or any picture file format in a location in the host machine.

The Following Part i have completed successfully :

I) Have created VM using the given VHD.
ii) Have booted up the VM.
iii) Have taken screenshot of the VM.

Now, How to save the Screenshot?

Below is upto what i have completed. the below function succeeds, What should i do next to proceed with the screenshot.
or how to use the screenshot obtained?

ULONG l_screenID = 0;
BYTE address;
ULONG width = 32;
ULONG height = 32;
rc = display->TakeScreenShot(l_screenID, &address, width, height);<b></b>
Posted
Comments
[no name] 24-Feb-12 23:27pm    
Your screenshot is going to be very small with only a single BYTE to store the bitmap bits. :)
gssajith87 25-Feb-12 2:06am    
Thanks. So what should i do to take the entire screen and how will i save the screenshot to a file?

1 solution

Hi,

Why have you neglected to do the research yourself on these Virtual Box API calls? I have never used the Virtual Box API but it took less than 10 seconds to find the SDK reference using my favorite search engine.

Virtual Box IDisplay[^]

I do realize that codeproject.com is the coolest orange website on the planet but you would probably get great advice from software engineers that have experience using this API from the virtual box forum.

Virtual Box Forum[^]

I am guessing that you should do the following:

1.) Call getScreenResolution and get the width, height and bit depth.
2.) Change your BYTE into a LPBYTE and allocate the space required for the bitmap using width,height,bit depth.
3.) Call takeScreenShot or takeScreenShotToArray or perhaps takeScreenShotPNGToArray to get the bitmap bits.

Some caveats: It looks like takeScreenShot and takeScreenShotToArray always returns 32 bit bitmap bits based on SDK description. It also looks like takeScreenShotPNGToArray might be the best choice, you might even be able to dump the returned buffer into a file.

Best Wishes,
-David Delaune
 
Share this answer
 
Comments
gssajith87 27-Feb-12 8:47am    
Thanks... takeScreenShotPNGToArray worked for me..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900