[vbox-dev] takecSreenShot

一生有你 793606370 at qq.com
Mon May 20 09:50:26 GMT 2013


I tried to take a screen shot by takecSreenShot(),,but everytime when i trys it, display->TakeScreenShot fails,,and VisualBox.exe crashes....
 I am sure that I can get the correct width and height of the screen "printf("Width: %ul Height: %ul Bits Per Pixel: %ul. ", width,height,bpp);"......
 my vbox and SDK version are the same 4.1.6....
 please help me ...thank U!!
  
 ///////here is the code..........bellow
 int testTakeScreenShot(ISession *session)
{
    IConsole *console = NULL;
    IDisplay *display = NULL;
    IFramebuffer* fb=NULL;
    unsigned long width, height, bpp;
    SIZE_T buffersize;
    BYTE* databuff;
     HRESULT rc;
    if (session == NULL)
      return 1;
  /* Get console object. */
    rc=session->get_Console(&console);
    rc=console->get_Display(&display);
  
     display->GetScreenResolution(0,&width,&height,&bpp);
    printf("Width: %ul Height: %ul Bits Per Pixel: %ul. ", width,height,bpp);
     buffersize = width*height*bpp/8;
    databuff= (BYTE*)CoTaskMemAlloc(buffersize);
     printf("%p\n", databuff);
 
  
   // Test databuffer
  if (databuff != NULL)
  {
   rc = display->TakeScreenShot(0,databuff,width,height);
    if (SUCCEEDED(rc))
   {
    printf("Took a screenshot! %d\n", rc);
   }
   else
   {
    printf("Error taking screen shot! rc = 0x%x\n", rc);
   }
   CoTaskMemFree(databuff);
  }
 return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20130520/69f81ca2/attachment.html>


More information about the vbox-dev mailing list