Click here to Skip to main content
13,189,324 members (68,829 online)
Rate this:
Please Sign up or sign in to vote.

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 24-Feb-12 4:24am
Randor 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


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 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
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171016.2 | Last Updated 25 Feb 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100