Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++C++/CLICOMOracle, +
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 24-Feb-12 4:24am
Comments
Randor at 24-Feb-12 23:27pm
   
Your screenshot is going to be very small with only a single BYTE to store the bitmap bits. :)
gssajith87 at 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
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
gssajith87 at 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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 860
1 OriginalGriff 427
2 Abhinav S 303
3 thatraja 225
4 CPallini 208
0 Sergey Alexandrovich Kryukov 8,122
1 OriginalGriff 4,520
2 Peter Leow 3,744
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 25 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid